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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) | 256 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) |
257 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, | 257 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, |
258 OnDidGetWebApplicationInfo) | 258 OnDidGetWebApplicationInfo) |
259 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall, | 259 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall, |
260 OnInlineWebstoreInstall) | 260 OnInlineWebstoreInstall) |
261 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState, | 261 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState, |
262 OnGetAppInstallState); | 262 OnGetAppInstallState); |
263 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 263 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
264 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ContentScriptsExecuting, | 264 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ContentScriptsExecuting, |
265 OnContentScriptsExecuting) | 265 OnContentScriptsExecuting) |
| 266 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OnWatchedPageChange, |
| 267 OnWatchedPageChange) |
266 IPC_MESSAGE_UNHANDLED(handled = false) | 268 IPC_MESSAGE_UNHANDLED(handled = false) |
267 IPC_END_MESSAGE_MAP() | 269 IPC_END_MESSAGE_MAP() |
268 return handled; | 270 return handled; |
269 } | 271 } |
270 | 272 |
271 bool TabHelper::OnMessageReceived(const IPC::Message& message, | 273 bool TabHelper::OnMessageReceived(const IPC::Message& message, |
272 content::RenderFrameHost* render_frame_host) { | 274 content::RenderFrameHost* render_frame_host) { |
273 bool handled = true; | 275 bool handled = true; |
274 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) | 276 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) |
275 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DetailedConsoleMessageAdded, | 277 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DetailedConsoleMessageAdded, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 425 |
424 void TabHelper::OnContentScriptsExecuting( | 426 void TabHelper::OnContentScriptsExecuting( |
425 const ScriptExecutionObserver::ExecutingScriptsMap& executing_scripts_map, | 427 const ScriptExecutionObserver::ExecutingScriptsMap& executing_scripts_map, |
426 const GURL& on_url) { | 428 const GURL& on_url) { |
427 FOR_EACH_OBSERVER( | 429 FOR_EACH_OBSERVER( |
428 ScriptExecutionObserver, | 430 ScriptExecutionObserver, |
429 script_execution_observers_, | 431 script_execution_observers_, |
430 OnScriptsExecuted(web_contents(), executing_scripts_map, on_url)); | 432 OnScriptsExecuted(web_contents(), executing_scripts_map, on_url)); |
431 } | 433 } |
432 | 434 |
| 435 void TabHelper::OnWatchedPageChange( |
| 436 const std::vector<std::string>& css_selectors) { |
| 437 if (ExtensionSystem::Get(profile_)->extension_service() && |
| 438 RulesRegistryService::Get(profile_)) { |
| 439 RulesRegistryService::Get(profile_)->content_rules_registry()->Apply( |
| 440 web_contents(), css_selectors); |
| 441 } |
| 442 } |
| 443 |
433 void TabHelper::OnDetailedConsoleMessageAdded( | 444 void TabHelper::OnDetailedConsoleMessageAdded( |
434 const base::string16& message, | 445 const base::string16& message, |
435 const base::string16& source, | 446 const base::string16& source, |
436 const StackTrace& stack_trace, | 447 const StackTrace& stack_trace, |
437 int32 severity_level) { | 448 int32 severity_level) { |
438 if (IsSourceFromAnExtension(source)) { | 449 if (IsSourceFromAnExtension(source)) { |
439 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); | 450 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
440 ErrorConsole::Get(profile_)->ReportError( | 451 ErrorConsole::Get(profile_)->ReportError( |
441 scoped_ptr<ExtensionError>(new RuntimeError( | 452 scoped_ptr<ExtensionError>(new RuntimeError( |
442 extension_app_ ? extension_app_->id() : std::string(), | 453 extension_app_ ? extension_app_->id() : std::string(), |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } | 594 } |
584 } | 595 } |
585 | 596 |
586 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 597 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
587 render_view_host->Send( | 598 render_view_host->Send( |
588 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 599 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
589 SessionTabHelper::IdForTab(web_contents()))); | 600 SessionTabHelper::IdForTab(web_contents()))); |
590 } | 601 } |
591 | 602 |
592 } // namespace extensions | 603 } // namespace extensions |
OLD | NEW |