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