Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1015)

Unified Diff: apps/app_launcher.cc

Issue 12095052: Move app_launcher.* out of chrome/browser/extensions and into apps/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Beserk Q. More rebase Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/app_launcher.h ('k') | apps/apps.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/app_launcher.cc
diff --git a/chrome/browser/extensions/app_launcher.cc b/apps/app_launcher.cc
similarity index 72%
rename from chrome/browser/extensions/app_launcher.cc
rename to apps/app_launcher.cc
index 5ca6fbf7f277cf8aa0ef6891149616f4a416dff2..73011bc00eac72fd18c771e5d69c7835c7bd06d8 100644
--- a/chrome/browser/extensions/app_launcher.cc
+++ b/apps/app_launcher.cc
@@ -1,16 +1,16 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/extensions/app_launcher.h"
+#include "apps/app_launcher.h"
+#include "apps/pref_names.h"
#include "base/command_line.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#if defined(OS_WIN)
@@ -18,30 +18,10 @@
#include "chrome/installer/util/browser_distribution.h"
#endif
-namespace extensions {
+namespace apps {
namespace {
-#if defined(OS_WIN)
-void UpdatePrefAndCallCallbackOnUI(
- bool result,
- const OnAppLauncherEnabledCompleted& completion_callback) {
- PrefService* prefs = g_browser_process->local_state();
- prefs->SetBoolean(prefs::kAppLauncherIsEnabled, result);
- completion_callback.Run(result);
-}
-
-void IsAppLauncherInstalledOnBlockingPool(
- const OnAppLauncherEnabledCompleted& completion_callback) {
- DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
- bool result = chrome_launcher_support::IsAppLauncherPresent();
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(UpdatePrefAndCallCallbackOnUI, result, completion_callback));
-}
-#endif
-
-} // namespace
-
enum AppLauncherState {
APP_LAUNCHER_UNKNOWN,
APP_LAUNCHER_ENABLED,
@@ -66,7 +46,31 @@ AppLauncherState SynchronousAppLauncherChecks() {
#endif
}
-void UpdateIsAppLauncherEnabled(
+#if defined(OS_WIN)
+void UpdatePrefAndCallCallbackOnUI(
+ bool result,
+ const OnAppLauncherEnabledCompleted& completion_callback) {
+ PrefService* prefs = g_browser_process->local_state();
+ prefs->SetBoolean(prefs::kAppLauncherIsEnabled, result);
+ completion_callback.Run(result);
+}
+
+void IsAppLauncherInstalledOnBlockingPool(
+ const OnAppLauncherEnabledCompleted& completion_callback) {
+ DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ bool result = chrome_launcher_support::IsAppLauncherPresent();
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(UpdatePrefAndCallCallbackOnUI, result, completion_callback));
+}
+#endif
+
+} // namespace
+
+bool MaybeIsAppLauncherEnabled() {
+ return SynchronousAppLauncherChecks() == APP_LAUNCHER_ENABLED;
+}
+
+void GetIsAppLauncherEnabled(
const OnAppLauncherEnabledCompleted& completion_callback) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -92,30 +96,12 @@ void UpdateIsAppLauncherEnabled(
#endif
}
-bool IsAppLauncherEnabled() {
+bool WasAppLauncherEnabled() {
PrefService* prefs = g_browser_process->local_state();
- // In some tests, the prefs aren't initialised, but the NTP still needs to
- // work.
+ // In some tests, the prefs aren't initialised.
if (!prefs)
return SynchronousAppLauncherChecks() == APP_LAUNCHER_ENABLED;
return prefs->GetBoolean(prefs::kAppLauncherIsEnabled);
}
-namespace app_launcher {
-
-void RegisterPrefs(PrefRegistrySimple* registry) {
- // If it is impossible to synchronously determine whether the app launcher is
- // enabled, assume it is disabled. Anything that needs to know the absolute
- // truth should call UpdateIsAppLauncherEnabled().
- //
- // This pref is just a cache of the value from the registry from last time
- // Chrome ran. To avoid having the NTP block on a registry check, it guesses
- // that the value hasn't changed since last time it was checked, using this
- // preference.
- bool is_enabled = SynchronousAppLauncherChecks() == APP_LAUNCHER_ENABLED;
- registry->RegisterBooleanPref(prefs::kAppLauncherIsEnabled, is_enabled);
-}
-
-} // namespace app_launcher
-
-} // namespace extensions
+} // namespace apps
« no previous file with comments | « apps/app_launcher.h ('k') | apps/apps.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698