OLD | NEW |
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 std::string DevToolsManagerDelegateAndroid::GetTargetTitle( | 186 std::string DevToolsManagerDelegateAndroid::GetTargetTitle( |
187 content::RenderFrameHost* host) { | 187 content::RenderFrameHost* host) { |
188 content::WebContents* web_contents = | 188 content::WebContents* web_contents = |
189 content::WebContents::FromRenderFrameHost(host); | 189 content::WebContents::FromRenderFrameHost(host); |
190 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | 190 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
191 return tab ? base::UTF16ToUTF8(tab->GetTitle()) : ""; | 191 return tab ? base::UTF16ToUTF8(tab->GetTitle()) : ""; |
192 } | 192 } |
193 | 193 |
194 bool DevToolsManagerDelegateAndroid::DiscoverTargets( | 194 bool DevToolsManagerDelegateAndroid::DiscoverTargets( |
195 const DevToolsAgentHost::DiscoveryCallback& callback) { | 195 const DevToolsAgentHost::DiscoveryCallback& callback) { |
196 #if BUILDFLAG(ANDROID_JAVA_UI) | 196 #if defined(OS_ANDROID) |
197 // Enumerate existing tabs, including the ones with no WebContents. | 197 // Enumerate existing tabs, including the ones with no WebContents. |
198 DevToolsAgentHost::List result; | 198 DevToolsAgentHost::List result; |
199 std::set<WebContents*> tab_web_contents; | 199 std::set<WebContents*> tab_web_contents; |
200 for (TabModelList::const_iterator iter = TabModelList::begin(); | 200 for (TabModelList::const_iterator iter = TabModelList::begin(); |
201 iter != TabModelList::end(); ++iter) { | 201 iter != TabModelList::end(); ++iter) { |
202 TabModel* model = *iter; | 202 TabModel* model = *iter; |
203 for (int i = 0; i < model->GetTabCount(); ++i) { | 203 for (int i = 0; i < model->GetTabCount(); ++i) { |
204 TabAndroid* tab = model->GetTabAt(i); | 204 TabAndroid* tab = model->GetTabAt(i); |
205 if (!tab) | 205 if (!tab) |
206 continue; | 206 continue; |
(...skipping 17 matching lines...) Expand all Loading... |
224 if (tab_web_contents.find(web_contents) != tab_web_contents.end()) | 224 if (tab_web_contents.find(web_contents) != tab_web_contents.end()) |
225 continue; | 225 continue; |
226 } | 226 } |
227 result.push_back(*it); | 227 result.push_back(*it); |
228 } | 228 } |
229 | 229 |
230 callback.Run(std::move(result)); | 230 callback.Run(std::move(result)); |
231 return true; | 231 return true; |
232 #else | 232 #else |
233 return false; | 233 return false; |
234 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 234 #endif // defined(OS_ANDROID) |
235 } | 235 } |
236 | 236 |
237 scoped_refptr<DevToolsAgentHost> | 237 scoped_refptr<DevToolsAgentHost> |
238 DevToolsManagerDelegateAndroid::CreateNewTarget(const GURL& url) { | 238 DevToolsManagerDelegateAndroid::CreateNewTarget(const GURL& url) { |
239 if (TabModelList::empty()) | 239 if (TabModelList::empty()) |
240 return nullptr; | 240 return nullptr; |
241 | 241 |
242 TabModel* tab_model = TabModelList::get(0); | 242 TabModel* tab_model = TabModelList::get(0); |
243 if (!tab_model) | 243 if (!tab_model) |
244 return nullptr; | 244 return nullptr; |
(...skipping 18 matching lines...) Expand all Loading... |
263 | 263 |
264 void DevToolsManagerDelegateAndroid::DevToolsAgentHostAttached( | 264 void DevToolsManagerDelegateAndroid::DevToolsAgentHostAttached( |
265 content::DevToolsAgentHost* agent_host) { | 265 content::DevToolsAgentHost* agent_host) { |
266 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, true); | 266 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, true); |
267 } | 267 } |
268 | 268 |
269 void DevToolsManagerDelegateAndroid::DevToolsAgentHostDetached( | 269 void DevToolsManagerDelegateAndroid::DevToolsAgentHostDetached( |
270 content::DevToolsAgentHost* agent_host) { | 270 content::DevToolsAgentHost* agent_host) { |
271 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, false); | 271 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, false); |
272 } | 272 } |
OLD | NEW |