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

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

Issue 2356883002: DevTools: prefer tab-based ids when reporting disovered targets on android. (Closed)
Patch Set: w/ attach 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
« no previous file with comments | « no previous file | 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 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/memory/ptr_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 void AgentHostClosed(DevToolsAgentHost* agent_host, 49 void AgentHostClosed(DevToolsAgentHost* agent_host,
50 bool replaced_with_another_client) override { 50 bool replaced_with_another_client) override {
51 proxy_->ConnectionClosed(); 51 proxy_->ConnectionClosed();
52 } 52 }
53 53
54 void Attach(content::DevToolsExternalAgentProxy* proxy) override { 54 void Attach(content::DevToolsExternalAgentProxy* proxy) override {
55 proxy_ = proxy; 55 proxy_ = proxy;
56 MaterializeAgentHost(); 56 MaterializeAgentHost();
57 if (agent_host_)
58 agent_host_->AttachClient(this);
57 } 59 }
58 60
59 void Detach() override { 61 void Detach() override {
60 if (agent_host_) 62 if (agent_host_)
61 agent_host_->DetachClient(this); 63 agent_host_->DetachClient(this);
62 agent_host_ = nullptr; 64 agent_host_ = nullptr;
63 proxy_ = nullptr; 65 proxy_ = nullptr;
64 } 66 }
65 67
66 std::string GetType() override { 68 std::string GetType() override {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // Enumerate existing tabs, including the ones with no WebContents. 165 // Enumerate existing tabs, including the ones with no WebContents.
164 std::set<WebContents*> tab_web_contents; 166 std::set<WebContents*> tab_web_contents;
165 for (TabModelList::const_iterator iter = TabModelList::begin(); 167 for (TabModelList::const_iterator iter = TabModelList::begin();
166 iter != TabModelList::end(); ++iter) { 168 iter != TabModelList::end(); ++iter) {
167 TabModel* model = *iter; 169 TabModel* model = *iter;
168 for (int i = 0; i < model->GetTabCount(); ++i) { 170 for (int i = 0; i < model->GetTabCount(); ++i) {
169 TabAndroid* tab = model->GetTabAt(i); 171 TabAndroid* tab = model->GetTabAt(i);
170 if (!tab) 172 if (!tab)
171 continue; 173 continue;
172 174
175 if (tab->web_contents())
176 tab_web_contents.insert(tab->web_contents());
177
173 scoped_refptr<DevToolsAgentHost> host = 178 scoped_refptr<DevToolsAgentHost> host =
174 DevToolsAgentHost::Forward( 179 DevToolsAgentHost::Forward(
175 base::IntToString(tab->GetAndroidId()), 180 base::IntToString(tab->GetAndroidId()),
176 base::WrapUnique(new TabProxyDelegate(tab))); 181 base::WrapUnique(new TabProxyDelegate(tab)));
182 result.push_back(host);
177 } 183 }
178 } 184 }
179 185
180 // Add descriptors for targets not associated with any tabs. 186 // Add descriptors for targets not associated with any tabs.
181 DevToolsAgentHost::List agents = DevToolsAgentHost::GetOrCreateAll(); 187 DevToolsAgentHost::List agents = DevToolsAgentHost::GetOrCreateAll();
182 for (DevToolsAgentHost::List::iterator it = agents.begin(); 188 for (DevToolsAgentHost::List::iterator it = agents.begin();
183 it != agents.end(); ++it) { 189 it != agents.end(); ++it) {
184 if (WebContents* web_contents = (*it)->GetWebContents()) { 190 if (WebContents* web_contents = (*it)->GetWebContents()) {
185 if (tab_web_contents.find(web_contents) != tab_web_contents.end()) 191 if (tab_web_contents.find(web_contents) != tab_web_contents.end())
186 continue; 192 continue;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 261
256 std::string DevToolsManagerDelegateAndroid::GetDiscoveryPageHTML() { 262 std::string DevToolsManagerDelegateAndroid::GetDiscoveryPageHTML() {
257 return ResourceBundle::GetSharedInstance().GetRawDataResource( 263 return ResourceBundle::GetSharedInstance().GetRawDataResource(
258 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); 264 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string();
259 } 265 }
260 266
261 void DevToolsManagerDelegateAndroid::DevToolsAgentStateChanged( 267 void DevToolsManagerDelegateAndroid::DevToolsAgentStateChanged(
262 DevToolsAgentHost* agent_host, bool attached) { 268 DevToolsAgentHost* agent_host, bool attached) {
263 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, attached); 269 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, attached);
264 } 270 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698