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.
5 #include "apps/app_launcher.h"
7 #include "apps/field_trial_names.h"
8 #include "apps/pref_names.h"
9 #include "base/metrics/field_trial.h"
10 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/pref_service.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/ui/host_desktop.h"
16 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
17 #include "chrome/installer/util/browser_distribution.h"
22 bool IsAppLauncherEnabled() {
23 #if !defined(ENABLE_APP_LIST)
26 #elif defined(OS_CHROMEOS)
29 #else // defined(ENABLE_APP_LIST) && !defined(OS_CHROMEOS)
30 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH
)
33 PrefService
* prefs
= g_browser_process
->local_state();
34 // In some tests, the prefs aren't initialised.
35 return prefs
&& prefs
->GetBoolean(prefs::kAppLauncherHasBeenEnabled
);
39 bool ShouldShowAppLauncherPromo() {
40 PrefService
* local_state
= g_browser_process
->local_state();
41 // In some tests, the prefs aren't initialised.
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
);