| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/devtools/device/devtools_android_bridge.h" | 5 #include "chrome/browser/devtools/device/devtools_android_bridge.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/threading/thread.h" | 28 #include "base/threading/thread.h" |
| 29 #include "base/values.h" | 29 #include "base/values.h" |
| 30 #include "chrome/browser/devtools/device/adb/adb_device_provider.h" | 30 #include "chrome/browser/devtools/device/adb/adb_device_provider.h" |
| 31 #include "chrome/browser/devtools/device/port_forwarding_controller.h" | 31 #include "chrome/browser/devtools/device/port_forwarding_controller.h" |
| 32 #include "chrome/browser/devtools/device/tcp_device_provider.h" | 32 #include "chrome/browser/devtools/device/tcp_device_provider.h" |
| 33 #include "chrome/browser/devtools/device/usb/usb_device_provider.h" | 33 #include "chrome/browser/devtools/device/usb/usb_device_provider.h" |
| 34 #include "chrome/browser/devtools/devtools_protocol.h" | 34 #include "chrome/browser/devtools/devtools_protocol.h" |
| 35 #include "chrome/browser/devtools/devtools_target_impl.h" | |
| 36 #include "chrome/browser/devtools/devtools_window.h" | 35 #include "chrome/browser/devtools/devtools_window.h" |
| 37 #include "chrome/browser/devtools/remote_debugging_server.h" | 36 #include "chrome/browser/devtools/remote_debugging_server.h" |
| 38 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
| 39 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 41 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 40 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 42 #include "components/prefs/pref_service.h" | 41 #include "components/prefs/pref_service.h" |
| 43 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 42 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 44 #include "components/signin/core/browser/signin_manager.h" | 43 #include "components/signin/core/browser/signin_manager.h" |
| 45 #include "content/public/browser/devtools_agent_host.h" | 44 #include "content/public/browser/devtools_agent_host.h" |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 for (const base::StringPiece& part : | 589 for (const base::StringPiece& part : |
| 591 base::SplitStringPiece( | 590 base::SplitStringPiece( |
| 592 version_, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { | 591 version_, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { |
| 593 int value = 0; | 592 int value = 0; |
| 594 base::StringToInt(part, &value); | 593 base::StringToInt(part, &value); |
| 595 result.push_back(value); | 594 result.push_back(value); |
| 596 } | 595 } |
| 597 return result; | 596 return result; |
| 598 } | 597 } |
| 599 | 598 |
| 600 DevToolsTargetImpl* | 599 scoped_refptr<content::DevToolsAgentHost> |
| 601 DevToolsAndroidBridge::CreatePageTarget(scoped_refptr<RemotePage> page) { | 600 DevToolsAndroidBridge::CreatePageTarget(scoped_refptr<RemotePage> page) { |
| 602 std::string local_id = BuildUniqueTargetId(page->browser_id_, | 601 std::string local_id = BuildUniqueTargetId(page->browser_id_, |
| 603 page->dict_.get()); | 602 page->dict_.get()); |
| 604 std::string target_path = GetTargetPath(page->dict_.get()); | 603 std::string target_path = GetTargetPath(page->dict_.get()); |
| 605 std::string type = GetStringProperty(page->dict_.get(), "type"); | 604 std::string type = GetStringProperty(page->dict_.get(), "type"); |
| 606 scoped_refptr<DevToolsAgentHost> host = | 605 return AgentHostDelegate::GetOrCreateAgentHost( |
| 607 AgentHostDelegate::GetOrCreateAgentHost(this, page->browser_id_, local_id, | 606 this, page->browser_id_, local_id, target_path, type, page->dict_.get()); |
| 608 target_path, type, | |
| 609 page->dict_.get()); | |
| 610 return new DevToolsTargetImpl(host); | |
| 611 } | 607 } |
| 612 | 608 |
| 613 void DevToolsAndroidBridge::SendJsonRequest( | 609 void DevToolsAndroidBridge::SendJsonRequest( |
| 614 const BrowserId& browser_id, | 610 const BrowserId& browser_id, |
| 615 const std::string& request, | 611 const std::string& request, |
| 616 const JsonRequestCallback& callback) { | 612 const JsonRequestCallback& callback) { |
| 617 scoped_refptr<AndroidDeviceManager::Device> device( | 613 scoped_refptr<AndroidDeviceManager::Device> device( |
| 618 FindDevice(browser_id.first)); | 614 FindDevice(browser_id.first)); |
| 619 if (!device.get()) { | 615 if (!device.get()) { |
| 620 callback.Run(net::ERR_FAILED, std::string()); | 616 callback.Run(net::ERR_FAILED, std::string()); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 StopDeviceListPolling(); | 977 StopDeviceListPolling(); |
| 982 StartDeviceListPolling(); | 978 StartDeviceListPolling(); |
| 983 } | 979 } |
| 984 } | 980 } |
| 985 | 981 |
| 986 void DevToolsAndroidBridge::set_tcp_provider_callback_for_test( | 982 void DevToolsAndroidBridge::set_tcp_provider_callback_for_test( |
| 987 TCPProviderCallback callback) { | 983 TCPProviderCallback callback) { |
| 988 tcp_provider_callback_ = callback; | 984 tcp_provider_callback_ = callback; |
| 989 CreateDeviceProviders(); | 985 CreateDeviceProviders(); |
| 990 } | 986 } |
| OLD | NEW |