Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "apps/app_launcher.h" |
| 6 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 7 | #include "apps/field_trial_names.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 8 | #include "apps/pref_names.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 9 | #include "base/metrics/field_trial.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 10 | #include "base/prefs/pref_registry_simple.h" |
| 11 | #include "base/prefs/pref_service.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 12 | #include "chrome/browser/browser_process.h" |
| 13 | #include "chrome/browser/ui/host_desktop.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 14 | |
| 15 | #if defined(OS_WIN) |
| 16 | #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
| 17 | #include "chrome/installer/util/browser_distribution.h" |
| 18 | #endif |
| 19 | |
| 20 | namespace apps { |
| 21 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 22 | bool IsAppLauncherEnabled() { |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame^] | 23 | #if !defined(ENABLE_APP_LIST) |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 24 | return false; |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame^] | 25 | |
| 26 | #elif defined(OS_CHROMEOS) |
| 27 | return true; |
| 28 | |
| 29 | #else // defined(ENABLE_APP_LIST) && !defined(OS_CHROMEOS) |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 30 | if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 31 | return true; |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame^] | 32 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 33 | PrefService* prefs = g_browser_process->local_state(); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 34 | // In some tests, the prefs aren't initialised. |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame^] | 35 | return prefs && prefs->GetBoolean(prefs::kAppLauncherHasBeenEnabled); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 36 | #endif |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 37 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 38 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 39 | bool ShouldShowAppLauncherPromo() { |
| 40 | PrefService* local_state = g_browser_process->local_state(); |
| 41 | // In some tests, the prefs aren't initialised. |
| 42 | if (!local_state) |
| 43 | return false; |
| 44 | std::string app_launcher_promo_group_name = |
| 45 | base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName); |
| 46 | return !IsAppLauncherEnabled() && |
| 47 | local_state->GetBoolean(apps::prefs::kShowAppLauncherPromo) && |
| 48 | (app_launcher_promo_group_name == apps::kShowLauncherPromoOnceGroupName || |
| 49 | app_launcher_promo_group_name == |
| 50 | apps::kResetShowLauncherPromoPrefGroupName); |
| 51 | } |
| 52 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 53 | } // namespace apps |