OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/runtime/runtime_api.h" | 5 #include "extensions/browser/api/runtime/runtime_api.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "base/version.h" | 14 #include "base/version.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/extensions/extension_service.h" | |
17 #include "chrome/browser/extensions/shared_module_service.h" | |
elijahtaylor1
2014/06/05 22:36:45
these includes are triggering presubmit errors, ev
asargent_no_longer_on_chrome
2014/06/06 21:07:01
The goal is that nothing in src/extensions/ can de
elijahtaylor1
2014/06/06 21:20:42
I think I would prefer to do that short term (with
| |
16 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
17 #include "content/public/browser/child_process_security_policy.h" | 19 #include "content/public/browser/child_process_security_policy.h" |
18 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
20 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
21 #include "extensions/browser/api/runtime/runtime_api_delegate.h" | 23 #include "extensions/browser/api/runtime/runtime_api_delegate.h" |
22 #include "extensions/browser/event_router.h" | 24 #include "extensions/browser/event_router.h" |
23 #include "extensions/browser/extension_host.h" | 25 #include "extensions/browser/extension_host.h" |
24 #include "extensions/browser/extension_prefs.h" | 26 #include "extensions/browser/extension_prefs.h" |
25 #include "extensions/browser/extension_registry.h" | 27 #include "extensions/browser/extension_registry.h" |
26 #include "extensions/browser/extension_system.h" | 28 #include "extensions/browser/extension_system.h" |
27 #include "extensions/browser/extension_util.h" | 29 #include "extensions/browser/extension_util.h" |
28 #include "extensions/browser/extensions_browser_client.h" | 30 #include "extensions/browser/extensions_browser_client.h" |
29 #include "extensions/browser/lazy_background_task_queue.h" | 31 #include "extensions/browser/lazy_background_task_queue.h" |
30 #include "extensions/browser/process_manager.h" | 32 #include "extensions/browser/process_manager.h" |
31 #include "extensions/common/api/runtime.h" | 33 #include "extensions/common/api/runtime.h" |
32 #include "extensions/common/error_utils.h" | 34 #include "extensions/common/error_utils.h" |
33 #include "extensions/common/extension.h" | 35 #include "extensions/common/extension.h" |
34 #include "extensions/common/manifest_handlers/background_info.h" | 36 #include "extensions/common/manifest_handlers/background_info.h" |
37 #include "extensions/common/manifest_handlers/shared_module_info.h" | |
35 #include "url/gurl.h" | 38 #include "url/gurl.h" |
36 #include "webkit/browser/fileapi/isolated_context.h" | 39 #include "webkit/browser/fileapi/isolated_context.h" |
37 | 40 |
38 using content::BrowserContext; | 41 using content::BrowserContext; |
39 | 42 |
40 namespace extensions { | 43 namespace extensions { |
41 | 44 |
42 namespace runtime = core_api::runtime; | 45 namespace runtime = core_api::runtime; |
43 | 46 |
44 namespace { | 47 namespace { |
45 | 48 |
46 const char kNoBackgroundPageError[] = "You do not have a background page."; | 49 const char kNoBackgroundPageError[] = "You do not have a background page."; |
47 const char kPageLoadError[] = "Background page failed to load."; | 50 const char kPageLoadError[] = "Background page failed to load."; |
51 const char kInstallId[] = "id"; | |
48 const char kInstallReason[] = "reason"; | 52 const char kInstallReason[] = "reason"; |
49 const char kInstallReasonChromeUpdate[] = "chrome_update"; | 53 const char kInstallReasonChromeUpdate[] = "chrome_update"; |
50 const char kInstallReasonUpdate[] = "update"; | 54 const char kInstallReasonUpdate[] = "update"; |
51 const char kInstallReasonInstall[] = "install"; | 55 const char kInstallReasonInstall[] = "install"; |
56 const char kInstallReasonSharedModuleUpdate[] = "shared_module_update"; | |
52 const char kInstallPreviousVersion[] = "previousVersion"; | 57 const char kInstallPreviousVersion[] = "previousVersion"; |
53 const char kInvalidUrlError[] = "Invalid URL."; | 58 const char kInvalidUrlError[] = "Invalid URL."; |
54 const char kPlatformInfoUnavailable[] = "Platform information unavailable."; | 59 const char kPlatformInfoUnavailable[] = "Platform information unavailable."; |
55 | 60 |
56 const char kUpdatesDisabledError[] = "Autoupdate is not enabled."; | 61 const char kUpdatesDisabledError[] = "Autoupdate is not enabled."; |
57 | 62 |
58 // A preference key storing the url loaded when an extension is uninstalled. | 63 // A preference key storing the url loaded when an extension is uninstalled. |
59 const char kUninstallUrl[] = "uninstall_url"; | 64 const char kUninstallUrl[] = "uninstall_url"; |
60 | 65 |
61 // The name of the directory to be returned by getPackageDirectoryEntry. This | 66 // The name of the directory to be returned by getPackageDirectoryEntry. This |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 } else if (chrome_updated) { | 332 } else if (chrome_updated) { |
328 info->SetString(kInstallReason, kInstallReasonChromeUpdate); | 333 info->SetString(kInstallReason, kInstallReasonChromeUpdate); |
329 } else { | 334 } else { |
330 info->SetString(kInstallReason, kInstallReasonInstall); | 335 info->SetString(kInstallReason, kInstallReasonInstall); |
331 } | 336 } |
332 DCHECK(system->event_router()); | 337 DCHECK(system->event_router()); |
333 scoped_ptr<Event> event( | 338 scoped_ptr<Event> event( |
334 new Event(runtime::OnInstalled::kEventName, event_args.Pass())); | 339 new Event(runtime::OnInstalled::kEventName, event_args.Pass())); |
335 system->event_router()->DispatchEventWithLazyListener(extension_id, | 340 system->event_router()->DispatchEventWithLazyListener(extension_id, |
336 event.Pass()); | 341 event.Pass()); |
342 | |
343 if (old_version.IsValid()) { | |
344 const Extension* extension = | |
345 ExtensionRegistry::Get(context)->enabled_extensions().GetByID( | |
346 extension_id); | |
347 if (SharedModuleInfo::IsSharedModule(extension)) { | |
348 ExtensionService* service = system->extension_service(); | |
349 DCHECK(service); | |
350 SharedModuleService* sm_service = service->shared_module_service(); | |
351 DCHECK(sm_service); | |
352 scoped_ptr<const ExtensionSet> dependents = | |
353 sm_service->GetDependentExtensions(extension); | |
354 for (ExtensionSet::const_iterator i = dependents->begin(); | |
355 i != dependents->end(); | |
356 i++) { | |
357 scoped_ptr<base::ListValue> sm_event_args(new base::ListValue()); | |
358 base::DictionaryValue* sm_info = new base::DictionaryValue(); | |
359 sm_event_args->Append(sm_info); | |
360 sm_info->SetString(kInstallReason, kInstallReasonSharedModuleUpdate); | |
361 sm_info->SetString(kInstallPreviousVersion, old_version.GetString()); | |
362 sm_info->SetString(kInstallId, extension_id); | |
363 scoped_ptr<Event> sm_event( | |
364 new Event(runtime::OnInstalled::kEventName, sm_event_args.Pass())); | |
365 system->event_router()->DispatchEventWithLazyListener((*i)->id(), | |
366 sm_event.Pass()); | |
367 } | |
368 } | |
369 } | |
337 } | 370 } |
338 | 371 |
339 // static | 372 // static |
340 void RuntimeEventRouter::DispatchOnUpdateAvailableEvent( | 373 void RuntimeEventRouter::DispatchOnUpdateAvailableEvent( |
341 content::BrowserContext* context, | 374 content::BrowserContext* context, |
342 const std::string& extension_id, | 375 const std::string& extension_id, |
343 const base::DictionaryValue* manifest) { | 376 const base::DictionaryValue* manifest) { |
344 ExtensionSystem* system = ExtensionSystem::Get(context); | 377 ExtensionSystem* system = ExtensionSystem::Get(context); |
345 if (!system) | 378 if (!system) |
346 return; | 379 return; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 content::ChildProcessSecurityPolicy* policy = | 540 content::ChildProcessSecurityPolicy* policy = |
508 content::ChildProcessSecurityPolicy::GetInstance(); | 541 content::ChildProcessSecurityPolicy::GetInstance(); |
509 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 542 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
510 base::DictionaryValue* dict = new base::DictionaryValue(); | 543 base::DictionaryValue* dict = new base::DictionaryValue(); |
511 dict->SetString("fileSystemId", filesystem_id); | 544 dict->SetString("fileSystemId", filesystem_id); |
512 dict->SetString("baseName", relative_path); | 545 dict->SetString("baseName", relative_path); |
513 return RespondNow(OneArgument(dict)); | 546 return RespondNow(OneArgument(dict)); |
514 } | 547 } |
515 | 548 |
516 } // namespace extensions | 549 } // namespace extensions |
OLD | NEW |