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

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

Issue 14912009: Support getEntryId for entries passed to apps as launch data. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 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/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/common/extensions/extension.h" 25 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/extensions/extension_messages.h" 26 #include "chrome/common/extensions/extension_messages.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/child_process_security_policy.h"
29 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
31 #include "net/base/mime_util.h" 30 #include "net/base/mime_util.h"
32 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
33 #include "webkit/fileapi/file_system_types.h" 32 #include "webkit/fileapi/file_system_types.h"
34 #include "webkit/fileapi/isolated_context.h"
35 33
36 #if defined(OS_CHROMEOS) 34 #if defined(OS_CHROMEOS)
37 #include "chrome/browser/chromeos/drive/drive_system_service.h" 35 #include "chrome/browser/chromeos/drive/drive_system_service.h"
38 #include "chrome/browser/chromeos/drive/file_errors.h" 36 #include "chrome/browser/chromeos/drive/file_errors.h"
39 #include "chrome/browser/chromeos/drive/file_system_interface.h" 37 #include "chrome/browser/chromeos/drive/file_system_interface.h"
40 #include "chrome/browser/chromeos/drive/file_system_util.h" 38 #include "chrome/browser/chromeos/drive/file_system_util.h"
41 #endif 39 #endif
42 40
43 #if defined(OS_WIN) 41 #if defined(OS_WIN)
44 #include "win8/util/win8_util.h" 42 #include "win8/util/win8_util.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 248 }
251 249
252 void GrantAccessToFileAndLaunch(const std::string& mime_type, 250 void GrantAccessToFileAndLaunch(const std::string& mime_type,
253 ExtensionHost* host) { 251 ExtensionHost* host) {
254 // If there was an error loading the app page, |host| will be NULL. 252 // If there was an error loading the app page, |host| will be NULL.
255 if (!host) { 253 if (!host) {
256 LOG(ERROR) << "Could not load app page for " << extension_->id(); 254 LOG(ERROR) << "Could not load app page for " << extension_->id();
257 return; 255 return;
258 } 256 }
259 257
260 content::ChildProcessSecurityPolicy* policy = 258 GrantedFileEntry file_entry = CreateFileEntry(
261 content::ChildProcessSecurityPolicy::GetInstance(); 259 profile_,
262 int renderer_id = host->render_process_host()->GetID(); 260 extension_->id(),
263 261 host->render_process_host()->GetID(),
264 // Granting read file permission to allow reading file content. 262 file_path_,
265 // If the renderer already has permission to read these paths, it is not 263 false);
266 // regranted, as this would overwrite any other permissions which the
267 // renderer may already have.
268 if (!policy->CanReadFile(renderer_id, file_path_))
269 policy->GrantReadFile(renderer_id, file_path_);
270
271 std::string registered_name;
272 fileapi::IsolatedContext* isolated_context =
273 fileapi::IsolatedContext::GetInstance();
274 DCHECK(isolated_context);
275 std::string filesystem_id = isolated_context->RegisterFileSystemForPath(
276 fileapi::kFileSystemTypeNativeForPlatformApp, file_path_,
277 &registered_name);
278 // Granting read file system permission as well to allow file-system
279 // read operations.
280 policy->GrantReadFileSystem(renderer_id, filesystem_id);
281
282 AppEventRouter::DispatchOnLaunchedEventWithFileEntry( 264 AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
283 profile_, extension_, handler_id_, mime_type, filesystem_id, 265 profile_, extension_, handler_id_, mime_type, file_entry);
284 registered_name);
285 } 266 }
286 267
287 // The profile the app should be run in. 268 // The profile the app should be run in.
288 Profile* profile_; 269 Profile* profile_;
289 // The extension providing the app. 270 // The extension providing the app.
290 const Extension* extension_; 271 const Extension* extension_;
291 // The path to be passed through to the app. 272 // The path to be passed through to the app.
292 const base::FilePath file_path_; 273 const base::FilePath file_path_;
293 // The ID of the file handler used to launch the app. 274 // The ID of the file handler used to launch the app.
294 std::string handler_id_; 275 std::string handler_id_;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 void RestartPlatformAppWithFileEntries( 401 void RestartPlatformAppWithFileEntries(
421 Profile* profile, 402 Profile* profile,
422 const Extension* extension, 403 const Extension* extension,
423 const std::vector<SavedFileEntry>& file_entries) { 404 const std::vector<SavedFileEntry>& file_entries) {
424 scoped_refptr<SavedFileEntryLauncher> launcher = new SavedFileEntryLauncher( 405 scoped_refptr<SavedFileEntryLauncher> launcher = new SavedFileEntryLauncher(
425 profile, extension, file_entries); 406 profile, extension, file_entries);
426 launcher->Launch(); 407 launcher->Launch();
427 } 408 }
428 409
429 } // namespace extensions 410 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698