| 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) | |
| 268 IPC_MESSAGE_UNHANDLED(handled = false) | 266 IPC_MESSAGE_UNHANDLED(handled = false) |
| 269 IPC_END_MESSAGE_MAP() | 267 IPC_END_MESSAGE_MAP() |
| 270 return handled; | 268 return handled; |
| 271 } | 269 } |
| 272 | 270 |
| 273 bool TabHelper::OnMessageReceived(const IPC::Message& message, | 271 bool TabHelper::OnMessageReceived(const IPC::Message& message, |
| 274 content::RenderFrameHost* render_frame_host) { | 272 content::RenderFrameHost* render_frame_host) { |
| 275 bool handled = true; | 273 bool handled = true; |
| 276 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) | 274 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) |
| 277 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DetailedConsoleMessageAdded, | 275 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DetailedConsoleMessageAdded, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 423 |
| 426 void TabHelper::OnContentScriptsExecuting( | 424 void TabHelper::OnContentScriptsExecuting( |
| 427 const ScriptExecutionObserver::ExecutingScriptsMap& executing_scripts_map, | 425 const ScriptExecutionObserver::ExecutingScriptsMap& executing_scripts_map, |
| 428 const GURL& on_url) { | 426 const GURL& on_url) { |
| 429 FOR_EACH_OBSERVER( | 427 FOR_EACH_OBSERVER( |
| 430 ScriptExecutionObserver, | 428 ScriptExecutionObserver, |
| 431 script_execution_observers_, | 429 script_execution_observers_, |
| 432 OnScriptsExecuted(web_contents(), executing_scripts_map, on_url)); | 430 OnScriptsExecuted(web_contents(), executing_scripts_map, on_url)); |
| 433 } | 431 } |
| 434 | 432 |
| 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 | |
| 444 void TabHelper::OnDetailedConsoleMessageAdded( | 433 void TabHelper::OnDetailedConsoleMessageAdded( |
| 445 const base::string16& message, | 434 const base::string16& message, |
| 446 const base::string16& source, | 435 const base::string16& source, |
| 447 const StackTrace& stack_trace, | 436 const StackTrace& stack_trace, |
| 448 int32 severity_level) { | 437 int32 severity_level) { |
| 449 if (IsSourceFromAnExtension(source)) { | 438 if (IsSourceFromAnExtension(source)) { |
| 450 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); | 439 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| 451 ErrorConsole::Get(profile_)->ReportError( | 440 ErrorConsole::Get(profile_)->ReportError( |
| 452 scoped_ptr<ExtensionError>(new RuntimeError( | 441 scoped_ptr<ExtensionError>(new RuntimeError( |
| 453 extension_app_ ? extension_app_->id() : std::string(), | 442 extension_app_ ? extension_app_->id() : std::string(), |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 } | 583 } |
| 595 } | 584 } |
| 596 | 585 |
| 597 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 586 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
| 598 render_view_host->Send( | 587 render_view_host->Send( |
| 599 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 588 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
| 600 SessionTabHelper::IdForTab(web_contents()))); | 589 SessionTabHelper::IdForTab(web_contents()))); |
| 601 } | 590 } |
| 602 | 591 |
| 603 } // namespace extensions | 592 } // namespace extensions |
| OLD | NEW |