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

Side by Side Diff: chrome/browser/android/devtools_manager_delegate_android.cc

Issue 2300703005: DevTools: merge devtools_http_handler into content - it is used in all the embedders anyways. (Closed)
Patch Set: for_landing! Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/android/devtools_manager_delegate_android.h" 5 #include "chrome/browser/android/devtools_manager_delegate_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h"
8 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
11 #include "chrome/browser/android/tab_android.h" 12 #include "chrome/browser/android/tab_android.h"
12 #include "chrome/browser/devtools/devtools_network_protocol_handler.h" 13 #include "chrome/browser/devtools/devtools_network_protocol_handler.h"
13 #include "chrome/browser/ui/android/tab_model/tab_model.h" 14 #include "chrome/browser/ui/android/tab_model/tab_model.h"
14 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" 15 #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
15 #include "chrome/common/features.h" 16 #include "chrome/common/features.h"
17 #include "chrome/grit/browser_resources.h"
16 #include "content/public/browser/devtools_agent_host.h" 18 #include "content/public/browser/devtools_agent_host.h"
17 #include "content/public/browser/devtools_agent_host_client.h" 19 #include "content/public/browser/devtools_agent_host_client.h"
18 #include "content/public/browser/devtools_external_agent_proxy.h" 20 #include "content/public/browser/devtools_external_agent_proxy.h"
19 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" 21 #include "content/public/browser/devtools_external_agent_proxy_delegate.h"
20 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "ui/base/resource/resource_bundle.h"
21 24
22 using content::DevToolsAgentHost; 25 using content::DevToolsAgentHost;
23 using content::WebContents; 26 using content::WebContents;
24 27
25 namespace { 28 namespace {
26 29
27 class TabProxyDelegate : public content::DevToolsExternalAgentProxyDelegate, 30 class TabProxyDelegate : public content::DevToolsExternalAgentProxyDelegate,
28 public content::DevToolsAgentHostClient { 31 public content::DevToolsAgentHostClient {
29 public: 32 public:
30 explicit TabProxyDelegate(TabAndroid* tab) 33 explicit TabProxyDelegate(TabAndroid* tab)
(...skipping 22 matching lines...) Expand all
53 MaterializeAgentHost(); 56 MaterializeAgentHost();
54 } 57 }
55 58
56 void Detach() override { 59 void Detach() override {
57 if (agent_host_) 60 if (agent_host_)
58 agent_host_->DetachClient(this); 61 agent_host_->DetachClient(this);
59 agent_host_ = nullptr; 62 agent_host_ = nullptr;
60 proxy_ = nullptr; 63 proxy_ = nullptr;
61 } 64 }
62 65
63 std::string GetId() override {
64 return base::IntToString(tab_id_);
65 }
66
67 std::string GetType() override { 66 std::string GetType() override {
68 return agent_host_ ? agent_host_->GetType() : DevToolsAgentHost::kTypePage; 67 return agent_host_ ? agent_host_->GetType() : DevToolsAgentHost::kTypePage;
69 } 68 }
70 69
71 std::string GetTitle() override { 70 std::string GetTitle() override {
72 return agent_host_ ? agent_host_->GetTitle() : title_; 71 return agent_host_ ? agent_host_->GetTitle() : title_;
73 } 72 }
74 73
75 std::string GetDescription() override { 74 std::string GetDescription() override {
76 return agent_host_ ? agent_host_->GetDescription() : ""; 75 return agent_host_ ? agent_host_->GetDescription() : "";
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 std::set<WebContents*> tab_web_contents; 164 std::set<WebContents*> tab_web_contents;
166 for (TabModelList::const_iterator iter = TabModelList::begin(); 165 for (TabModelList::const_iterator iter = TabModelList::begin();
167 iter != TabModelList::end(); ++iter) { 166 iter != TabModelList::end(); ++iter) {
168 TabModel* model = *iter; 167 TabModel* model = *iter;
169 for (int i = 0; i < model->GetTabCount(); ++i) { 168 for (int i = 0; i < model->GetTabCount(); ++i) {
170 TabAndroid* tab = model->GetTabAt(i); 169 TabAndroid* tab = model->GetTabAt(i);
171 if (!tab) 170 if (!tab)
172 continue; 171 continue;
173 172
174 scoped_refptr<DevToolsAgentHost> host = 173 scoped_refptr<DevToolsAgentHost> host =
175 DevToolsAgentHost::Create(new TabProxyDelegate(tab)); 174 DevToolsAgentHost::Forward(
175 base::IntToString(tab->GetAndroidId()),
176 base::WrapUnique(new TabProxyDelegate(tab)));
176 } 177 }
177 } 178 }
178 179
179 // Add descriptors for targets not associated with any tabs. 180 // Add descriptors for targets not associated with any tabs.
180 DevToolsAgentHost::List agents = DevToolsAgentHost::GetOrCreateAll(); 181 DevToolsAgentHost::List agents = DevToolsAgentHost::GetOrCreateAll();
181 for (DevToolsAgentHost::List::iterator it = agents.begin(); 182 for (DevToolsAgentHost::List::iterator it = agents.begin();
182 it != agents.end(); ++it) { 183 it != agents.end(); ++it) {
183 if (WebContents* web_contents = (*it)->GetWebContents()) { 184 if (WebContents* web_contents = (*it)->GetWebContents()) {
184 if (tab_web_contents.find(web_contents) != tab_web_contents.end()) 185 if (tab_web_contents.find(web_contents) != tab_web_contents.end())
185 continue; 186 continue;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return nullptr; 241 return nullptr;
241 242
242 WebContents* web_contents = tab_model->CreateNewTabForDevTools(url); 243 WebContents* web_contents = tab_model->CreateNewTabForDevTools(url);
243 if (!web_contents) 244 if (!web_contents)
244 return nullptr; 245 return nullptr;
245 246
246 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); 247 TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
247 if (!tab) 248 if (!tab)
248 return nullptr; 249 return nullptr;
249 250
250 return DevToolsAgentHost::Create(new TabProxyDelegate(tab)); 251 return DevToolsAgentHost::Forward(
252 base::IntToString(tab->GetAndroidId()),
253 base::WrapUnique(new TabProxyDelegate(tab)));
254 }
255
256 std::string DevToolsManagerDelegateAndroid::GetDiscoveryPageHTML() {
257 return ResourceBundle::GetSharedInstance().GetRawDataResource(
258 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string();
251 } 259 }
252 260
253 void DevToolsManagerDelegateAndroid::DevToolsAgentStateChanged( 261 void DevToolsManagerDelegateAndroid::DevToolsAgentStateChanged(
254 DevToolsAgentHost* agent_host, bool attached) { 262 DevToolsAgentHost* agent_host, bool attached) {
255 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, attached); 263 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, attached);
256 } 264 }
OLDNEW
« no previous file with comments | « chrome/browser/android/devtools_manager_delegate_android.h ('k') | chrome/browser/android/devtools_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698