| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 OnContentScriptsExecuting) | 311 OnContentScriptsExecuting) |
| 312 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OnWatchedPageChange, | 312 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OnWatchedPageChange, |
| 313 OnWatchedPageChange) | 313 OnWatchedPageChange) |
| 314 IPC_MESSAGE_UNHANDLED(handled = false) | 314 IPC_MESSAGE_UNHANDLED(handled = false) |
| 315 IPC_END_MESSAGE_MAP() | 315 IPC_END_MESSAGE_MAP() |
| 316 return handled; | 316 return handled; |
| 317 } | 317 } |
| 318 | 318 |
| 319 bool TabHelper::OnMessageReceived(const IPC::Message& message, | 319 bool TabHelper::OnMessageReceived(const IPC::Message& message, |
| 320 content::RenderFrameHost* render_frame_host) { | 320 content::RenderFrameHost* render_frame_host) { |
| 321 #if defined(ENABLE_EXTENSIONS) |
| 321 bool handled = true; | 322 bool handled = true; |
| 322 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) | 323 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) |
| 323 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DetailedConsoleMessageAdded, | 324 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DetailedConsoleMessageAdded, |
| 324 OnDetailedConsoleMessageAdded) | 325 OnDetailedConsoleMessageAdded) |
| 325 IPC_MESSAGE_UNHANDLED(handled = false) | 326 IPC_MESSAGE_UNHANDLED(handled = false) |
| 326 IPC_END_MESSAGE_MAP() | 327 IPC_END_MESSAGE_MAP() |
| 328 #else |
| 329 bool handled = false; |
| 330 #endif |
| 327 return handled; | 331 return handled; |
| 328 } | 332 } |
| 329 | 333 |
| 330 void TabHelper::DidCloneToNewWebContents(WebContents* old_web_contents, | 334 void TabHelper::DidCloneToNewWebContents(WebContents* old_web_contents, |
| 331 WebContents* new_web_contents) { | 335 WebContents* new_web_contents) { |
| 332 // When the WebContents that this is attached to is cloned, give the new clone | 336 // When the WebContents that this is attached to is cloned, give the new clone |
| 333 // a TabHelper and copy state over. | 337 // a TabHelper and copy state over. |
| 334 CreateForWebContents(new_web_contents); | 338 CreateForWebContents(new_web_contents); |
| 335 TabHelper* new_helper = FromWebContents(new_web_contents); | 339 TabHelper* new_helper = FromWebContents(new_web_contents); |
| 336 | 340 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 web_contents(), css_selectors); | 469 web_contents(), css_selectors); |
| 466 } | 470 } |
| 467 #endif // defined(ENABLE_EXTENSIONS) | 471 #endif // defined(ENABLE_EXTENSIONS) |
| 468 } | 472 } |
| 469 | 473 |
| 470 void TabHelper::OnDetailedConsoleMessageAdded( | 474 void TabHelper::OnDetailedConsoleMessageAdded( |
| 471 const base::string16& message, | 475 const base::string16& message, |
| 472 const base::string16& source, | 476 const base::string16& source, |
| 473 const StackTrace& stack_trace, | 477 const StackTrace& stack_trace, |
| 474 int32 severity_level) { | 478 int32 severity_level) { |
| 479 #if defined(ENABLE_EXTENSIONS) |
| 475 if (IsSourceFromAnExtension(source)) { | 480 if (IsSourceFromAnExtension(source)) { |
| 476 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); | 481 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| 477 ErrorConsole::Get(profile_)->ReportError( | 482 ErrorConsole::Get(profile_)->ReportError( |
| 478 scoped_ptr<ExtensionError>(new RuntimeError( | 483 scoped_ptr<ExtensionError>(new RuntimeError( |
| 479 extension_app_ ? extension_app_->id() : std::string(), | 484 extension_app_ ? extension_app_->id() : std::string(), |
| 480 profile_->IsOffTheRecord(), | 485 profile_->IsOffTheRecord(), |
| 481 source, | 486 source, |
| 482 message, | 487 message, |
| 483 stack_trace, | 488 stack_trace, |
| 484 web_contents() ? | 489 web_contents() ? |
| 485 web_contents()->GetLastCommittedURL() : GURL::EmptyGURL(), | 490 web_contents()->GetLastCommittedURL() : GURL::EmptyGURL(), |
| 486 static_cast<logging::LogSeverity>(severity_level), | 491 static_cast<logging::LogSeverity>(severity_level), |
| 487 rvh->GetRoutingID(), | 492 rvh->GetRoutingID(), |
| 488 rvh->GetProcess()->GetID()))); | 493 rvh->GetProcess()->GetID()))); |
| 489 } | 494 } |
| 495 #endif |
| 490 } | 496 } |
| 491 | 497 |
| 492 const Extension* TabHelper::GetExtension(const std::string& extension_app_id) { | 498 const Extension* TabHelper::GetExtension(const std::string& extension_app_id) { |
| 493 if (extension_app_id.empty()) | 499 if (extension_app_id.empty()) |
| 494 return NULL; | 500 return NULL; |
| 495 | 501 |
| 496 Profile* profile = | 502 Profile* profile = |
| 497 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 503 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 498 ExtensionService* extension_service = profile->GetExtensionService(); | 504 ExtensionService* extension_service = profile->GetExtensionService(); |
| 499 if (!extension_service || !extension_service->is_ready()) | 505 if (!extension_service || !extension_service->is_ready()) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 594 } |
| 589 } | 595 } |
| 590 | 596 |
| 591 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 597 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
| 592 render_view_host->Send( | 598 render_view_host->Send( |
| 593 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 599 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
| 594 SessionID::IdForTab(web_contents()))); | 600 SessionID::IdForTab(web_contents()))); |
| 595 } | 601 } |
| 596 | 602 |
| 597 } // namespace extensions | 603 } // namespace extensions |
| OLD | NEW |