Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: content/browser/devtools/devtools_agent_host_impl.cc

Issue 12319114: Extract debugger target enumeration into a separate class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@debugger
Patch Set: Cleaner version ready for review Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/devtools/devtools_agent_host_impl.h" 5 #include "content/browser/devtools/devtools_agent_host_impl.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/utf_string_conversions.h"
9 #include "content/browser/renderer_host/render_view_host_delegate.h"
8 #include "content/common/devtools_messages.h" 10 #include "content/common/devtools_messages.h"
11 #include "content/public/browser/devtools_manager.h"
12 #include "content/public/browser/favicon_status.h"
13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h"
16 #include "net/base/escape.h"
9 17
10 namespace content { 18 namespace content {
11 19
12 namespace { 20 namespace {
13 static int g_next_agent_host_id = 0; 21 static int g_next_agent_host_id = 0;
14 } // namespace 22 } // namespace
15 23
16 DevToolsAgentHostImpl::DevToolsAgentHostImpl() 24 DevToolsAgentHostImpl::DevToolsAgentHostImpl()
17 : close_listener_(NULL), 25 : close_listener_(NULL),
18 id_(++g_next_agent_host_id) { 26 id_(++g_next_agent_host_id) {
(...skipping 28 matching lines...) Expand all
47 } 55 }
48 56
49 void DevToolsAgentHostImpl::AddMessageToConsole(ConsoleMessageLevel level, 57 void DevToolsAgentHostImpl::AddMessageToConsole(ConsoleMessageLevel level,
50 const std::string& message) { 58 const std::string& message) {
51 SendMessageToAgent(new DevToolsAgentMsg_AddMessageToConsole( 59 SendMessageToAgent(new DevToolsAgentMsg_AddMessageToConsole(
52 MSG_ROUTING_NONE, 60 MSG_ROUTING_NONE,
53 level, 61 level,
54 message)); 62 message));
55 } 63 }
56 64
65 bool DevToolsAgentHostImpl::attached() {
66 return !!DevToolsManager::GetInstance()->GetDevToolsClientHostFor(this);
67 }
68
69 std::string DevToolsAgentHostImpl::title() {
70 WebContents* web_contents = GetWebContents();
71 if (!web_contents)
72 return "";
73
74 return UTF16ToUTF8(net::EscapeForHTML(web_contents->GetTitle()));
75 }
76
77 GURL DevToolsAgentHostImpl::url() {
78 return GetRenderViewHost()->GetDelegate()->GetURL();
pfeldman 2013/03/01 08:49:30 Like this will return NULL for workers.
Vladislav Kaznacheev 2013/03/01 12:58:35 Done.
79 }
80
81 GURL DevToolsAgentHostImpl::thumbnail_url() {
82 NavigationEntry* entry = GetNavigationEntry();
83 if (!entry)
84 return GURL();
85
86 return GURL("/thumb/" + entry->GetURL().spec());
87 }
88
89 GURL DevToolsAgentHostImpl::favicon_url() {
90 NavigationEntry* entry = GetNavigationEntry();
91 if (!entry)
92 return GURL();
93
94 return entry->GetFavicon().url;
95 }
96
57 RenderViewHost* DevToolsAgentHostImpl::GetRenderViewHost() { 97 RenderViewHost* DevToolsAgentHostImpl::GetRenderViewHost() {
58 return NULL; 98 return NULL;
59 } 99 }
60 100
61 void DevToolsAgentHostImpl::NotifyCloseListener() { 101 void DevToolsAgentHostImpl::NotifyCloseListener() {
62 if (close_listener_) { 102 if (close_listener_) {
63 scoped_refptr<DevToolsAgentHostImpl> protect(this); 103 scoped_refptr<DevToolsAgentHostImpl> protect(this);
64 close_listener_->AgentHostClosing(this); 104 close_listener_->AgentHostClosing(this);
65 close_listener_ = NULL; 105 close_listener_ = NULL;
66 } 106 }
67 } 107 }
68 108
109 WebContents* DevToolsAgentHostImpl::GetWebContents() {
110 return GetRenderViewHost()->GetDelegate()->GetAsWebContents();
111 }
112
113 NavigationEntry* DevToolsAgentHostImpl::GetNavigationEntry() {
114 WebContents* web_contents = GetWebContents();
115 if (!web_contents)
116 return NULL;
117
118 NavigationController& controller = web_contents->GetController();
119 NavigationEntry* entry = controller.GetActiveEntry();
120 if (!entry || !entry->GetURL().is_valid())
121 return NULL;
122
123 return entry;
124 }
125
69 } // namespace content 126 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698