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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 for (const base::StringPiece& part : | 594 for (const base::StringPiece& part : |
596 base::SplitStringPiece( | 595 base::SplitStringPiece( |
597 version_, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { | 596 version_, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { |
598 int value = 0; | 597 int value = 0; |
599 base::StringToInt(part, &value); | 598 base::StringToInt(part, &value); |
600 result.push_back(value); | 599 result.push_back(value); |
601 } | 600 } |
602 return result; | 601 return result; |
603 } | 602 } |
604 | 603 |
605 DevToolsTargetImpl* | 604 scoped_refptr<content::DevToolsAgentHost> |
606 DevToolsAndroidBridge::CreatePageTarget(scoped_refptr<RemotePage> page) { | 605 DevToolsAndroidBridge::CreatePageTarget(scoped_refptr<RemotePage> page) { |
607 std::string local_id = BuildUniqueTargetId(page->browser_id_, | 606 std::string local_id = BuildUniqueTargetId(page->browser_id_, |
608 page->dict_.get()); | 607 page->dict_.get()); |
609 std::string target_path = GetTargetPath(page->dict_.get()); | 608 std::string target_path = GetTargetPath(page->dict_.get()); |
610 std::string type = GetStringProperty(page->dict_.get(), "type"); | 609 std::string type = GetStringProperty(page->dict_.get(), "type"); |
611 scoped_refptr<DevToolsAgentHost> host = | 610 return AgentHostDelegate::GetOrCreateAgentHost( |
612 AgentHostDelegate::GetOrCreateAgentHost(this, page->browser_id_, local_id, | 611 this, page->browser_id_, local_id, target_path, type, page->dict_.get()); |
613 target_path, type, | |
614 page->dict_.get()); | |
615 return new DevToolsTargetImpl(host); | |
616 } | 612 } |
617 | 613 |
618 void DevToolsAndroidBridge::SendJsonRequest( | 614 void DevToolsAndroidBridge::SendJsonRequest( |
619 const BrowserId& browser_id, | 615 const BrowserId& browser_id, |
620 const std::string& request, | 616 const std::string& request, |
621 const JsonRequestCallback& callback) { | 617 const JsonRequestCallback& callback) { |
622 scoped_refptr<AndroidDeviceManager::Device> device( | 618 scoped_refptr<AndroidDeviceManager::Device> device( |
623 FindDevice(browser_id.first)); | 619 FindDevice(browser_id.first)); |
624 if (!device.get()) { | 620 if (!device.get()) { |
625 callback.Run(net::ERR_FAILED, std::string()); | 621 callback.Run(net::ERR_FAILED, std::string()); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 StopDeviceListPolling(); | 982 StopDeviceListPolling(); |
987 StartDeviceListPolling(); | 983 StartDeviceListPolling(); |
988 } | 984 } |
989 } | 985 } |
990 | 986 |
991 void DevToolsAndroidBridge::set_tcp_provider_callback_for_test( | 987 void DevToolsAndroidBridge::set_tcp_provider_callback_for_test( |
992 TCPProviderCallback callback) { | 988 TCPProviderCallback callback) { |
993 tcp_provider_callback_ = callback; | 989 tcp_provider_callback_ = callback; |
994 CreateDeviceProviders(); | 990 CreateDeviceProviders(); |
995 } | 991 } |
OLD | NEW |