OLD | NEW |
---|---|
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/api/file_system/file_system_api.h" | 16 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
17 #include "chrome/browser/extensions/extension_host.h" | 17 #include "chrome/browser/extensions/extension_host.h" |
18 #include "chrome/browser/extensions/extension_prefs.h" | 18 #include "chrome/browser/extensions/extension_prefs.h" |
19 #include "chrome/browser/extensions/extension_process_manager.h" | 19 #include "chrome/browser/extensions/extension_process_manager.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/extension_system.h" | 21 #include "chrome/browser/extensions/extension_system.h" |
22 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 22 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h" | 24 #include "chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h" |
25 #include "chrome/browser/web_applications/web_app.h" | |
25 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
26 #include "chrome/common/extensions/extension_messages.h" | 27 #include "chrome/common/extensions/extension_messages.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
29 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
30 #include "net/base/mime_util.h" | 31 #include "net/base/mime_util.h" |
31 #include "net/base/net_util.h" | 32 #include "net/base/net_util.h" |
32 #include "webkit/fileapi/file_system_types.h" | 33 #include "webkit/fileapi/file_system_types.h" |
33 | 34 |
34 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 base::FilePath relative_path(command_line->GetArgs()[0]); | 84 base::FilePath relative_path(command_line->GetArgs()[0]); |
84 base::FilePath absolute_path(relative_path); | 85 base::FilePath absolute_path(relative_path); |
85 if (!MakePathAbsolute(current_directory, &absolute_path)) { | 86 if (!MakePathAbsolute(current_directory, &absolute_path)) { |
86 LOG(WARNING) << "Cannot make absolute path from " << relative_path.value(); | 87 LOG(WARNING) << "Cannot make absolute path from " << relative_path.value(); |
87 return false; | 88 return false; |
88 } | 89 } |
89 *path = absolute_path; | 90 *path = absolute_path; |
90 return true; | 91 return true; |
91 } | 92 } |
92 | 93 |
94 void DoNothing(bool) {} | |
95 | |
93 // Helper method to launch the platform app |extension| with no data. This | 96 // Helper method to launch the platform app |extension| with no data. This |
94 // should be called in the fallback case, where it has been impossible to | 97 // should be called in the fallback case, where it has been impossible to |
95 // load or obtain file launch data. | 98 // load or obtain file launch data. |
96 void LaunchPlatformAppWithNoData(Profile* profile, const Extension* extension) { | 99 void LaunchPlatformAppWithNoData(Profile* profile, const Extension* extension) { |
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
98 extensions::AppEventRouter::DispatchOnLaunchedEvent(profile, extension); | 101 extensions::AppEventRouter::DispatchOnLaunchedEvent(profile, extension); |
102 web_app::internals::LaunchShim(profile, extension, base::Bind(&DoNothing)); | |
tapted
2013/05/16 04:51:00
Would a base::Closure() with no arguments have the
jackhou1
2013/05/17 05:45:36
Nup, it needs to take a bool.
| |
99 } | 103 } |
100 | 104 |
101 // Class to handle launching of platform apps to open a specific path. | 105 // Class to handle launching of platform apps to open a specific path. |
102 // An instance of this class is created for each launch. The lifetime of these | 106 // An instance of this class is created for each launch. The lifetime of these |
103 // instances is managed by reference counted pointers. As long as an instance | 107 // instances is managed by reference counted pointers. As long as an instance |
104 // has outstanding tasks on a message queue it will be retained; once all | 108 // has outstanding tasks on a message queue it will be retained; once all |
105 // outstanding tasks are completed it will be deleted. | 109 // outstanding tasks are completed it will be deleted. |
106 class PlatformAppPathLauncher | 110 class PlatformAppPathLauncher |
107 : public base::RefCountedThreadSafe<PlatformAppPathLauncher> { | 111 : public base::RefCountedThreadSafe<PlatformAppPathLauncher> { |
108 public: | 112 public: |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 void RestartPlatformAppWithFileEntries( | 405 void RestartPlatformAppWithFileEntries( |
402 Profile* profile, | 406 Profile* profile, |
403 const Extension* extension, | 407 const Extension* extension, |
404 const std::vector<SavedFileEntry>& file_entries) { | 408 const std::vector<SavedFileEntry>& file_entries) { |
405 scoped_refptr<SavedFileEntryLauncher> launcher = new SavedFileEntryLauncher( | 409 scoped_refptr<SavedFileEntryLauncher> launcher = new SavedFileEntryLauncher( |
406 profile, extension, file_entries); | 410 profile, extension, file_entries); |
407 launcher->Launch(); | 411 launcher->Launch(); |
408 } | 412 } |
409 | 413 |
410 } // namespace extensions | 414 } // namespace extensions |
OLD | NEW |