OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "apps/app_launcher.h" | 5 #include "apps/app_launcher.h" |
6 | 6 |
7 #include "apps/pref_names.h" | 7 #include "apps/pref_names.h" |
8 #include "base/command_line.h" | |
9 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
11 #include "base/threading/sequenced_worker_pool.h" | |
12 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
14 #include "content/public/browser/browser_thread.h" | |
15 | 12 |
16 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
17 #include "chrome/installer/launcher_support/chrome_launcher_support.h" | 14 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
18 #include "chrome/installer/util/browser_distribution.h" | 15 #include "chrome/installer/util/browser_distribution.h" |
19 #endif | 16 #endif |
20 | 17 |
21 namespace apps { | 18 namespace apps { |
22 | 19 |
23 namespace { | 20 bool IsAppLauncherEnabled() { |
24 | |
25 enum AppLauncherState { | |
26 APP_LAUNCHER_UNKNOWN, | |
27 APP_LAUNCHER_ENABLED, | |
28 APP_LAUNCHER_DISABLED, | |
29 }; | |
30 | |
31 AppLauncherState SynchronousAppLauncherChecks() { | |
32 #if defined(USE_ASH) && !defined(OS_WIN) | 21 #if defined(USE_ASH) && !defined(OS_WIN) |
33 return APP_LAUNCHER_ENABLED; | 22 return true; |
34 #elif !defined(OS_WIN) | 23 #elif !defined(OS_WIN) |
35 return APP_LAUNCHER_DISABLED; | 24 return false; |
36 #else | 25 #else |
37 #if defined(USE_ASH) | 26 #if defined(USE_ASH) |
38 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) | 27 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) |
39 return APP_LAUNCHER_ENABLED; | 28 return true; |
40 #endif | 29 #endif |
41 PrefService* prefs = g_browser_process->local_state(); | 30 PrefService* prefs = g_browser_process->local_state(); |
42 // In some tests, the prefs aren't initialised. | 31 // In some tests, the prefs aren't initialised. |
43 if (!prefs) | 32 if (!prefs) |
44 return APP_LAUNCHER_UNKNOWN; | 33 NOTREACHED(); |
koz (OOO until 15th September)
2013/05/30 04:08:40
The comment here seems to imply this will crash so
calamity
2013/05/31 01:15:22
Done.
| |
45 return prefs->GetBoolean(prefs::kAppLauncherHasBeenEnabled) ? | 34 return prefs->GetBoolean(prefs::kAppLauncherHasBeenEnabled); |
46 APP_LAUNCHER_ENABLED : APP_LAUNCHER_DISABLED; | |
47 #endif | 35 #endif |
48 } | 36 } |
49 | 37 |
50 } // namespace | |
51 | |
52 bool MaybeIsAppLauncherEnabled() { | |
53 return SynchronousAppLauncherChecks() == APP_LAUNCHER_ENABLED; | |
54 } | |
55 | |
56 void GetIsAppLauncherEnabled( | |
57 const OnAppLauncherEnabledCompleted& completion_callback) { | |
58 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
59 | |
60 AppLauncherState state = SynchronousAppLauncherChecks(); | |
61 | |
62 if (state != APP_LAUNCHER_UNKNOWN) { | |
63 completion_callback.Run(state == APP_LAUNCHER_ENABLED); | |
64 return; | |
65 } | |
66 NOTREACHED(); | |
67 } | |
68 | |
69 bool WasAppLauncherEnabled() { | |
70 return SynchronousAppLauncherChecks() == APP_LAUNCHER_ENABLED; | |
71 } | |
72 | |
73 } // namespace apps | 38 } // namespace apps |
OLD | NEW |