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

Side by Side Diff: content/shell/browser/shell_devtools_manager_delegate.cc

Issue 1099243004: [DevTools] Migrate android to devtools_discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « components/devtools_discovery/devtools_discovery_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/shell/browser/shell_devtools_manager_delegate.h" 5 #include "content/shell/browser/shell_devtools_manager_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 port = static_cast<uint16>(temp_port); 125 port = static_cast<uint16>(temp_port);
126 } else { 126 } else {
127 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; 127 DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
128 } 128 }
129 } 129 }
130 return scoped_ptr<DevToolsHttpHandler::ServerSocketFactory>( 130 return scoped_ptr<DevToolsHttpHandler::ServerSocketFactory>(
131 new TCPServerSocketFactory("127.0.0.1", port)); 131 new TCPServerSocketFactory("127.0.0.1", port));
132 #endif 132 #endif
133 } 133 }
134 134
135 scoped_ptr<devtools_discovery::DevToolsTargetDescriptor>
136 CreateNewShellTarget(BrowserContext* browser_context, const GURL& url) {
137 Shell* shell = Shell::CreateNewWindow(browser_context,
138 url,
139 nullptr,
140 gfx::Size());
141 return make_scoped_ptr(new devtools_discovery::BasicTargetDescriptor(
142 DevToolsAgentHost::GetOrCreateFor(shell->web_contents())));
143 }
144
135 // ShellDevToolsDelegate ---------------------------------------------------- 145 // ShellDevToolsDelegate ----------------------------------------------------
136 146
137 class ShellDevToolsDelegate : 147 class ShellDevToolsDelegate :
138 public devtools_http_handler::DevToolsHttpHandlerDelegate { 148 public devtools_http_handler::DevToolsHttpHandlerDelegate {
139 public: 149 public:
140 explicit ShellDevToolsDelegate(BrowserContext* browser_context); 150 explicit ShellDevToolsDelegate(BrowserContext* browser_context);
141 ~ShellDevToolsDelegate() override; 151 ~ShellDevToolsDelegate() override;
142 152
143 // devtools_http_handler::DevToolsHttpHandlerDelegate implementation. 153 // devtools_http_handler::DevToolsHttpHandlerDelegate implementation.
144 std::string GetDiscoveryPageHTML() override; 154 std::string GetDiscoveryPageHTML() override;
145 std::string GetFrontendResource(const std::string& path) override; 155 std::string GetFrontendResource(const std::string& path) override;
146 156
147 private: 157 private:
148 BrowserContext* browser_context_; 158 BrowserContext* browser_context_;
149 159
150 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsDelegate); 160 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsDelegate);
151 }; 161 };
152 162
153 ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context) 163 ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context)
154 : browser_context_(browser_context) { 164 : browser_context_(browser_context) {
165 devtools_discovery::DevToolsDiscoveryManager::GetInstance()->
166 SetCreateCallback(base::Bind(&CreateNewShellTarget,
167 base::Unretained(browser_context)));
155 } 168 }
156 169
157 ShellDevToolsDelegate::~ShellDevToolsDelegate() { 170 ShellDevToolsDelegate::~ShellDevToolsDelegate() {
171 devtools_discovery::DevToolsDiscoveryManager::GetInstance()->
172 SetCreateCallback(
173 devtools_discovery::DevToolsDiscoveryManager::CreateCallback());
158 } 174 }
159 175
160 std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() { 176 std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() {
161 #if defined(OS_ANDROID) 177 #if defined(OS_ANDROID)
162 return std::string(); 178 return std::string();
163 #else 179 #else
164 return ResourceBundle::GetSharedInstance().GetRawDataResource( 180 return ResourceBundle::GetSharedInstance().GetRawDataResource(
165 IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); 181 IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string();
166 #endif 182 #endif
167 } 183 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return NULL; 224 return NULL;
209 } 225 }
210 226
211 std::string ShellDevToolsManagerDelegate::GetPageThumbnailData( 227 std::string ShellDevToolsManagerDelegate::GetPageThumbnailData(
212 const GURL& url) { 228 const GURL& url) {
213 return std::string(); 229 return std::string();
214 } 230 }
215 231
216 scoped_ptr<DevToolsTarget> 232 scoped_ptr<DevToolsTarget>
217 ShellDevToolsManagerDelegate::CreateNewTarget(const GURL& url) { 233 ShellDevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
218 Shell* shell = Shell::CreateNewWindow(browser_context_, 234 devtools_discovery::DevToolsDiscoveryManager* discovery_manager =
219 url, 235 devtools_discovery::DevToolsDiscoveryManager::GetInstance();
220 NULL, 236 return discovery_manager->CreateNew(url);
221 gfx::Size());
222 return scoped_ptr<DevToolsTarget>(
223 new devtools_discovery::BasicTargetDescriptor(
224 DevToolsAgentHost::GetOrCreateFor(shell->web_contents())));
225 } 237 }
226 238
227 void ShellDevToolsManagerDelegate::EnumerateTargets(TargetCallback callback) { 239 void ShellDevToolsManagerDelegate::EnumerateTargets(TargetCallback callback) {
228 TargetList targets; 240 TargetList targets;
229 devtools_discovery::DevToolsDiscoveryManager* discovery_manager = 241 devtools_discovery::DevToolsDiscoveryManager* discovery_manager =
230 devtools_discovery::DevToolsDiscoveryManager::GetInstance(); 242 devtools_discovery::DevToolsDiscoveryManager::GetInstance();
231 for (const auto& descriptor : discovery_manager->GetDescriptors()) 243 for (const auto& descriptor : discovery_manager->GetDescriptors())
232 targets.push_back(descriptor); 244 targets.push_back(descriptor);
233 callback.Run(targets); 245 callback.Run(targets);
234 } 246 }
235 247
236 } // namespace content 248 } // namespace content
OLDNEW
« no previous file with comments | « components/devtools_discovery/devtools_discovery_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698