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/tab_helper.h" | 5 #include "chrome/browser/extensions/tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/extensions/activity_log/activity_log.h" | 7 #include "chrome/browser/extensions/activity_log/activity_log.h" |
8 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 8 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
9 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist
ry.h" | 9 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist
ry.h" |
10 #include "chrome/browser/extensions/crx_installer.h" | 10 #include "chrome/browser/extensions/crx_installer.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 TabHelper::TabHelper(content::WebContents* web_contents) | 80 TabHelper::TabHelper(content::WebContents* web_contents) |
81 : content::WebContentsObserver(web_contents), | 81 : content::WebContentsObserver(web_contents), |
82 extension_app_(NULL), | 82 extension_app_(NULL), |
83 extension_function_dispatcher_( | 83 extension_function_dispatcher_( |
84 Profile::FromBrowserContext(web_contents->GetBrowserContext()), this), | 84 Profile::FromBrowserContext(web_contents->GetBrowserContext()), this), |
85 pending_web_app_action_(NONE), | 85 pending_web_app_action_(NONE), |
86 script_executor_(new ScriptExecutor(web_contents, | 86 script_executor_(new ScriptExecutor(web_contents, |
87 &script_execution_observers_)), | 87 &script_execution_observers_)), |
| 88 rules_registry_service_( |
| 89 ExtensionSystem::Get( |
| 90 Profile::FromBrowserContext(web_contents->GetBrowserContext()))-> |
| 91 rules_registry_service()), |
88 image_loader_ptr_factory_(this) { | 92 image_loader_ptr_factory_(this) { |
89 // The ActiveTabPermissionManager requires a session ID; ensure this | 93 // The ActiveTabPermissionManager requires a session ID; ensure this |
90 // WebContents has one. | 94 // WebContents has one. |
91 SessionTabHelper::CreateForWebContents(web_contents); | 95 SessionTabHelper::CreateForWebContents(web_contents); |
92 if (web_contents->GetRenderViewHost()) | 96 if (web_contents->GetRenderViewHost()) |
93 SetTabId(web_contents->GetRenderViewHost()); | 97 SetTabId(web_contents->GetRenderViewHost()); |
94 active_tab_permission_granter_.reset(new ActiveTabPermissionGranter( | 98 active_tab_permission_granter_.reset(new ActiveTabPermissionGranter( |
95 web_contents, | 99 web_contents, |
96 SessionID::IdForTab(web_contents), | 100 SessionID::IdForTab(web_contents), |
97 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); | 101 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 187 } |
184 | 188 |
185 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) { | 189 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) { |
186 SetTabId(render_view_host); | 190 SetTabId(render_view_host); |
187 } | 191 } |
188 | 192 |
189 void TabHelper::DidNavigateMainFrame( | 193 void TabHelper::DidNavigateMainFrame( |
190 const content::LoadCommittedDetails& details, | 194 const content::LoadCommittedDetails& details, |
191 const content::FrameNavigateParams& params) { | 195 const content::FrameNavigateParams& params) { |
192 #if defined(ENABLE_EXTENSIONS) | 196 #if defined(ENABLE_EXTENSIONS) |
193 if (ExtensionSystem::Get(profile_)->extension_service()) { | 197 if (rules_registry_service_) { |
194 RulesRegistryService::Get(profile_)->content_rules_registry()-> | 198 rules_registry_service_->content_rules_registry()->DidNavigateMainFrame( |
195 DidNavigateMainFrame(web_contents(), details, params); | 199 web_contents(), details, params); |
196 } | 200 } |
197 #endif // defined(ENABLE_EXTENSIONS) | 201 #endif // defined(ENABLE_EXTENSIONS) |
198 | 202 |
199 if (details.is_in_page) | 203 if (details.is_in_page) |
200 return; | 204 return; |
201 | 205 |
202 Profile* profile = | 206 Profile* profile = |
203 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 207 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
204 ExtensionService* service = profile->GetExtensionService(); | 208 ExtensionService* service = profile->GetExtensionService(); |
205 if (!service) | 209 if (!service) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_, | 338 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_, |
335 OnScriptsExecuted(web_contents(), | 339 OnScriptsExecuted(web_contents(), |
336 executing_scripts_map, | 340 executing_scripts_map, |
337 on_page_id, | 341 on_page_id, |
338 on_url)); | 342 on_url)); |
339 } | 343 } |
340 | 344 |
341 void TabHelper::OnWatchedPageChange( | 345 void TabHelper::OnWatchedPageChange( |
342 const std::vector<std::string>& css_selectors) { | 346 const std::vector<std::string>& css_selectors) { |
343 #if defined(ENABLE_EXTENSIONS) | 347 #if defined(ENABLE_EXTENSIONS) |
344 if (ExtensionSystem::Get(profile_)->extension_service()) { | 348 if (rules_registry_service_) { |
345 RulesRegistryService::Get(profile_)->content_rules_registry()->Apply( | 349 rules_registry_service_->content_rules_registry()->Apply( |
346 web_contents(), css_selectors); | 350 web_contents(), css_selectors); |
347 } | 351 } |
348 #endif // defined(ENABLE_EXTENSIONS) | 352 #endif // defined(ENABLE_EXTENSIONS) |
349 } | 353 } |
350 | 354 |
351 const Extension* TabHelper::GetExtension(const std::string& extension_app_id) { | 355 const Extension* TabHelper::GetExtension(const std::string& extension_app_id) { |
352 if (extension_app_id.empty()) | 356 if (extension_app_id.empty()) |
353 return NULL; | 357 return NULL; |
354 | 358 |
355 Profile* profile = | 359 Profile* profile = |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 460 } |
457 } | 461 } |
458 | 462 |
459 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 463 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
460 render_view_host->Send( | 464 render_view_host->Send( |
461 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 465 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
462 SessionID::IdForTab(web_contents()))); | 466 SessionID::IdForTab(web_contents()))); |
463 } | 467 } |
464 | 468 |
465 } // namespace extensions | 469 } // namespace extensions |
OLD | NEW |