OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 #include "chrome/common/chrome_notification_types.h" | 77 #include "chrome/common/chrome_notification_types.h" |
78 #include "chrome/common/chrome_switches.h" | 78 #include "chrome/common/chrome_switches.h" |
79 #include "chrome/common/extensions/extension.h" | 79 #include "chrome/common/extensions/extension.h" |
80 #include "chrome/common/extensions/extension_constants.h" | 80 #include "chrome/common/extensions/extension_constants.h" |
81 #include "chrome/common/extensions/extension_error_utils.h" | 81 #include "chrome/common/extensions/extension_error_utils.h" |
82 #include "chrome/common/extensions/extension_file_util.h" | 82 #include "chrome/common/extensions/extension_file_util.h" |
83 #include "chrome/common/extensions/extension_messages.h" | 83 #include "chrome/common/extensions/extension_messages.h" |
84 #include "chrome/common/extensions/extension_resource.h" | 84 #include "chrome/common/extensions/extension_resource.h" |
85 #include "chrome/common/pref_names.h" | 85 #include "chrome/common/pref_names.h" |
86 #include "chrome/common/url_constants.h" | 86 #include "chrome/common/url_constants.h" |
87 #include "content/browser/debugger/devtools_manager.h" | |
88 #include "content/browser/plugin_process_host.h" | 87 #include "content/browser/plugin_process_host.h" |
89 #include "content/browser/plugin_service.h" | 88 #include "content/browser/plugin_service.h" |
90 #include "content/browser/user_metrics.h" | 89 #include "content/browser/user_metrics.h" |
91 #include "content/common/pepper_plugin_registry.h" | 90 #include "content/common/pepper_plugin_registry.h" |
92 #include "content/public/browser/browser_thread.h" | 91 #include "content/public/browser/browser_thread.h" |
| 92 #include "content/public/browser/devtools/devtools_agent_host_registry.h" |
| 93 #include "content/public/browser/devtools/devtools_manager.h" |
93 #include "content/public/browser/notification_service.h" | 94 #include "content/public/browser/notification_service.h" |
94 #include "content/public/browser/notification_types.h" | 95 #include "content/public/browser/notification_types.h" |
95 #include "content/public/browser/render_process_host.h" | 96 #include "content/public/browser/render_process_host.h" |
96 #include "googleurl/src/gurl.h" | 97 #include "googleurl/src/gurl.h" |
97 #include "net/base/registry_controlled_domain.h" | 98 #include "net/base/registry_controlled_domain.h" |
98 #include "webkit/database/database_tracker.h" | 99 #include "webkit/database/database_tracker.h" |
99 #include "webkit/database/database_util.h" | 100 #include "webkit/database/database_util.h" |
100 | 101 |
101 #if defined(OS_CHROMEOS) | 102 #if defined(OS_CHROMEOS) |
102 #include "chrome/browser/chromeos/cros/cros_library.h" | 103 #include "chrome/browser/chromeos/cros/cros_library.h" |
103 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" | 104 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
104 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 105 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
105 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 106 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
106 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 107 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
107 #include "chrome/browser/extensions/extension_input_ime_api.h" | 108 #include "chrome/browser/extensions/extension_input_ime_api.h" |
108 #include "webkit/fileapi/file_system_context.h" | 109 #include "webkit/fileapi/file_system_context.h" |
109 #include "webkit/fileapi/file_system_mount_point_provider.h" | 110 #include "webkit/fileapi/file_system_mount_point_provider.h" |
110 #include "webkit/fileapi/file_system_path_manager.h" | 111 #include "webkit/fileapi/file_system_path_manager.h" |
111 #endif | 112 #endif |
112 | 113 |
113 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) | 114 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) |
114 #include "chrome/browser/extensions/extension_input_ui_api.h" | 115 #include "chrome/browser/extensions/extension_input_ui_api.h" |
115 #endif | 116 #endif |
116 | 117 |
117 using base::Time; | 118 using base::Time; |
118 using content::BrowserThread; | 119 using content::BrowserThread; |
| 120 using content::DevToolsAgentHostRegistry; |
119 | 121 |
120 namespace errors = extension_manifest_errors; | 122 namespace errors = extension_manifest_errors; |
121 | 123 |
122 namespace { | 124 namespace { |
123 | 125 |
124 #if defined(OS_LINUX) | 126 #if defined(OS_LINUX) |
125 static const int kOmniboxIconPaddingLeft = 2; | 127 static const int kOmniboxIconPaddingLeft = 2; |
126 static const int kOmniboxIconPaddingRight = 2; | 128 static const int kOmniboxIconPaddingRight = 2; |
127 #elif defined(OS_MACOSX) | 129 #elif defined(OS_MACOSX) |
128 static const int kOmniboxIconPaddingLeft = 0; | 130 static const int kOmniboxIconPaddingLeft = 0; |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 593 |
592 // Disable the extension if it's loaded. It might not be loaded if it crashed. | 594 // Disable the extension if it's loaded. It might not be loaded if it crashed. |
593 if (current_extension) { | 595 if (current_extension) { |
594 // If the extension has an inspector open for its background page, detach | 596 // If the extension has an inspector open for its background page, detach |
595 // the inspector and hang onto a cookie for it, so that we can reattach | 597 // the inspector and hang onto a cookie for it, so that we can reattach |
596 // later. | 598 // later. |
597 ExtensionProcessManager* manager = profile_->GetExtensionProcessManager(); | 599 ExtensionProcessManager* manager = profile_->GetExtensionProcessManager(); |
598 ExtensionHost* host = manager->GetBackgroundHostForExtension(extension_id); | 600 ExtensionHost* host = manager->GetBackgroundHostForExtension(extension_id); |
599 if (host) { | 601 if (host) { |
600 // Look for an open inspector for the background page. | 602 // Look for an open inspector for the background page. |
601 int devtools_cookie = DevToolsManager::GetInstance()->DetachClientHost( | 603 DevToolsAgentHost* agent = |
602 host->render_view_host()); | 604 DevToolsAgentHostRegistry::FindDevToolsAgentHost( |
603 if (devtools_cookie >= 0) | 605 host->render_view_host()); |
604 orphaned_dev_tools_[extension_id] = devtools_cookie; | 606 if (agent) { |
| 607 int devtools_cookie = |
| 608 content::DevToolsManager::GetInstance()->DetachClientHost(agent); |
| 609 if (devtools_cookie >= 0) |
| 610 orphaned_dev_tools_[extension_id] = devtools_cookie; |
| 611 } |
605 } | 612 } |
606 | 613 |
607 path = current_extension->path(); | 614 path = current_extension->path(); |
608 DisableExtension(extension_id); | 615 DisableExtension(extension_id); |
609 disabled_extension_paths_[extension_id] = path; | 616 disabled_extension_paths_[extension_id] = path; |
610 } else { | 617 } else { |
611 path = unloaded_extension_paths_[extension_id]; | 618 path = unloaded_extension_paths_[extension_id]; |
612 } | 619 } |
613 | 620 |
614 // Check the installed extensions to see if what we're reloading was already | 621 // Check the installed extensions to see if what we're reloading was already |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 ExtensionErrorReporter::GetInstance()->ReportError(message, be_noisy); | 2287 ExtensionErrorReporter::GetInstance()->ReportError(message, be_noisy); |
2281 } | 2288 } |
2282 | 2289 |
2283 void ExtensionService::DidCreateRenderViewForBackgroundPage( | 2290 void ExtensionService::DidCreateRenderViewForBackgroundPage( |
2284 ExtensionHost* host) { | 2291 ExtensionHost* host) { |
2285 OrphanedDevTools::iterator iter = | 2292 OrphanedDevTools::iterator iter = |
2286 orphaned_dev_tools_.find(host->extension_id()); | 2293 orphaned_dev_tools_.find(host->extension_id()); |
2287 if (iter == orphaned_dev_tools_.end()) | 2294 if (iter == orphaned_dev_tools_.end()) |
2288 return; | 2295 return; |
2289 | 2296 |
2290 DevToolsManager::GetInstance()->AttachClientHost( | 2297 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
2291 iter->second, host->render_view_host()); | 2298 host->render_view_host()); |
| 2299 content::DevToolsManager::GetInstance()->AttachClientHost(iter->second, |
| 2300 agent); |
2292 orphaned_dev_tools_.erase(iter); | 2301 orphaned_dev_tools_.erase(iter); |
2293 } | 2302 } |
2294 | 2303 |
2295 void ExtensionService::Observe(int type, | 2304 void ExtensionService::Observe(int type, |
2296 const content::NotificationSource& source, | 2305 const content::NotificationSource& source, |
2297 const content::NotificationDetails& details) { | 2306 const content::NotificationDetails& details) { |
2298 switch (type) { | 2307 switch (type) { |
2299 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { | 2308 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { |
2300 if (profile_ != | 2309 if (profile_ != |
2301 content::Source<Profile>(source).ptr()->GetOriginalProfile()) { | 2310 content::Source<Profile>(source).ptr()->GetOriginalProfile()) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 | 2513 |
2505 ExtensionService::NaClModuleInfoList::iterator | 2514 ExtensionService::NaClModuleInfoList::iterator |
2506 ExtensionService::FindNaClModule(const GURL& url) { | 2515 ExtensionService::FindNaClModule(const GURL& url) { |
2507 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2516 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
2508 iter != nacl_module_list_.end(); ++iter) { | 2517 iter != nacl_module_list_.end(); ++iter) { |
2509 if (iter->url == url) | 2518 if (iter->url == url) |
2510 return iter; | 2519 return iter; |
2511 } | 2520 } |
2512 return nacl_module_list_.end(); | 2521 return nacl_module_list_.end(); |
2513 } | 2522 } |
OLD | NEW |