| Index: content/browser/devtools/render_view_devtools_agent_host.cc
|
| diff --git a/content/browser/devtools/render_view_devtools_agent_host.cc b/content/browser/devtools/render_view_devtools_agent_host.cc
|
| index 26b14bf59886f502c74ddf9c310cb7fc4b9cbcb5..da36c64bfd53dfede6c57c2e36fd7514adb76fae 100644
|
| --- a/content/browser/devtools/render_view_devtools_agent_host.cc
|
| +++ b/content/browser/devtools/render_view_devtools_agent_host.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/base64.h"
|
| #include "base/basictypes.h"
|
| #include "base/lazy_instance.h"
|
| +#include "base/utf_string_conversions.h"
|
| #include "content/browser/child_process_security_policy_impl.h"
|
| #include "content/browser/devtools/devtools_manager_impl.h"
|
| #include "content/browser/devtools/devtools_protocol.h"
|
| @@ -17,9 +18,12 @@
|
| #include "content/browser/web_contents/web_contents_impl.h"
|
| #include "content/common/devtools_messages.h"
|
| #include "content/public/browser/content_browser_client.h"
|
| +#include "content/public/browser/favicon_status.h"
|
| +#include "content/public/browser/navigation_entry.h"
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_widget_host_view.h"
|
| +#include "net/base/escape.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h"
|
| #include "ui/gfx/image/image_skia.h"
|
| #include "ui/gfx/native_widget_types.h"
|
| @@ -104,16 +108,19 @@ bool DevToolsAgentHost::IsDebuggerAttached(WebContents* web_contents) {
|
| }
|
|
|
| // static
|
| -int DevToolsAgentHost::DisconnectRenderViewHost(RenderViewHost* rvh) {
|
| +const std::string DevToolsAgentHost::EmptyCookie;
|
| +
|
| +// static
|
| +std::string DevToolsAgentHost::DisconnectRenderViewHost(RenderViewHost* rvh) {
|
| RenderViewDevToolsAgentHost* agent_host = FindAgentHost(rvh);
|
| if (!agent_host)
|
| - return -1;
|
| + return EmptyCookie;
|
| agent_host->DisconnectRenderViewHost();
|
| return agent_host->id();
|
| }
|
|
|
| // static
|
| -void DevToolsAgentHost::ConnectRenderViewHost(int cookie,
|
| +void DevToolsAgentHost::ConnectRenderViewHost(const std::string& cookie,
|
| RenderViewHost* rvh) {
|
| for (Instances::iterator it = g_instances.Get().begin();
|
| it != g_instances.Get().end(); ++it) {
|
| @@ -128,8 +135,8 @@ void DevToolsAgentHost::ConnectRenderViewHost(int cookie,
|
| void RenderViewDevToolsAgentHost::OnCancelPendingNavigation(
|
| RenderViewHost* pending,
|
| RenderViewHost* current) {
|
| - int cookie = DevToolsAgentHost::DisconnectRenderViewHost(pending);
|
| - if (cookie != -1)
|
| + std::string cookie = DevToolsAgentHost::DisconnectRenderViewHost(pending);
|
| + if (cookie != EmptyCookie)
|
| DevToolsAgentHost::ConnectRenderViewHost(cookie, current);
|
| }
|
|
|
| @@ -147,6 +154,41 @@ RenderViewHost* RenderViewDevToolsAgentHost::GetRenderViewHost() {
|
| return render_view_host_;
|
| }
|
|
|
| +std::string RenderViewDevToolsAgentHost::title() {
|
| + if (!render_view_host_)
|
| + return "";
|
| +
|
| + WebContents* web_contents =
|
| + render_view_host_->GetDelegate()->GetAsWebContents();
|
| + if (!web_contents)
|
| + return "";
|
| +
|
| + return UTF16ToUTF8(net::EscapeForHTML(web_contents->GetTitle()));
|
| +}
|
| +
|
| +GURL RenderViewDevToolsAgentHost::url() {
|
| + if (!render_view_host_)
|
| + return GURL();
|
| +
|
| + return render_view_host_->GetDelegate()->GetURL();
|
| +}
|
| +
|
| +GURL RenderViewDevToolsAgentHost::thumbnail_url() {
|
| + NavigationEntry* entry = GetNavigationEntry();
|
| + if (!entry)
|
| + return GURL();
|
| +
|
| + return GURL("/thumb/" + entry->GetURL().spec());
|
| +}
|
| +
|
| +GURL RenderViewDevToolsAgentHost::favicon_url() {
|
| + NavigationEntry* entry = GetNavigationEntry();
|
| + if (!entry)
|
| + return GURL();
|
| +
|
| + return entry->GetFavicon().url;
|
| +}
|
| +
|
| void RenderViewDevToolsAgentHost::DispatchOnInspectorBackend(
|
| const std::string& message) {
|
| std::string error_message;
|
| @@ -346,4 +388,21 @@ bool RenderViewDevToolsAgentHost::CaptureScreenshot(std::string* base_64_data) {
|
| base_64_data);
|
| }
|
|
|
| +NavigationEntry* RenderViewDevToolsAgentHost::GetNavigationEntry() {
|
| + if (!render_view_host_)
|
| + return NULL;
|
| +
|
| + WebContents* web_contents =
|
| + render_view_host_->GetDelegate()->GetAsWebContents();
|
| + if (!web_contents)
|
| + return NULL;
|
| +
|
| + NavigationController& controller = web_contents->GetController();
|
| + NavigationEntry* entry = controller.GetActiveEntry();
|
| + if (!entry || !entry->GetURL().is_valid())
|
| + return NULL;
|
| +
|
| + return entry;
|
| +}
|
| +
|
| } // namespace content
|
|
|