blob: 4e1f379c29a3a326d2e6d4a7d014d0641c82b1c7 [file] [log] [blame]
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001// 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 Murdocheb525c52013-07-10 11:40:50 +01007#include "apps/field_trial_names.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00008#include "apps/pref_names.h"
Ben Murdocheb525c52013-07-10 11:40:50 +01009#include "base/metrics/field_trial.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000010#include "base/prefs/pref_registry_simple.h"
11#include "base/prefs/pref_service.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000012#include "chrome/browser/browser_process.h"
13#include "chrome/browser/ui/host_desktop.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000014
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
20namespace apps {
21
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010022bool IsAppLauncherEnabled() {
Ben Murdochca12bfa2013-07-23 11:17:05 +010023#if !defined(ENABLE_APP_LIST)
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010024 return false;
Ben Murdochca12bfa2013-07-23 11:17:05 +010025
26#elif defined(OS_CHROMEOS)
27 return true;
28
29#else // defined(ENABLE_APP_LIST) && !defined(OS_CHROMEOS)
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000030 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010031 return true;
Ben Murdochca12bfa2013-07-23 11:17:05 +010032
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000033 PrefService* prefs = g_browser_process->local_state();
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010034 // In some tests, the prefs aren't initialised.
Ben Murdochca12bfa2013-07-23 11:17:05 +010035 return prefs && prefs->GetBoolean(prefs::kAppLauncherHasBeenEnabled);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000036#endif
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010037}
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000038
Ben Murdocheb525c52013-07-10 11:40:50 +010039bool 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)2a99a7e2013-03-28 15:31:22 +000053} // namespace apps