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

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

Issue 2263843002: DevTools: merge devtools target with devtools host, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for review Created 4 years, 4 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/dev_tools_discovery_provider_android.h" 5 #include "chrome/browser/android/dev_tools_discovery_provider_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 base::TimeTicks GetLastActivityTime() const override { 74 base::TimeTicks GetLastActivityTime() const override {
75 return last_activity_time_; 75 return last_activity_time_;
76 } 76 }
77 77
78 std::string GetId() const override { 78 std::string GetId() const override {
79 return base::IntToString(tab_id_); 79 return base::IntToString(tab_id_);
80 } 80 }
81 81
82 std::string GetType() const override { 82 std::string GetType() const override {
83 return devtools_discovery::BasicTargetDescriptor::kTypePage; 83 return DevToolsAgentHost::kTypePage;
84 } 84 }
85 85
86 bool IsAttached() const override { 86 bool IsAttached() const override {
87 TabModel* model; 87 TabModel* model;
88 int index; 88 int index;
89 if (!FindTab(&model, &index)) 89 if (!FindTab(&model, &index))
90 return false; 90 return false;
91 WebContents* web_contents = model->GetWebContentsAt(index); 91 WebContents* web_contents = model->GetWebContentsAt(index);
92 if (!web_contents) 92 if (!web_contents)
93 return false; 93 return false;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 TabAndroid* tab = model->GetTabAt(i); 216 TabAndroid* tab = model->GetTabAt(i);
217 if (!tab) 217 if (!tab)
218 continue; 218 continue;
219 219
220 WebContents* web_contents = tab->web_contents(); 220 WebContents* web_contents = tab->web_contents();
221 if (web_contents) { 221 if (web_contents) {
222 tab_web_contents.insert(web_contents); 222 tab_web_contents.insert(web_contents);
223 result.push_back(TabDescriptor::CreateForWebContents( 223 result.push_back(TabDescriptor::CreateForWebContents(
224 tab->GetAndroidId(), web_contents)); 224 tab->GetAndroidId(), web_contents));
225 } else { 225 } else {
226 result.push_back(TabDescriptor::CreateForUnloadedTab( 226 result.push_back(TabDescriptor::CreateForUnloadedTab(
dgozman 2016/08/22 23:09:07 This should be a forwarding agent host.
227 tab->GetAndroidId(), tab->GetTitle(), tab->GetURL())); 227 tab->GetAndroidId(), tab->GetTitle(), tab->GetURL()));
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 // Add descriptors for targets not associated with any tabs. 232 // Add descriptors for targets not associated with any tabs.
233 DevToolsAgentHost::List agents = DevToolsAgentHost::GetOrCreateAll(); 233 DevToolsAgentHost::List agents = DevToolsAgentHost::GetOrCreateAll();
234 for (DevToolsAgentHost::List::iterator it = agents.begin(); 234 for (DevToolsAgentHost::List::iterator it = agents.begin();
235 it != agents.end(); ++it) { 235 it != agents.end(); ++it) {
236 if (WebContents* web_contents = (*it)->GetWebContents()) { 236 if (WebContents* web_contents = (*it)->GetWebContents()) {
237 if (tab_web_contents.find(web_contents) != tab_web_contents.end()) 237 if (tab_web_contents.find(web_contents) != tab_web_contents.end())
238 continue; 238 continue;
239 } 239 }
240 result.push_back(new devtools_discovery::BasicTargetDescriptor(*it)); 240 result.push_back(new DevToolsTargetImpl(*it));
241 } 241 }
242 242
243 return result; 243 return result;
244 } 244 }
245 245
246 // static 246 // static
247 void DevToolsDiscoveryProviderAndroid::Install() { 247 void DevToolsDiscoveryProviderAndroid::Install() {
248 devtools_discovery::DevToolsDiscoveryManager* discovery_manager = 248 devtools_discovery::DevToolsDiscoveryManager* discovery_manager =
249 devtools_discovery::DevToolsDiscoveryManager::GetInstance(); 249 devtools_discovery::DevToolsDiscoveryManager::GetInstance();
250 discovery_manager->AddProvider( 250 discovery_manager->AddProvider(
251 base::WrapUnique(new DevToolsDiscoveryProviderAndroid())); 251 base::WrapUnique(new DevToolsDiscoveryProviderAndroid()));
252 discovery_manager->SetCreateCallback(base::Bind(&CreateNewAndroidTab)); 252 discovery_manager->SetCreateCallback(base::Bind(&CreateNewAndroidTab));
253 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698