Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / app_list / app_list_util.cc
blob67e56e7a65c79757938e0f0a703ecd70cd25a317
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 "chrome/browser/ui/app_list/app_list_util.h"
7 #include "base/metrics/field_trial.h"
8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/ui/host_desktop.h"
12 #include "chrome/common/pref_names.h"
14 namespace {
16 #if defined(ENABLE_APP_LIST)
17 // The field trial group name that enables showing the promo.
18 const char kShowLauncherPromoOnceGroupName[] = "ShowPromoUntilDismissed";
20 // The field trial group name that resets the pref to show the app launcher
21 // promo on every session startup.
22 const char kResetShowLauncherPromoPrefGroupName[] = "ResetShowPromoPref";
24 // The name of the field trial that controls showing the app launcher promo.
25 const char kLauncherPromoTrialName[] = "ShowAppLauncherPromo";
26 #endif // defined(ENABLE_APP_LIST)
28 } // namespace
30 void SetupShowAppLauncherPromoFieldTrial(PrefService* local_state) {
31 #if defined(ENABLE_APP_LIST)
32 if (base::FieldTrialList::FindFullName(kLauncherPromoTrialName) ==
33 kResetShowLauncherPromoPrefGroupName) {
34 local_state->SetBoolean(prefs::kShowAppLauncherPromo, true);
36 #endif
39 bool IsAppLauncherEnabled() {
40 #if !defined(ENABLE_APP_LIST)
41 return false;
43 #elif defined(OS_CHROMEOS)
44 return true;
46 #else // defined(ENABLE_APP_LIST) && !defined(OS_CHROMEOS)
47 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
48 return true;
50 PrefService* prefs = g_browser_process->local_state();
51 // In some tests, the prefs aren't initialised.
52 return prefs && prefs->GetBoolean(prefs::kAppLauncherHasBeenEnabled);
53 #endif
56 bool ShouldShowAppLauncherPromo() {
57 #if !defined(ENABLE_APP_LIST)
58 return false;
59 #else
60 PrefService* local_state = g_browser_process->local_state();
61 // In some tests, the prefs aren't initialised.
62 if (!local_state)
63 return false;
64 std::string app_launcher_promo_group_name =
65 base::FieldTrialList::FindFullName(kLauncherPromoTrialName);
66 return !IsAppLauncherEnabled() &&
67 local_state->GetBoolean(prefs::kShowAppLauncherPromo) &&
68 (app_launcher_promo_group_name == kShowLauncherPromoOnceGroupName ||
69 app_launcher_promo_group_name == kResetShowLauncherPromoPrefGroupName);
70 #endif
71 } // namespace apps