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/api/runtime/runtime_api.h" | 5 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/event_router.h" | 9 #include "chrome/browser/extensions/event_router.h" |
10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
11 #include "chrome/browser/extensions/extension_process_manager.h" | 11 #include "chrome/browser/extensions/extension_process_manager.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_system.h" | 13 #include "chrome/browser/extensions/extension_system.h" |
14 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 14 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
15 #include "chrome/browser/extensions/updater/extension_updater.h" | 15 #include "chrome/browser/extensions/updater/extension_updater.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
19 #include "chrome/browser/ui/browser_navigator.h" | 19 #include "chrome/browser/ui/browser_navigator.h" |
20 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
21 #include "chrome/common/extensions/api/runtime.h" | 21 #include "chrome/common/extensions/api/runtime.h" |
22 #include "chrome/common/extensions/background_info.h" | 22 #include "chrome/common/extensions/background_info.h" |
23 #include "chrome/common/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
24 #include "chrome/common/omaha_query_params/omaha_query_params.h" | 24 #include "chrome/common/omaha_query_params/omaha_query_params.h" |
25 #include "content/public/browser/child_process_security_policy.h" | |
26 #include "content/public/browser/render_process_host.h" | |
27 #include "content/public/browser/render_view_host.h" | |
25 #include "extensions/common/error_utils.h" | 28 #include "extensions/common/error_utils.h" |
26 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
30 #include "webkit/browser/fileapi/isolated_context.h" | |
27 | 31 |
28 namespace GetPlatformInfo = extensions::api::runtime::GetPlatformInfo; | 32 namespace GetPlatformInfo = extensions::api::runtime::GetPlatformInfo; |
29 | 33 |
30 namespace extensions { | 34 namespace extensions { |
31 | 35 |
32 namespace { | 36 namespace { |
33 | 37 |
34 const char kOnStartupEvent[] = "runtime.onStartup"; | 38 const char kOnStartupEvent[] = "runtime.onStartup"; |
35 const char kOnInstalledEvent[] = "runtime.onInstalled"; | 39 const char kOnInstalledEvent[] = "runtime.onInstalled"; |
36 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; | 40 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; |
37 const char kOnBrowserUpdateAvailableEvent[] = | 41 const char kOnBrowserUpdateAvailableEvent[] = |
38 "runtime.onBrowserUpdateAvailable"; | 42 "runtime.onBrowserUpdateAvailable"; |
39 const char kNoBackgroundPageError[] = "You do not have a background page."; | 43 const char kNoBackgroundPageError[] = "You do not have a background page."; |
40 const char kPageLoadError[] = "Background page failed to load."; | 44 const char kPageLoadError[] = "Background page failed to load."; |
41 const char kInstallReason[] = "reason"; | 45 const char kInstallReason[] = "reason"; |
42 const char kInstallReasonChromeUpdate[] = "chrome_update"; | 46 const char kInstallReasonChromeUpdate[] = "chrome_update"; |
43 const char kInstallReasonUpdate[] = "update"; | 47 const char kInstallReasonUpdate[] = "update"; |
44 const char kInstallReasonInstall[] = "install"; | 48 const char kInstallReasonInstall[] = "install"; |
45 const char kInstallPreviousVersion[] = "previousVersion"; | 49 const char kInstallPreviousVersion[] = "previousVersion"; |
46 const char kInvalidUrlError[] = "Invalid URL."; | 50 const char kInvalidUrlError[] = "Invalid URL."; |
47 const char kUpdatesDisabledError[] = "Autoupdate is not enabled."; | 51 const char kUpdatesDisabledError[] = "Autoupdate is not enabled."; |
48 const char kUpdateFound[] = "update_available"; | 52 const char kUpdateFound[] = "update_available"; |
49 const char kUpdateNotFound[] = "no_update"; | 53 const char kUpdateNotFound[] = "no_update"; |
50 const char kUpdateThrottled[] = "throttled"; | 54 const char kUpdateThrottled[] = "throttled"; |
51 | 55 |
52 // A preference key storing the url loaded when an extension is uninstalled. | 56 // A preference key storing the url loaded when an extension is uninstalled. |
53 const char kUninstallUrl[] = "uninstall_url"; | 57 const char kUninstallUrl[] = "uninstall_url"; |
54 | 58 |
59 // The name of the directory to be returned by getPackageDirectoryEntry. | |
60 const char kPackageDirectoryPath[] = "crxfs"; | |
benwells
2013/06/11 03:14:51
If I'm reading this correctly, this could be anyth
Sam McNally
2013/06/11 06:00:29
Done.
| |
61 | |
55 static void DispatchOnStartupEventImpl( | 62 static void DispatchOnStartupEventImpl( |
56 Profile* profile, | 63 Profile* profile, |
57 const std::string& extension_id, | 64 const std::string& extension_id, |
58 bool first_call, | 65 bool first_call, |
59 ExtensionHost* host) { | 66 ExtensionHost* host) { |
60 // A NULL host from the LazyBackgroundTaskQueue means the page failed to | 67 // A NULL host from the LazyBackgroundTaskQueue means the page failed to |
61 // load. Give up. | 68 // load. Give up. |
62 if (!host && !first_call) | 69 if (!host && !first_call) |
63 return; | 70 return; |
64 | 71 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 info.nacl_arch = GetPlatformInfo::Results::PlatformInfo::NACL_ARCH_X86_64; | 380 info.nacl_arch = GetPlatformInfo::Results::PlatformInfo::NACL_ARCH_X86_64; |
374 } else { | 381 } else { |
375 NOTREACHED(); | 382 NOTREACHED(); |
376 return false; | 383 return false; |
377 } | 384 } |
378 | 385 |
379 results_ = GetPlatformInfo::Results::Create(info); | 386 results_ = GetPlatformInfo::Results::Create(info); |
380 return true; | 387 return true; |
381 } | 388 } |
382 | 389 |
390 bool RuntimeGetPackageDirectoryEntryFunction::RunImpl() { | |
391 fileapi::IsolatedContext* isolated_context = | |
392 fileapi::IsolatedContext::GetInstance(); | |
393 DCHECK(isolated_context); | |
394 | |
395 std::string relative_path = kPackageDirectoryPath; | |
396 base::FilePath path = extension_->path(); | |
397 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( | |
398 fileapi::kFileSystemTypeNativeLocal, path, &relative_path); | |
399 | |
400 int renderer_id = render_view_host_->GetProcess()->GetID(); | |
401 content::ChildProcessSecurityPolicy* policy = | |
402 content::ChildProcessSecurityPolicy::GetInstance(); | |
403 policy->GrantReadFileSystem(renderer_id, filesystem_id); | |
404 | |
405 if (!policy->CanReadFile(renderer_id, path)) | |
406 policy->GrantReadFile(renderer_id, path); | |
407 | |
408 DictionaryValue* dict = new DictionaryValue(); | |
409 SetResult(dict); | |
410 dict->SetString("fileSystemId", filesystem_id); | |
411 dict->SetString("baseName", relative_path); | |
412 return true; | |
413 } | |
414 | |
383 } // namespace extensions | 415 } // namespace extensions |
OLD | NEW |