| 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" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/android/tab_android.h" | 12 #include "chrome/browser/android/tab_android.h" |
| 13 #include "chrome/browser/devtools/devtools_network_protocol_handler.h" | 13 #include "chrome/browser/devtools/devtools_network_protocol_handler.h" |
| 14 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 14 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| 15 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 15 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 16 #include "chrome/common/features.h" | |
| 17 #include "chrome/grit/browser_resources.h" | 16 #include "chrome/grit/browser_resources.h" |
| 18 #include "content/public/browser/devtools_agent_host.h" | 17 #include "content/public/browser/devtools_agent_host.h" |
| 19 #include "content/public/browser/devtools_agent_host_client.h" | 18 #include "content/public/browser/devtools_agent_host_client.h" |
| 20 #include "content/public/browser/devtools_external_agent_proxy.h" | 19 #include "content/public/browser/devtools_external_agent_proxy.h" |
| 21 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" | 20 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" |
| 22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 24 | 23 |
| 25 using content::DevToolsAgentHost; | 24 using content::DevToolsAgentHost; |
| 26 using content::WebContents; | 25 using content::WebContents; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 std::string DevToolsManagerDelegateAndroid::GetTargetTitle( | 185 std::string DevToolsManagerDelegateAndroid::GetTargetTitle( |
| 187 content::RenderFrameHost* host) { | 186 content::RenderFrameHost* host) { |
| 188 content::WebContents* web_contents = | 187 content::WebContents* web_contents = |
| 189 content::WebContents::FromRenderFrameHost(host); | 188 content::WebContents::FromRenderFrameHost(host); |
| 190 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | 189 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
| 191 return tab ? base::UTF16ToUTF8(tab->GetTitle()) : ""; | 190 return tab ? base::UTF16ToUTF8(tab->GetTitle()) : ""; |
| 192 } | 191 } |
| 193 | 192 |
| 194 bool DevToolsManagerDelegateAndroid::DiscoverTargets( | 193 bool DevToolsManagerDelegateAndroid::DiscoverTargets( |
| 195 const DevToolsAgentHost::DiscoveryCallback& callback) { | 194 const DevToolsAgentHost::DiscoveryCallback& callback) { |
| 196 #if BUILDFLAG(ANDROID_JAVA_UI) | 195 #if defined(OS_ANDROID) |
| 197 // Enumerate existing tabs, including the ones with no WebContents. | 196 // Enumerate existing tabs, including the ones with no WebContents. |
| 198 DevToolsAgentHost::List result; | 197 DevToolsAgentHost::List result; |
| 199 std::set<WebContents*> tab_web_contents; | 198 std::set<WebContents*> tab_web_contents; |
| 200 for (TabModelList::const_iterator iter = TabModelList::begin(); | 199 for (TabModelList::const_iterator iter = TabModelList::begin(); |
| 201 iter != TabModelList::end(); ++iter) { | 200 iter != TabModelList::end(); ++iter) { |
| 202 TabModel* model = *iter; | 201 TabModel* model = *iter; |
| 203 for (int i = 0; i < model->GetTabCount(); ++i) { | 202 for (int i = 0; i < model->GetTabCount(); ++i) { |
| 204 TabAndroid* tab = model->GetTabAt(i); | 203 TabAndroid* tab = model->GetTabAt(i); |
| 205 if (!tab) | 204 if (!tab) |
| 206 continue; | 205 continue; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 224 if (tab_web_contents.find(web_contents) != tab_web_contents.end()) | 223 if (tab_web_contents.find(web_contents) != tab_web_contents.end()) |
| 225 continue; | 224 continue; |
| 226 } | 225 } |
| 227 result.push_back(*it); | 226 result.push_back(*it); |
| 228 } | 227 } |
| 229 | 228 |
| 230 callback.Run(std::move(result)); | 229 callback.Run(std::move(result)); |
| 231 return true; | 230 return true; |
| 232 #else | 231 #else |
| 233 return false; | 232 return false; |
| 234 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 233 #endif // defined(OS_ANDROID) |
| 235 } | 234 } |
| 236 | 235 |
| 237 scoped_refptr<DevToolsAgentHost> | 236 scoped_refptr<DevToolsAgentHost> |
| 238 DevToolsManagerDelegateAndroid::CreateNewTarget(const GURL& url) { | 237 DevToolsManagerDelegateAndroid::CreateNewTarget(const GURL& url) { |
| 239 if (TabModelList::empty()) | 238 if (TabModelList::empty()) |
| 240 return nullptr; | 239 return nullptr; |
| 241 | 240 |
| 242 TabModel* tab_model = TabModelList::get(0); | 241 TabModel* tab_model = TabModelList::get(0); |
| 243 if (!tab_model) | 242 if (!tab_model) |
| 244 return nullptr; | 243 return nullptr; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 263 | 262 |
| 264 void DevToolsManagerDelegateAndroid::DevToolsAgentHostAttached( | 263 void DevToolsManagerDelegateAndroid::DevToolsAgentHostAttached( |
| 265 content::DevToolsAgentHost* agent_host) { | 264 content::DevToolsAgentHost* agent_host) { |
| 266 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, true); | 265 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, true); |
| 267 } | 266 } |
| 268 | 267 |
| 269 void DevToolsManagerDelegateAndroid::DevToolsAgentHostDetached( | 268 void DevToolsManagerDelegateAndroid::DevToolsAgentHostDetached( |
| 270 content::DevToolsAgentHost* agent_host) { | 269 content::DevToolsAgentHost* agent_host) { |
| 271 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, false); | 270 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, false); |
| 272 } | 271 } |
| OLD | NEW |