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

Side by Side Diff: chrome/browser/extensions/platform_app_launcher.cc

Issue 12450014: Show an InfoBar when trying to start Packaged Apps from Metro mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a 1 second delay, some nits Created 7 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/platform_app_launcher.h" 5 #include "chrome/browser/extensions/platform_app_launcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" 14 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h"
15 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 15 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
16 #include "chrome/browser/extensions/extension_host.h" 16 #include "chrome/browser/extensions/extension_host.h"
17 #include "chrome/browser/extensions/extension_process_manager.h" 17 #include "chrome/browser/extensions/extension_process_manager.h"
18 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/lazy_background_task_queue.h" 19 #include "chrome/browser/extensions/lazy_background_task_queue.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h"
21 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
22 #include "chrome/common/extensions/extension_messages.h" 23 #include "chrome/common/extensions/extension_messages.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/child_process_security_policy.h" 25 #include "content/public/browser/child_process_security_policy.h"
25 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "net/base/mime_util.h" 28 #include "net/base/mime_util.h"
28 #include "net/base/net_util.h" 29 #include "net/base/net_util.h"
29 #include "webkit/fileapi/file_system_types.h" 30 #include "webkit/fileapi/file_system_types.h"
30 #include "webkit/fileapi/isolated_context.h" 31 #include "webkit/fileapi/isolated_context.h"
31 32
33 #if defined(OS_WIN)
34 #include "win8/util/win8_util.h"
35 #endif
36
32 using content::BrowserThread; 37 using content::BrowserThread;
33 using extensions::app_file_handler_util::FileHandlerForId; 38 using extensions::app_file_handler_util::FileHandlerForId;
34 using extensions::app_file_handler_util::FileHandlerCanHandleFileWithMimeType; 39 using extensions::app_file_handler_util::FileHandlerCanHandleFileWithMimeType;
35 using extensions::app_file_handler_util::FirstFileHandlerForMimeType; 40 using extensions::app_file_handler_util::FirstFileHandlerForMimeType;
36 41
37 namespace extensions { 42 namespace extensions {
38 43
39 namespace { 44 namespace {
40 45
41 bool MakePathAbsolute(const base::FilePath& current_directory, 46 bool MakePathAbsolute(const base::FilePath& current_directory,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 243
239 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher); 244 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher);
240 }; 245 };
241 246
242 } // namespace 247 } // namespace
243 248
244 void LaunchPlatformApp(Profile* profile, 249 void LaunchPlatformApp(Profile* profile,
245 const Extension* extension, 250 const Extension* extension,
246 const CommandLine* command_line, 251 const CommandLine* command_line,
247 const base::FilePath& current_directory) { 252 const base::FilePath& current_directory) {
253 #if defined(OS_WIN)
254 // On Windows 8's single window Metro mode we can not launch platform apps.
255 // Offer to switch Chrome to desktop mode.
256 if (win8::IsSingleWindowMetroMode()) {
257 chrome::AppMetroInfoBarDelegateWin::CreateAndActivateMetroForApp(
258 profile, extension->id());
259 return;
260 }
261 #endif
262
248 base::FilePath path; 263 base::FilePath path;
249 if (!GetAbsolutePathFromCommandLine(command_line, current_directory, &path)) { 264 if (!GetAbsolutePathFromCommandLine(command_line, current_directory, &path)) {
250 LaunchPlatformAppWithNoData(profile, extension); 265 LaunchPlatformAppWithNoData(profile, extension);
251 return; 266 return;
252 } 267 }
253 268
254 // TODO(benwells): add a command-line argument to provide a handler ID. 269 // TODO(benwells): add a command-line argument to provide a handler ID.
255 LaunchPlatformAppWithPath(profile, extension, path); 270 LaunchPlatformAppWithPath(profile, extension, path);
256 } 271 }
257 272
(...skipping 11 matching lines...) Expand all
269 void LaunchPlatformAppWithFileHandler(Profile* profile, 284 void LaunchPlatformAppWithFileHandler(Profile* profile,
270 const Extension* extension, 285 const Extension* extension,
271 const std::string& handler_id, 286 const std::string& handler_id,
272 const base::FilePath& file_path) { 287 const base::FilePath& file_path) {
273 scoped_refptr<PlatformAppPathLauncher> launcher = 288 scoped_refptr<PlatformAppPathLauncher> launcher =
274 new PlatformAppPathLauncher(profile, extension, file_path); 289 new PlatformAppPathLauncher(profile, extension, file_path);
275 launcher->LaunchWithHandler(handler_id); 290 launcher->LaunchWithHandler(handler_id);
276 } 291 }
277 292
278 } // namespace extensions 293 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698