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"
17 bool IsAppLauncherEnabled() {
18 #if !defined(ENABLE_APP_LIST)
21 #elif defined(OS_CHROMEOS)
24 #else // defined(ENABLE_APP_LIST) && !defined(OS_CHROMEOS)
25 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH
)
28 PrefService
* prefs
= g_browser_process
->local_state();
29 // In some tests, the prefs aren't initialised.
30 return prefs
&& prefs
->GetBoolean(prefs::kAppLauncherHasBeenEnabled
);
34 bool ShouldShowAppLauncherPromo() {
35 PrefService
* local_state
= g_browser_process
->local_state();
36 // In some tests, the prefs aren't initialised.
39 std::string app_launcher_promo_group_name
=
40 base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName
);
41 return !IsAppLauncherEnabled() &&
42 local_state
->GetBoolean(apps::prefs::kShowAppLauncherPromo
) &&
43 (app_launcher_promo_group_name
== apps::kShowLauncherPromoOnceGroupName
||
44 app_launcher_promo_group_name
==
45 apps::kResetShowLauncherPromoPrefGroupName
);