Move platform_app_launcher to apps
chrome/browser/extensions/platform_app_launcher.* -> apps/launcher.*
[email protected], [email protected], [email protected]
TBR for simple refactors:
yoz for extensions
willchan for new dependency on net/base
satorux for new dependency on chrome/browser/chromeos/drive
BUG=159366
TEST=Ensure launching apps in Windows 8 while chrome is running in
single window mode still prompts to run chrome in desktop mode.
Review URL: https://chromiumcodereview.appspot.com/22536002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216181 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/apps/DEPS b/apps/DEPS
index dbcf7e7..0100480c 100644
--- a/apps/DEPS
+++ b/apps/DEPS
@@ -5,6 +5,7 @@
"+components/user_prefs/pref_registry_syncable.h",
"+components/web_modal",
"+extensions",
+ "+net/base",
"+skia/ext",
"+third_party/skia/include",
"+ui",
@@ -14,6 +15,7 @@
"+chrome/browser/browser_process.h",
"+chrome/browser/browser_shutdown.h",
"+chrome/browser/chrome_notification_types.h",
+ "+chrome/browser/chromeos/drive",
"+chrome/browser/extensions",
"+chrome/browser/lifetime/application_lifetime.h",
"+chrome/browser/profiles",
diff --git a/apps/app_launch_for_metro_restart_win.cc b/apps/app_launch_for_metro_restart_win.cc
index 9d6cb22e..2b10274 100644
--- a/apps/app_launch_for_metro_restart_win.cc
+++ b/apps/app_launch_for_metro_restart_win.cc
@@ -4,6 +4,7 @@
#include "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"
@@ -14,7 +15,6 @@
#include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "win8/util/win8_util.h"
diff --git a/apps/app_load_service.cc b/apps/app_load_service.cc
index 982822e8..d2423c0 100644
--- a/apps/app_load_service.cc
+++ b/apps/app_load_service.cc
@@ -5,12 +5,12 @@
#include "apps/app_load_service.h"
#include "apps/app_load_service_factory.h"
+#include "apps/launcher.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
@@ -89,13 +89,13 @@
switch (it->second.action_type) {
case LAUNCH:
- extensions::LaunchPlatformApp(profile_, extension);
+ LaunchPlatformApp(profile_, extension);
break;
case RESTART:
- extensions::RestartPlatformApp(profile_, extension);
+ RestartPlatformApp(profile_, extension);
break;
case LAUNCH_WITH_COMMAND_LINE:
- extensions::LaunchPlatformAppWithCommandLine(
+ LaunchPlatformAppWithCommandLine(
profile_, extension, &it->second.command_line,
it->second.current_dir);
break;
diff --git a/apps/app_restore_service.cc b/apps/app_restore_service.cc
index 2ed8c47..e2d5a858 100644
--- a/apps/app_restore_service.cc
+++ b/apps/app_restore_service.cc
@@ -6,6 +6,7 @@
#include "apps/app_lifetime_monitor_factory.h"
#include "apps/app_restore_service_factory.h"
+#include "apps/launcher.h"
#include "apps/saved_files_service.h"
#include "apps/shell_window.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -14,7 +15,6 @@
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
@@ -138,7 +138,7 @@
}
void AppRestoreService::RestoreApp(const Extension* extension) {
- extensions::RestartPlatformApp(profile_, extension);
+ RestartPlatformApp(profile_, extension);
}
void AppRestoreService::StartObservingAppLifetime() {
diff --git a/apps/apps.gypi b/apps/apps.gypi
index 2a1bc99..59f4c75a 100644
--- a/apps/apps.gypi
+++ b/apps/apps.gypi
@@ -54,6 +54,8 @@
'app_window_contents.h',
'field_trial_names.cc',
'field_trial_names.h',
+ 'launcher.cc',
+ 'launcher.h',
'metrics_names.h',
'native_app_window.h',
'pref_names.cc',
@@ -72,6 +74,13 @@
'switches.h',
],
'conditions': [
+ ['chromeos==1',
+ {
+ 'dependencies': [
+ 'browser_chromeos',
+ ]
+ }
+ ],
['enable_extensions==0',
{
'sources/': [
diff --git a/chrome/browser/extensions/platform_app_launcher.cc b/apps/launcher.cc
similarity index 91%
rename from chrome/browser/extensions/platform_app_launcher.cc
rename to apps/launcher.cc
index 9a8dd0c..d892da6 100644
--- a/chrome/browser/extensions/platform_app_launcher.cc
+++ b/apps/launcher.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 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/platform_app_launcher.h"
+#include "apps/launcher.h"
#include "base/command_line.h"
#include "base/file_util.h"
@@ -23,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/extensions/app_metro_infobar_delegate_win.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
#include "content/public/browser/browser_thread.h"
@@ -31,7 +30,6 @@
#include "content/public/browser/web_contents.h"
#include "net/base/mime_util.h"
#include "net/base/net_util.h"
-#include "webkit/common/fileapi/file_system_types.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
@@ -50,8 +48,11 @@
using extensions::app_file_handler_util::FirstFileHandlerForFile;
using extensions::app_file_handler_util::CreateFileEntry;
using extensions::app_file_handler_util::GrantedFileEntry;
+using extensions::Extension;
+using extensions::ExtensionHost;
+using extensions::ExtensionSystem;
-namespace extensions {
+namespace apps {
namespace {
@@ -202,7 +203,7 @@
void LaunchWithMimeType(const std::string& mime_type) {
// Find file handler from the platform app for the file being opened.
- const FileHandlerInfo* handler = NULL;
+ const extensions::FileHandlerInfo* handler = NULL;
if (!handler_id_.empty())
handler = FileHandlerForId(*extension_, handler_id_);
else
@@ -231,7 +232,7 @@
// available, or it might be in the process of being unloaded, in which case
// the lazy background task queue is used to load the extension and then
// call back to us.
- LazyBackgroundTaskQueue* queue =
+ extensions::LazyBackgroundTaskQueue* queue =
ExtensionSystem::Get(profile_)->lazy_background_task_queue();
if (queue->ShouldEnqueueTask(profile_, extension_)) {
queue->AddPendingTask(profile_, extension_->id(), base::Bind(
@@ -262,7 +263,7 @@
host->render_process_host()->GetID(),
file_path_,
false);
- AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
+ extensions::AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
profile_, extension_, handler_id_, mime_type, file_entry);
}
@@ -284,17 +285,6 @@
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());
- return;
- }
-#endif
-
base::FilePath path;
if (!GetAbsolutePathFromCommandLine(command_line, current_directory, &path)) {
LaunchPlatformAppWithNoData(profile, extension);
@@ -339,22 +329,24 @@
extensions::EventRouter* event_router =
ExtensionSystem::Get(profile)->event_router();
bool listening_to_restart = event_router->
- ExtensionHasEventListener(extension->id(), event_names::kOnRestarted);
+ ExtensionHasEventListener(extension->id(),
+ extensions::event_names::kOnRestarted);
if (listening_to_restart) {
extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension);
return;
}
- ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile)->
+ extensions::ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile)->
extension_service()->extension_prefs();
bool had_windows = extension_prefs->IsActive(extension->id());
extension_prefs->SetIsActive(extension->id(), false);
bool listening_to_launch = event_router->
- ExtensionHasEventListener(extension->id(), event_names::kOnLaunched);
+ ExtensionHasEventListener(extension->id(),
+ extensions::event_names::kOnLaunched);
if (listening_to_launch && had_windows)
LaunchPlatformAppWithNoData(profile, extension);
}
-} // namespace extensions
+} // namespace apps
diff --git a/chrome/browser/extensions/platform_app_launcher.h b/apps/launcher.h
similarity index 66%
rename from chrome/browser/extensions/platform_app_launcher.h
rename to apps/launcher.h
index 460c3e8..9412c11 100644
--- a/chrome/browser/extensions/platform_app_launcher.h
+++ b/apps/launcher.h
@@ -1,12 +1,11 @@
-// Copyright (c) 2012 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.
-#ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_LAUNCHER_H_
-#define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_LAUNCHER_H_
+#ifndef APPS_LAUNCHER_H_
+#define APPS_LAUNCHER_H_
#include <string>
-#include <vector>
class CommandLine;
class Profile;
@@ -15,41 +14,41 @@
class FilePath;
}
-namespace content {
-class WebContents;
+namespace extensions {
+class Extension;
}
-namespace extensions {
-
-class Extension;
+namespace apps {
// Launches the platform app |extension|. Creates appropriate launch data for
// the |command_line| fields present. |extension| and |profile| must not be
// NULL. A NULL |command_line| means there is no launch data. If non-empty,
// |current_directory| is used to expand any relative paths on the command line.
void LaunchPlatformAppWithCommandLine(Profile* profile,
- const Extension* extension,
+ const extensions::Extension* extension,
const CommandLine* command_line,
const base::FilePath& current_directory);
// Launches the platform app |extension| with the contents of |file_path|
// available through the launch data.
void LaunchPlatformAppWithPath(Profile* profile,
- const Extension* extension,
+ const extensions::Extension* extension,
const base::FilePath& file_path);
// Launches the platform app |extension| with no launch data.
-void LaunchPlatformApp(Profile* profile, const Extension* extension);
+void LaunchPlatformApp(Profile* profile,
+ const extensions::Extension* extension);
// Launches the platform app |extension| with the contents of |file_path|
// available through the launch data.
void LaunchPlatformAppWithFileHandler(Profile* profile,
- const Extension* extension,
+ const extensions::Extension* extension,
const std::string& handler_id,
const base::FilePath& file_path);
-void RestartPlatformApp(Profile* profile, const Extension* extension);
+void RestartPlatformApp(Profile* profile,
+ const extensions::Extension* extension);
-} // namespace extensions
+} // namespace apps
-#endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_LAUNCHER_H_
+#endif // APPS_LAUNCHER_H_
diff --git a/chrome/browser/chromeos/extensions/file_manager/file_tasks.cc b/chrome/browser/chromeos/extensions/file_manager/file_tasks.cc
index 64a1214c..609cf4c 100644
--- a/chrome/browser/chromeos/extensions/file_manager/file_tasks.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/file_tasks.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/extensions/file_manager/file_tasks.h"
+#include "apps/launcher.h"
#include "base/bind.h"
#include "base/file_util.h"
#include "base/i18n/case_conversion.h"
@@ -20,7 +21,6 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/lazy_background_task_queue.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -559,7 +559,7 @@
return true;
} else if (task_type == kTaskApp) {
for (size_t i = 0; i != file_urls.size(); ++i) {
- extensions::LaunchPlatformAppWithFileHandler(
+ apps::LaunchPlatformAppWithFileHandler(
profile, extension, action_id, file_urls[i].path());
}
diff --git a/chrome/browser/extensions/DEPS b/chrome/browser/extensions/DEPS
index 0a10421..290e2e5 100644
--- a/chrome/browser/extensions/DEPS
+++ b/chrome/browser/extensions/DEPS
@@ -5,6 +5,7 @@
# to depend on apps will be lifted.
"-apps",
"+apps/app_window_contents.h",
+ "+apps/launcher.h",
"+apps/native_app_window.h",
"+apps/shell_window.h",
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc
index c766c21..6e981608 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc
@@ -4,12 +4,12 @@
#include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h"
+#include "apps/launcher.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h"
#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_mapper.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/invalidation/fake_invalidation_service.h"
#include "chrome/browser/invalidation/invalidation_service.h"
#include "chrome/browser/invalidation/invalidation_service_factory.h"
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 87d18e99..21bfb2e07 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -59,7 +59,6 @@
#include "chrome/browser/extensions/management_policy.h"
#include "chrome/browser/extensions/pending_extension_manager.h"
#include "chrome/browser/extensions/permissions_updater.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/extensions/update_observer.h"
diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc
index a58a259..1f124a8 100644
--- a/chrome/browser/extensions/platform_app_browsertest.cc
+++ b/chrome/browser/extensions/platform_app_browsertest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "apps/launcher.h"
#include "apps/native_app_window.h"
#include "apps/shell_window.h"
#include "base/bind.h"
@@ -27,7 +28,6 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/platform_app_browsertest_util.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/ui/extensions/application_launch.cc b/chrome/browser/ui/extensions/application_launch.cc
index 72b1c957..02112d1 100644
--- a/chrome/browser/ui/extensions/application_launch.cc
+++ b/chrome/browser/ui/extensions/application_launch.cc
@@ -6,13 +6,13 @@
#include <string>
+#include "apps/launcher.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -20,6 +20,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/web_app.h"
@@ -342,7 +343,18 @@
UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100);
if (extension->is_platform_app()) {
- extensions::LaunchPlatformAppWithCommandLine(
+#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());
+ return NULL;
+ }
+#endif
+
+ apps::LaunchPlatformAppWithCommandLine(
profile, extension, params.command_line, params.current_directory);
return NULL;
}
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 89cad58a..e6840ca 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -723,8 +723,6 @@
'browser/extensions/pending_extension_manager.h',
'browser/extensions/permissions_updater.cc',
'browser/extensions/permissions_updater.h',
- 'browser/extensions/platform_app_launcher.cc',
- 'browser/extensions/platform_app_launcher.h',
'browser/extensions/plugin_manager.cc',
'browser/extensions/plugin_manager.h',
'browser/extensions/process_map.cc',
@@ -990,8 +988,6 @@
'browser/extensions/extension_error_ui_default.cc',
'browser/extensions/extension_error_ui_default.h',
'browser/extensions/extension_tab_util.cc',
- 'browser/extensions/platform_app_launcher.cc',
- 'browser/extensions/platform_app_launcher.h',
],
}],
['chrome_multiple_dll!=1', {