summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/DEPS3
-rw-r--r--apps/app_shim/DEPS1
-rw-r--r--apps/apps.gypi2
-rw-r--r--apps/apps_client.h9
-rw-r--r--apps/launcher.cc12
-rw-r--r--apps/pref_names.cc9
-rw-r--r--apps/pref_names.h2
-rw-r--r--apps/prefs.cc7
-rw-r--r--apps/prefs.h3
-rw-r--r--chrome/browser/apps/app_launch_for_metro_restart_win.cc (renamed from apps/app_launch_for_metro_restart_win.cc)13
-rw-r--r--chrome/browser/apps/app_launch_for_metro_restart_win.h (renamed from apps/app_launch_for_metro_restart_win.h)14
-rw-r--r--chrome/browser/apps/chrome_apps_client.cc22
-rw-r--r--chrome/browser/apps/chrome_apps_client.h5
-rw-r--r--chrome/browser/prefs/browser_prefs.cc9
-rw-r--r--chrome/browser/ui/app_list/app_list_service_unittest.cc3
-rw-r--r--chrome/browser/ui/apps/app_metro_infobar_delegate_win.cc4
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator_impl.cc4
-rw-r--r--chrome/chrome_browser_extensions.gypi2
-rw-r--r--chrome/common/pref_names.cc9
-rw-r--r--chrome/common/pref_names.h2
20 files changed, 83 insertions, 52 deletions
diff --git a/apps/DEPS b/apps/DEPS
index ee53482..17a23d1 100644
--- a/apps/DEPS
+++ b/apps/DEPS
@@ -12,15 +12,12 @@ include_rules = [
"+win8",
# Temporary allowed includes.
# TODO(benwells): remove these (http://crbug.com/159366)
- "+chrome/browser/browser_process.h",
"+chrome/browser/chrome_notification_types.h",
"+chrome/browser/chromeos/drive",
"+chrome/browser/chromeos/login/user_manager.h",
"+chrome/browser/lifetime/application_lifetime.h",
"+chrome/browser/profiles",
"+chrome/browser/sessions/session_id.h",
- "+chrome/browser/ui/apps/app_metro_infobar_delegate_win.h",
- "+chrome/browser/ui/host_desktop.h",
"+chrome/common/chrome_switches.h",
# Pieces of the extensions system that need to move to src/extensions.
# See http://crbug.com/162530 for details.
diff --git a/apps/app_shim/DEPS b/apps/app_shim/DEPS
index aefaed4..5bf1f29 100644
--- a/apps/app_shim/DEPS
+++ b/apps/app_shim/DEPS
@@ -2,6 +2,7 @@ include_rules = [
# TODO(benwells): move this whole folder out of apps and review these.
# See http://crbug.com/266705.
"+chrome/browser/apps/app_launcher_util.h",
+ "+chrome/browser/browser_process.h",
"+chrome/browser/ui/extensions/application_launch.h",
"+chrome/browser/ui/web_applications/web_app_ui.h",
"+chrome/browser/ui/webui/ntp/core_app_launcher_handler.h",
diff --git a/apps/apps.gypi b/apps/apps.gypi
index 13664de..4f1be5d 100644
--- a/apps/apps.gypi
+++ b/apps/apps.gypi
@@ -23,8 +23,6 @@
'<(grit_out_dir)',
],
'sources': [
- 'app_launch_for_metro_restart_win.cc',
- 'app_launch_for_metro_restart_win.h',
'app_lifetime_monitor.cc',
'app_lifetime_monitor.h',
'app_lifetime_monitor_factory.cc',
diff --git a/apps/apps_client.h b/apps/apps_client.h
index c3a58ca..f67aad6 100644
--- a/apps/apps_client.h
+++ b/apps/apps_client.h
@@ -11,6 +11,10 @@ namespace content {
class BrowserContext;
}
+namespace extensions {
+class Extension;
+}
+
namespace apps {
// Sets up global state for the apps system. Should be Set() once in each
@@ -20,6 +24,11 @@ class AppsClient {
// Get all loaded browser contexts.
virtual std::vector<content::BrowserContext*> GetLoadedBrowserContexts() = 0;
+ // Do any pre app launch checks. Returns true if the app launch should proceed
+ // or false if the launch should be prevented.
+ virtual bool CheckAppLaunch(content::BrowserContext* context,
+ const extensions::Extension* extension) = 0;
+
// Return the apps client.
static AppsClient* Get();
diff --git a/apps/launcher.cc b/apps/launcher.cc
index 384d271..731ff88 100644
--- a/apps/launcher.cc
+++ b/apps/launcher.cc
@@ -4,6 +4,7 @@
#include "apps/launcher.h"
+#include "apps/apps_client.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
@@ -22,7 +23,6 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/lazy_background_task_queue.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/apps/app_metro_infobar_delegate_win.h"
#include "chrome/common/extensions/api/app_runtime.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
@@ -314,16 +314,8 @@ void LaunchPlatformAppWithCommandLine(Profile* profile,
const Extension* extension,
const CommandLine* command_line,
const base::FilePath& current_directory) {
-#if defined(OS_WIN)
- // On Windows 8's single window Metro mode we can not launch platform apps.
- // Offer to switch Chrome to desktop mode.
- if (win8::IsSingleWindowMetroMode()) {
- AppMetroInfoBarDelegateWin::Create(
- profile, AppMetroInfoBarDelegateWin::LAUNCH_PACKAGED_APP,
- extension->id());
+ if (!AppsClient::Get()->CheckAppLaunch(profile, extension))
return;
- }
-#endif
// An app with "kiosk_only" should not be installed and launched
// outside of ChromeOS kiosk mode in the first place. This is a defensive
diff --git a/apps/pref_names.cc b/apps/pref_names.cc
index e44df75..ea08c76 100644
--- a/apps/pref_names.cc
+++ b/apps/pref_names.cc
@@ -12,15 +12,6 @@ namespace prefs {
extern const char kAppFullscreenAllowed[] =
"apps.fullscreen.allowed";
-// If set, the user requested to launch the app with this extension id while
-// in Metro mode, and then relaunched to Desktop mode to start it.
-const char kAppLaunchForMetroRestart[] = "apps.app_launch_for_metro_restart";
-
-// Set with |kAppLaunchForMetroRestart|, the profile whose loading triggers
-// launch of the specified app when restarting Chrome in desktop mode.
-const char kAppLaunchForMetroRestartProfile[] =
- "apps.app_launch_for_metro_restart_profile";
-
} // namespace prefs
} // namespace apps
diff --git a/apps/pref_names.h b/apps/pref_names.h
index a2a9a3b..764be82 100644
--- a/apps/pref_names.h
+++ b/apps/pref_names.h
@@ -11,8 +11,6 @@ namespace prefs {
// Alphabetical list of preference names specific to Apps component.
// Keep alphabetized and document each one in the source file.
extern const char kAppFullscreenAllowed[];
-extern const char kAppLaunchForMetroRestart[];
-extern const char kAppLaunchForMetroRestartProfile[];
} // namespace prefs
} // namespace apps
diff --git a/apps/prefs.cc b/apps/prefs.cc
index 0e66801..7c98bc8 100644
--- a/apps/prefs.cc
+++ b/apps/prefs.cc
@@ -10,13 +10,6 @@
namespace apps {
-void RegisterPrefs(PrefRegistrySimple* registry) {
-#if defined(OS_WIN)
- registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, "");
- registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, "");
-#endif
-}
-
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
#if !defined(OS_MACOSX)
registry->RegisterBooleanPref(
diff --git a/apps/prefs.h b/apps/prefs.h
index 8fee0ce..fcccfec 100644
--- a/apps/prefs.h
+++ b/apps/prefs.h
@@ -13,9 +13,6 @@ class PrefRegistrySyncable;
namespace apps {
-// Register preferences for the apps system.
-void RegisterPrefs(PrefRegistrySimple* registry);
-
// Register per-profile preferences for the apps system.
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
diff --git a/apps/app_launch_for_metro_restart_win.cc b/chrome/browser/apps/app_launch_for_metro_restart_win.cc
index 2b10274..a55cb33 100644
--- a/apps/app_launch_for_metro_restart_win.cc
+++ b/chrome/browser/apps/app_launch_for_metro_restart_win.cc
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "apps/app_launch_for_metro_restart_win.h"
+#include "chrome/browser/apps/app_launch_for_metro_restart_win.h"
#include "apps/launcher.h"
#include "apps/pref_names.h"
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
+#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
@@ -17,12 +18,13 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/pref_names.h"
#include "win8/util/win8_util.h"
using extensions::Extension;
using extensions::ExtensionSystem;
-namespace apps {
+namespace app_metro_launch {
namespace {
@@ -90,4 +92,9 @@ void SetAppLaunchForMetroRestart(Profile* profile,
prefs->SetString(prefs::kAppLaunchForMetroRestart, extension_id);
}
-} // namespace apps
+void RegisterPrefs(PrefRegistrySimple* registry) {
+ registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, "");
+ registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, "");
+}
+
+} // namespace app_metro_launch
diff --git a/apps/app_launch_for_metro_restart_win.h b/chrome/browser/apps/app_launch_for_metro_restart_win.h
index dfbd13e..a6296ab 100644
--- a/apps/app_launch_for_metro_restart_win.h
+++ b/chrome/browser/apps/app_launch_for_metro_restart_win.h
@@ -2,16 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H
-#define APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H
+#ifndef CHROME_BROWSER_APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H_
+#define CHROME_BROWSER_APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H_
#include <string>
#include "base/basictypes.h"
+class PrefRegistrySimple;
class Profile;
-namespace apps {
+namespace app_metro_launch {
// Handles launching apps on browser startup due to an attempt to launch an app
// in Windows 8 Metro mode.
@@ -21,6 +22,9 @@ void HandleAppLaunchForMetroRestart(Profile* profile);
void SetAppLaunchForMetroRestart(Profile* profile,
const std::string& extension_id);
-} // namespace apps
+// Register preferences to do with launching apps in Metro.
+void RegisterPrefs(PrefRegistrySimple* registry);
-#endif // APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H
+} // namespace app_metro_launch
+
+#endif // CHROME_BROWSER_APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H_
diff --git a/chrome/browser/apps/chrome_apps_client.cc b/chrome/browser/apps/chrome_apps_client.cc
index 4a9f4ca..d95d139 100644
--- a/chrome/browser/apps/chrome_apps_client.cc
+++ b/chrome/browser/apps/chrome_apps_client.cc
@@ -7,6 +7,12 @@
#include "base/memory/singleton.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/apps/app_metro_infobar_delegate_win.h"
+#include "chrome/common/extensions/extension.h"
+
+#if defined(OS_WIN)
+#include "win8/util/win8_util.h"
+#endif
ChromeAppsClient::ChromeAppsClient() {}
@@ -25,3 +31,19 @@ std::vector<content::BrowserContext*>
return std::vector<content::BrowserContext*>(profiles.begin(),
profiles.end());
}
+
+bool ChromeAppsClient::CheckAppLaunch(content::BrowserContext* context,
+ const extensions::Extension* extension) {
+#if defined(OS_WIN)
+ // On Windows 8's single window Metro mode we can not launch platform apps.
+ // Offer to switch Chrome to desktop mode.
+ if (win8::IsSingleWindowMetroMode()) {
+ AppMetroInfoBarDelegateWin::Create(
+ Profile::FromBrowserContext(context),
+ AppMetroInfoBarDelegateWin::LAUNCH_PACKAGED_APP,
+ extension->id());
+ return false;
+ }
+#endif
+ return true;
+}
diff --git a/chrome/browser/apps/chrome_apps_client.h b/chrome/browser/apps/chrome_apps_client.h
index 7788961..06273d1 100644
--- a/chrome/browser/apps/chrome_apps_client.h
+++ b/chrome/browser/apps/chrome_apps_client.h
@@ -27,6 +27,11 @@ class ChromeAppsClient : public apps::AppsClient {
virtual std::vector<content::BrowserContext*> GetLoadedBrowserContexts()
OVERRIDE;
+ // Do any pre app launch checks. Returns true if the app launch should proceed
+ // or false if the launch should be prevented.
+ virtual bool CheckAppLaunch(content::BrowserContext* context,
+ const extensions::Extension* extension) OVERRIDE;
+
DISALLOW_COPY_AND_ASSIGN(ChromeAppsClient);
};
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 0526317..465801b 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -180,6 +180,10 @@
#include "chrome/browser/plugins/plugins_resource_service.h"
#endif
+#if defined(OS_WIN)
+#include "chrome/browser/apps/app_launch_for_metro_restart_win.h"
+#endif
+
namespace {
enum MigratedPreferences {
@@ -215,7 +219,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
// Please keep this list alphabetized.
AppListService::RegisterPrefs(registry);
- apps::RegisterPrefs(registry);
browser_shutdown::RegisterPrefs(registry);
BrowserProcessImpl::RegisterPrefs(registry);
RegisterScreenshotPrefs(registry);
@@ -306,6 +309,10 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
#if defined(OS_MACOSX)
confirm_quit::RegisterLocalState(registry);
#endif
+
+#if defined(OS_WIN)
+ app_metro_launch::RegisterPrefs(registry);
+#endif
}
// Register prefs applicable to all profiles.
diff --git a/chrome/browser/ui/app_list/app_list_service_unittest.cc b/chrome/browser/ui/app_list/app_list_service_unittest.cc
index ce41574..570b1d5 100644
--- a/chrome/browser/ui/app_list/app_list_service_unittest.cc
+++ b/chrome/browser/ui/app_list/app_list_service_unittest.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "apps/pref_names.h"
-#include "apps/prefs.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
@@ -86,7 +84,6 @@ class AppListServiceUnitTest : public testing::Test {
PrefRegistrySimple* pref_registry = new PrefRegistrySimple;
AppListService::RegisterPrefs(pref_registry);
- apps::RegisterPrefs(pref_registry);
profiles::RegisterPrefs(pref_registry);
PrefServiceBuilder builder;
diff --git a/chrome/browser/ui/apps/app_metro_infobar_delegate_win.cc b/chrome/browser/ui/apps/app_metro_infobar_delegate_win.cc
index a73a85f..8ad72ce 100644
--- a/chrome/browser/ui/apps/app_metro_infobar_delegate_win.cc
+++ b/chrome/browser/ui/apps/app_metro_infobar_delegate_win.cc
@@ -4,10 +4,10 @@
#include "chrome/browser/ui/apps/app_metro_infobar_delegate_win.h"
-#include "apps/app_launch_for_metro_restart_win.h"
#include "base/bind_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_service.h"
+#include "chrome/browser/apps/app_launch_for_metro_restart_win.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/metro_utils/metro_chrome_win.h"
@@ -88,7 +88,7 @@ bool AppMetroInfoBarDelegateWin::Accept() {
if (mode_ == SHOW_APP_LIST) {
prefs->SetBoolean(prefs::kRestartWithAppList, true);
} else {
- apps::SetAppLaunchForMetroRestart(
+ app_metro_launch::SetAppLaunchForMetroRestart(
Profile::FromBrowserContext(web_contents()->GetBrowserContext()),
extension_id_);
}
diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
index 53c80835..d8d4c14 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
@@ -103,8 +103,8 @@
#endif
#if defined(OS_WIN)
-#include "apps/app_launch_for_metro_restart_win.h"
#include "base/win/windows_version.h"
+#include "chrome/browser/apps/app_launch_for_metro_restart_win.h"
#endif
using content::ChildProcessSecurityPolicy;
@@ -585,7 +585,7 @@ void StartupBrowserCreatorImpl::ProcessLaunchURLs(
if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
// See if there are apps for this profile that should be launched on startup
// due to a switch from Metro mode.
- apps::HandleAppLaunchForMetroRestart(profile_);
+ app_metro_launch::HandleAppLaunchForMetroRestart(profile_);
}
#endif
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 855864a..9afbd84 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -56,6 +56,8 @@
'sources': [
# All .cc, .h, .m, and .mm files under browser/extensions except for
# tests and mocks.
+ 'browser/apps/app_launch_for_metro_restart_win.cc',
+ 'browser/apps/app_launch_for_metro_restart_win.h',
'browser/apps/app_launcher_util.cc',
'browser/apps/app_launcher_util.h',
'browser/apps/app_url_redirector.cc',
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 489cb93..0131cb7 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -2528,6 +2528,15 @@ const char kAppLauncherShortcutVersion[] = "apps.app_launcher.shortcut_version";
const char kShowAppLauncherPromo[] = "app_launcher.show_promo";
#endif
+// If set, the user requested to launch the app with this extension id while
+// in Metro mode, and then relaunched to Desktop mode to start it.
+const char kAppLaunchForMetroRestart[] = "apps.app_launch_for_metro_restart";
+
+// Set with |kAppLaunchForMetroRestart|, the profile whose loading triggers
+// launch of the specified app when restarting Chrome in desktop mode.
+const char kAppLaunchForMetroRestartProfile[] =
+ "apps.app_launch_for_metro_restart_profile";
+
// A boolean that indicates whether app shortcuts have been created.
// On a transition from false to true, shortcuts are created for all apps.
const char kAppShortcutsHaveBeenCreated[] = "apps.shortcuts_have_been_created";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 45dc49d..b232b53 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -921,6 +921,8 @@ extern const char kAppLauncherShortcutVersion[];
extern const char kShowAppLauncherPromo[];
#endif
+extern const char kAppLaunchForMetroRestart[];
+extern const char kAppLaunchForMetroRestartProfile[];
extern const char kAppShortcutsHaveBeenCreated[];
extern const char kModuleConflictBubbleShown[];