diff options
31 files changed, 3 insertions, 1395 deletions
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn index 1cd9988..e18f5d4 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn @@ -685,10 +685,8 @@ repack("packed_extra_resources") { "$root_gen_dir/chrome/quota_internals_resources.pak", "$root_gen_dir/chrome/settings_resources.pak", "$root_gen_dir/chrome/sync_file_system_internals_resources.pak", - "$root_gen_dir/chrome/webrtc_device_provider_resources.pak", ] deps += [ - "//chrome/browser/devtools:webrtc_device_provider_resources", "//chrome/browser/resources:component_extension_resources", "//chrome/browser/resources:options_resources", "//chrome/browser/resources:quota_internals_resources", diff --git a/chrome/browser/devtools/BUILD.gn b/chrome/browser/devtools/BUILD.gn index 17b2789..06b35f6 100644 --- a/chrome/browser/devtools/BUILD.gn +++ b/chrome/browser/devtools/BUILD.gn @@ -69,7 +69,6 @@ static_library("devtools") { if (!is_android) { deps += [ - ":webrtc_device_provider_resources", "//chrome:extra_resources", "//chrome:resources", "//chrome:strings", @@ -109,14 +108,6 @@ static_library("devtools") { "device/usb/android_usb_socket.h", "device/usb/usb_device_provider.cc", "device/usb/usb_device_provider.h", - "device/webrtc/devtools_bridge_client.cc", - "device/webrtc/devtools_bridge_client.h", - "device/webrtc/devtools_bridge_instances_request.cc", - "device/webrtc/devtools_bridge_instances_request.h", - "device/webrtc/send_command_request.cc", - "device/webrtc/send_command_request.h", - "device/webrtc/webrtc_device_provider.cc", - "device/webrtc/webrtc_device_provider.h", "devtools_contents_resizing_strategy.cc", "devtools_contents_resizing_strategy.h", "devtools_embedder_message_dispatcher.cc", @@ -144,17 +135,3 @@ static_library("devtools") { ] } } - -if (!is_android) { - # GYP version: chrome/browser/devtools/webrtc_device_provider_resources.gyp:webrtc_device_provider_resources - grit("webrtc_device_provider_resources") { - source = "device/webrtc/resources.grd" - output_dir = "$root_gen_dir/chrome" - outputs = [ - "grit/webrtc_device_provider_resources.h", - "grit/webrtc_device_provider_resources_map.cc", - "grit/webrtc_device_provider_resources_map.h", - "webrtc_device_provider_resources.pak", - ] - } -} diff --git a/chrome/browser/devtools/device/devtools_android_bridge.cc b/chrome/browser/devtools/device/devtools_android_bridge.cc index eef7de4..5cc5b77 100644 --- a/chrome/browser/devtools/device/devtools_android_bridge.cc +++ b/chrome/browser/devtools/device/devtools_android_bridge.cc @@ -33,14 +33,11 @@ #include "chrome/browser/devtools/device/port_forwarding_controller.h" #include "chrome/browser/devtools/device/tcp_device_provider.h" #include "chrome/browser/devtools/device/usb/usb_device_provider.h" -#include "chrome/browser/devtools/device/webrtc/webrtc_device_provider.h" #include "chrome/browser/devtools/devtools_protocol.h" #include "chrome/browser/devtools/devtools_target_impl.h" #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/devtools/remote_debugging_server.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" -#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" @@ -70,11 +67,6 @@ const char kPageReloadCommand[] = "Page.reload"; const char kWebViewSocketPrefix[] = "webview_devtools_remote"; -bool IsWebRTCDeviceProviderEnabled() { - return base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableDevToolsExperiments); -} - bool BrowserIdFromString(const std::string& browser_id_str, DevToolsAndroidBridge::BrowserId* browser_id) { size_t colon_pos = browser_id_str.find(':'); @@ -276,10 +268,6 @@ DevToolsAndroidBridge::Factory::Factory() : BrowserContextKeyedServiceFactory( "DevToolsAndroidBridge", BrowserContextDependencyManager::GetInstance()) { - if (IsWebRTCDeviceProviderEnabled()) { - DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); - DependsOn(SigninManagerFactory::GetInstance()); - } } DevToolsAndroidBridge::Factory::~Factory() {} @@ -288,16 +276,7 @@ KeyedService* DevToolsAndroidBridge::Factory::BuildServiceInstanceFor( content::BrowserContext* context) const { Profile* profile = Profile::FromBrowserContext(context); - ProfileOAuth2TokenService* token_service = nullptr; - SigninManagerBase* signin_manager = nullptr; - - if (IsWebRTCDeviceProviderEnabled()) { - token_service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); - signin_manager = SigninManagerFactory::GetForProfile(profile); - } - - return new DevToolsAndroidBridge( - profile, signin_manager, token_service); + return new DevToolsAndroidBridge(profile); } // AgentHostDelegate ---------------------------------------------------------- @@ -732,12 +711,8 @@ DevToolsAndroidBridge::RemoteDevice::~RemoteDevice() { // DevToolsAndroidBridge ------------------------------------------------------ DevToolsAndroidBridge::DevToolsAndroidBridge( - Profile* profile, - SigninManagerBase* signin_manager, - ProfileOAuth2TokenService* const token_service) + Profile* profile) : profile_(profile), - signin_manager_(signin_manager), - token_service_(token_service), device_manager_(AndroidDeviceManager::Create()), task_scheduler_(base::Bind(&DevToolsAndroidBridge::ScheduleTaskDefault)), port_forwarding_controller_(new PortForwardingController(profile, this)), @@ -962,11 +937,6 @@ void DevToolsAndroidBridge::CreateDeviceProviders() { device_providers.push_back(new UsbDeviceProvider(profile_)); } - if (IsWebRTCDeviceProviderEnabled()) { - device_providers.push_back( - new WebRTCDeviceProvider(profile_, signin_manager_, token_service_)); - } - device_manager_->SetDeviceProviders(device_providers); if (NeedsDeviceListPolling()) { StopDeviceListPolling(); diff --git a/chrome/browser/devtools/device/devtools_android_bridge.h b/chrome/browser/devtools/device/devtools_android_bridge.h index b315798..0c63afd 100644 --- a/chrome/browser/devtools/device/devtools_android_bridge.h +++ b/chrome/browser/devtools/device/devtools_android_bridge.h @@ -37,9 +37,6 @@ class BrowserContext; class DevToolsTargetImpl; class PortForwardingController; class Profile; -class WebRTCDeviceProvider; -class SigninManagerBase; -class ProfileOAuth2TokenService; class DevToolsAndroidBridge : public KeyedService { public: @@ -160,9 +157,7 @@ class DevToolsAndroidBridge : public KeyedService { virtual ~DeviceListListener() {} }; - DevToolsAndroidBridge(Profile* profile, - SigninManagerBase* signin_manager, - ProfileOAuth2TokenService* token_service); + explicit DevToolsAndroidBridge(Profile* profile); void AddDeviceListListener(DeviceListListener* listener); void RemoveDeviceListListener(DeviceListListener* listener); @@ -274,8 +269,6 @@ class DevToolsAndroidBridge : public KeyedService { } Profile* const profile_; - SigninManagerBase* const signin_manager_; - ProfileOAuth2TokenService* const token_service_; const scoped_ptr<AndroidDeviceManager> device_manager_; typedef std::map<std::string, scoped_refptr<AndroidDeviceManager::Device>> diff --git a/chrome/browser/devtools/device/webrtc/background_worker.html b/chrome/browser/devtools/device/webrtc/background_worker.html deleted file mode 100644 index 9b630fc..0000000 --- a/chrome/browser/devtools/device/webrtc/background_worker.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML> -<!-- - -- Copyright 2014 The Chromium Authors. All rights reserved. - -- Use of this source code is governed by a BSD-style license that can be - -- found in the LICENSE file. - --> -<html> -<head> -<script src="js/webrtc_device_provider.js"></script> -</head> -</html> diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_client.cc b/chrome/browser/devtools/device/webrtc/devtools_bridge_client.cc deleted file mode 100644 index a1c7184..0000000 --- a/chrome/browser/devtools/device/webrtc/devtools_bridge_client.cc +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/devtools/device/webrtc/devtools_bridge_client.h" - -#include <stddef.h> - -#include "base/callback.h" -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/local_discovery/gcd_api_flow.h" -#include "chrome/common/url_constants.h" -#include "components/signin/core/browser/profile_identity_provider.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/notification_source.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_observer.h" -#include "content/public/browser/web_contents_user_data.h" -#include "ui/base/page_transition_types.h" - -using content::BrowserThread; -using content::WebContents; - -namespace { - -const char kBackgroundWorkerURL[] = - "chrome://webrtc-device-provider/background_worker.html"; -const char kSerial[] = "webrtc"; -const char kPseudoDeviceName[] = "Remote browsers"; -const char kDeviceIdPrefix[] = "device-id:"; - -class BackgroundWorkerUserData - : public content::WebContentsUserData<BackgroundWorkerUserData> { - public: - DevToolsBridgeClient* client() const { return client_; } - void SetClient(DevToolsBridgeClient* client) { client_ = client; } - - private: - friend WebContentsUserData<BackgroundWorkerUserData>; - - explicit BackgroundWorkerUserData(WebContents* contents) : client_(nullptr) {} - - DevToolsBridgeClient* client_; -}; - -} // namespace - -DEFINE_WEB_CONTENTS_USER_DATA_KEY(BackgroundWorkerUserData); - -// DevToolsBridgeClient -------------------------------------------------------- - -// static -base::WeakPtr<DevToolsBridgeClient> DevToolsBridgeClient::Create( - Profile* profile, - SigninManagerBase* signin_manager, - ProfileOAuth2TokenService* token_service) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - auto instance = - new DevToolsBridgeClient(profile, signin_manager, token_service); - return instance->weak_factory_.GetWeakPtr(); -} - -DevToolsBridgeClient::DevToolsBridgeClient( - Profile* profile, - SigninManagerBase* signin_manager, - ProfileOAuth2TokenService* token_service) - : WebContentsObserver(), - profile_(profile), - identity_provider_(signin_manager, token_service, base::Closure()), - worker_is_loaded_(false), - weak_factory_(this) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - identity_provider_.AddObserver(this); - registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, - content::Source<Profile>(profile_)); - - if (IsAuthenticated()) - CreateBackgroundWorker(); -} - -DevToolsBridgeClient::~DevToolsBridgeClient() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - identity_provider_.RemoveObserver(this); -} - -void DevToolsBridgeClient::DeleteSelf() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - delete this; -} - -void DevToolsBridgeClient::UpdateBrowserList() { - if (!IsAuthenticated() || browser_list_request_.get()) - return; - browser_list_request_ = CreateGCDApiFlow(); - browser_list_request_->Start( - make_scoped_ptr(new DevToolsBridgeInstancesRequest(this))); -} - -void DevToolsBridgeClient::StartSessionIfNeeded( - const std::string& socket_name) { - if (!background_worker_.get() || !background_worker_->GetWebUI() || - !worker_is_loaded_) { - return; - } - - const size_t kPrefixLength = sizeof(kDeviceIdPrefix) - 1; - if (socket_name.substr(0, kPrefixLength) != kDeviceIdPrefix) - return; - - std::string browser_id = socket_name.substr(kPrefixLength); - background_worker_->GetWebUI()->CallJavascriptFunction( - "WebRTCDeviceProvider.instance.startSessionIfNeeded", - base::StringValue(browser_id)); -} - -// static -DevToolsBridgeClient* DevToolsBridgeClient::FromWebContents( - WebContents* web_contents) { - auto user_data = BackgroundWorkerUserData::FromWebContents(web_contents); - return user_data ? user_data->client() : nullptr; -} - -void DevToolsBridgeClient::RegisterMessageHandlers(content::WebUI* web_ui) { - web_ui->RegisterMessageCallback( - "sendCommand", base::Bind(&DevToolsBridgeClient::HandleSendCommand, - base::Unretained(this))); -} - -bool DevToolsBridgeClient::IsAuthenticated() { - return !identity_provider_.GetActiveAccountId().empty(); -} - -void DevToolsBridgeClient::HandleSendCommand(const base::ListValue* args) { - if (args->GetSize() != 1) - return; - - const base::DictionaryValue* command_value; - if (!args->GetDictionary(0, &command_value)) - return; - - send_command_request_ = CreateGCDApiFlow(); - send_command_request_->Start( - make_scoped_ptr(new SendCommandRequest(command_value, this))); -} - -scoped_ptr<local_discovery::GCDApiFlow> -DevToolsBridgeClient::CreateGCDApiFlow() { - DCHECK(IsAuthenticated()); - return local_discovery::GCDApiFlow::Create( - profile_->GetRequestContext(), identity_provider_.GetTokenService(), - identity_provider_.GetActiveAccountId()); -} - -// static -DevToolsBridgeClient::SerialList DevToolsBridgeClient::GetDevices( - base::WeakPtr<DevToolsBridgeClient> weak_ptr) { - SerialList result; - if (auto* ptr = weak_ptr.get()) { - if (ptr->background_worker_.get()) - result.push_back(kSerial); - - ptr->UpdateBrowserList(); - } - return result; -} - -// static -DevToolsBridgeClient::DeviceInfo DevToolsBridgeClient::GetDeviceInfo( - base::WeakPtr<DevToolsBridgeClient> weak_self, - const std::string& serial) { - DeviceInfo result; - if (auto* self = weak_self.get()) { - result.connected = !!self->background_worker_.get(); - result.model = kPseudoDeviceName; - result.browser_info = self->browsers_; - } - return result; -} - -void DevToolsBridgeClient::CreateBackgroundWorker() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - background_worker_.reset( - WebContents::Create(WebContents::CreateParams(profile_))); - - BackgroundWorkerUserData::CreateForWebContents(background_worker_.get()); - BackgroundWorkerUserData::FromWebContents(background_worker_.get()) - ->SetClient(this); - WebContentsObserver::Observe(background_worker_.get()); - - GURL url(kBackgroundWorkerURL); - DCHECK_EQ(chrome::kChromeUIWebRTCDeviceProviderHost, url.host()); - - background_worker_->GetController().LoadURL(url, content::Referrer(), - ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - std::string()); -} - -void DevToolsBridgeClient::DocumentOnLoadCompletedInMainFrame() { - worker_is_loaded_ = true; -} - -void DevToolsBridgeClient::Observe( - int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); - - delete this; -} - -void DevToolsBridgeClient::OnActiveAccountLogin() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - CreateBackgroundWorker(); -} - -void DevToolsBridgeClient::OnActiveAccountLogout() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - background_worker_.reset(); - browser_list_request_.reset(); - send_command_request_.reset(); - BrowserInfoList().swap(browsers_); - worker_is_loaded_ = false; -} - -void DevToolsBridgeClient::OnCommandSucceeded( - const base::DictionaryValue& response) { - if (background_worker_.get() && background_worker_->GetWebUI()) { - background_worker_->GetWebUI()->CallJavascriptFunction( - "WebRTCDeviceProvider.instance.handleCommandSuccess", response); - } - send_command_request_.reset(); -} - -void DevToolsBridgeClient::OnCommandFailed() { - if (background_worker_.get() && background_worker_->GetWebUI()) { - background_worker_->GetWebUI()->CallJavascriptFunction( - "WebRTCDeviceProvider.instance.handleCommandFailure"); - } - send_command_request_.reset(); -} - -void DevToolsBridgeClient::OnDevToolsBridgeInstancesRequestSucceeded( - const DevToolsBridgeInstancesRequest::InstanceList& instances) { - BrowserInfoList browsers; - for (const auto& instance : instances) { - BrowserInfo browser; - browser.type = BrowserInfo::kTypeChrome; - browser.display_name = instance.display_name; - browser.socket_name = kDeviceIdPrefix + instance.id; - browsers.push_back(browser); - } - browsers_.swap(browsers); - - browser_list_request_.reset(); - - OnBrowserListUpdatedForTests(); -} - -void DevToolsBridgeClient::OnDevToolsBridgeInstancesRequestFailed() { - // We keep the list of remote browsers even if the request failed. - browser_list_request_.reset(); -} diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_client.h b/chrome/browser/devtools/device/webrtc/devtools_bridge_client.h deleted file mode 100644 index f107e2e..0000000 --- a/chrome/browser/devtools/device/webrtc/devtools_bridge_client.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ -#define CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ - -#include "base/macros.h" -#include "chrome/browser/devtools/device/android_device_manager.h" -#include "chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.h" -#include "chrome/browser/devtools/device/webrtc/send_command_request.h" -#include "chrome/browser/local_discovery/cloud_device_list_delegate.h" -#include "components/signin/core/browser/profile_identity_provider.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/web_contents_observer.h" -#include "google_apis/gaia/identity_provider.h" - -class Profile; -class SigninManagerBase; -class ProfileOAuth2TokenService; - -namespace content { -class WebUI; -} // namespace content - -namespace local_discovery { -class GCDApiFlow; -} // local_discovery - -// Lives on the UI thread. -class DevToolsBridgeClient : protected content::WebContentsObserver, - private content::NotificationObserver, - private IdentityProvider::Observer, - private SendCommandRequest::Delegate, - private DevToolsBridgeInstancesRequest::Delegate { - public: - using BrowserInfo = AndroidDeviceManager::BrowserInfo; - using DeviceInfo = AndroidDeviceManager::DeviceInfo; - using SerialList = std::vector<std::string>; - using BrowserInfoList = std::vector<BrowserInfo>; - - static base::WeakPtr<DevToolsBridgeClient> Create( - Profile* profile, - SigninManagerBase* signin_manager, - ProfileOAuth2TokenService* token_service); - - void DeleteSelf(); - - static SerialList GetDevices(base::WeakPtr<DevToolsBridgeClient> weak_ptr); - static DeviceInfo GetDeviceInfo(base::WeakPtr<DevToolsBridgeClient> weak_ptr, - const std::string& serial); - void StartSessionIfNeeded(const std::string& socket_name); - - static DevToolsBridgeClient* FromWebContents( - content::WebContents* web_contents); - void RegisterMessageHandlers(content::WebUI* web_ui); - - protected: - DevToolsBridgeClient(Profile* profile, - SigninManagerBase* signin_manager, - ProfileOAuth2TokenService* token_service); - - // Implementation of content::WebContentsObserver. - void DocumentOnLoadCompletedInMainFrame() override; - - ~DevToolsBridgeClient() override; - - bool IsAuthenticated(); - - // Overridden in tests. - virtual scoped_ptr<local_discovery::GCDApiFlow> CreateGCDApiFlow(); - virtual void OnBrowserListUpdatedForTests() {} - - const BrowserInfoList& browsers() const { return browsers_; } - ProfileIdentityProvider& identity_provider() { return identity_provider_; } - - private: - void CreateBackgroundWorker(); - void UpdateBrowserList(); - - void HandleSendCommand(const base::ListValue* args); - - // Implementation of IdentityProvider::Observer. - void OnActiveAccountLogin() override; - void OnActiveAccountLogout() override; - - // Implementation of NotificationObserver. - void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) override; - - // Implementation of SendCommandRequest::Delegate. - void OnCommandSucceeded(const base::DictionaryValue& response) override; - void OnCommandFailed() override; - - // Implementation of DevToolsBridgeInstancesRequest::Delegate. - void OnDevToolsBridgeInstancesRequestSucceeded( - const DevToolsBridgeInstancesRequest::InstanceList& instances) override; - void OnDevToolsBridgeInstancesRequestFailed() override; - - Profile* const profile_; - ProfileIdentityProvider identity_provider_; - content::NotificationRegistrar registrar_; - scoped_ptr<content::WebContents> background_worker_; - scoped_ptr<local_discovery::GCDApiFlow> browser_list_request_; - scoped_ptr<local_discovery::GCDApiFlow> send_command_request_; - BrowserInfoList browsers_; - bool worker_is_loaded_; - base::WeakPtrFactory<DevToolsBridgeClient> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(DevToolsBridgeClient); -}; - -#endif // CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc b/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc deleted file mode 100644 index 7736644..0000000 --- a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.h" - -#include <utility> - -#include "chrome/browser/devtools/device/webrtc/devtools_bridge_client.h" -#include "chrome/browser/local_discovery/gcd_api_flow.h" -#include "chrome/browser/signin/account_tracker_service_factory.h" -#include "chrome/browser/signin/fake_signin_manager_builder.h" -#include "chrome/browser/ui/browser.h" -#include "components/signin/core/browser/account_tracker_service.h" -#include "components/signin/core/browser/fake_profile_oauth2_token_service.h" -#include "content/public/browser/web_ui_message_handler.h" - -namespace { - -const char kGaiaId[] = "stub-user@example.com"; -const char kUsername[] = "stub-user@example.com"; - -} // namespace - -class DevToolsBridgeClientBrowserTest::GCDApiFlowMock - : public local_discovery::GCDApiFlow { - public: - explicit GCDApiFlowMock(DevToolsBridgeClientBrowserTest* test) - : test_(test), id_(++test->last_flow_id_) { - test_->flows_[id_] = this; - } - - ~GCDApiFlowMock() override { test_->flows_.erase(id_); } - - // Passes request's data to the JS test. Result will be passed back - // in MessageHandler::Response. - void Start(scoped_ptr<Request> request) override { - request_ = std::move(request); - - std::string type; - std::string data; - request_->GetUploadData(&type, &data); - - ScopedVector<const base::Value> params; - params.push_back(new base::FundamentalValue(id_)); - params.push_back(new base::StringValue(request_->GetURL().spec())); - params.push_back(new base::StringValue(data)); - - test_->RunJavascriptFunction("callbacks.gcdApiRequest", params); - } - - void Respond(const base::DictionaryValue* response) { - if (request_.get()) - request_->OnGCDAPIFlowComplete(*response); - } - - private: - DevToolsBridgeClientBrowserTest* const test_; - const int id_; - scoped_ptr<Request> request_; -}; - -class DevToolsBridgeClientBrowserTest::DevToolsBridgeClientMock - : public DevToolsBridgeClient, - public base::SupportsWeakPtr<DevToolsBridgeClientMock> { - public: - explicit DevToolsBridgeClientMock(DevToolsBridgeClientBrowserTest* test) - : DevToolsBridgeClient(test->browser()->profile(), - test->fake_signin_manager_.get(), - test->fake_token_service_.get()), - test_(test) {} - - ~DevToolsBridgeClientMock() override {} - - void DocumentOnLoadCompletedInMainFrame() override { - DevToolsBridgeClient::DocumentOnLoadCompletedInMainFrame(); - - test_->RunJavascriptFunction("callbacks.workerLoaded"); - } - - void OnBrowserListUpdatedForTests() override { - int count = static_cast<int>(browsers().size()); - test_->RunJavascriptFunction("callbacks.browserListUpdated", - new base::FundamentalValue(count)); - } - - scoped_ptr<local_discovery::GCDApiFlow> CreateGCDApiFlow() override { - return make_scoped_ptr(new GCDApiFlowMock(test_)); - } - - void GoogleSigninSucceeded() { - // This username is checked on Chrome OS. - const std::string account_id = - AccountTrackerServiceFactory::GetForProfile( - test_->browser()->profile()) - ->PickAccountIdForAccount(kGaiaId, kUsername); - test_->fake_signin_manager_->SetAuthenticatedAccountInfo(kGaiaId, - kUsername); - identity_provider().GoogleSigninSucceeded(account_id, kUsername, - "password"); - } - - private: - DevToolsBridgeClientBrowserTest* const test_; -}; - -class DevToolsBridgeClientBrowserTest::MessageHandler - : public content::WebUIMessageHandler { - public: - explicit MessageHandler(DevToolsBridgeClientBrowserTest* test) - : test_(test) {} - - void RegisterMessages() override { - web_ui()->RegisterMessageCallback( - "signIn", base::Bind(&MessageHandler::SignIn, base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "gcdApiResponse", - base::Bind(&MessageHandler::GCDApiResponse, base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "queryDevices", - base::Bind(&MessageHandler::QueryDevices, base::Unretained(this))); - } - - void SignIn(const base::ListValue*) { - if (test_->client_mock_.get()) - test_->client_mock_->GoogleSigninSucceeded(); - const std::string account_id = - AccountTrackerServiceFactory::GetForProfile( - test_->browser()->profile())->PickAccountIdForAccount(kGaiaId, - kUsername); - test_->fake_token_service_->UpdateCredentials(account_id, "token"); - } - - void GCDApiResponse(const base::ListValue* params) { - CHECK(params->GetSize() >= 2); - int id; - const base::DictionaryValue* response; - CHECK(params->GetInteger(0, &id)); - CHECK(params->GetDictionary(1, &response)); - - auto flow = test_->flows_.find(id); - CHECK(test_->flows_.end() != flow); - flow->second->Respond(response); - } - - void QueryDevices(const base::ListValue*) { - DevToolsBridgeClient::GetDevices(test_->client_mock_); - } - - private: - DevToolsBridgeClientBrowserTest* const test_; -}; - -DevToolsBridgeClientBrowserTest::DevToolsBridgeClientBrowserTest() - : last_flow_id_(0) { -} - -DevToolsBridgeClientBrowserTest::~DevToolsBridgeClientBrowserTest() { - DCHECK(flows_.empty()); -} - -void DevToolsBridgeClientBrowserTest::SetUpOnMainThread() { - WebUIBrowserTest::SetUpOnMainThread(); - - DCHECK(browser()->profile()); - fake_signin_manager_.reset( - new FakeSigninManagerForTesting(browser()->profile())); - fake_token_service_.reset(new FakeProfileOAuth2TokenService()); - client_mock_ = (new DevToolsBridgeClientMock(this))->AsWeakPtr(); -} - -void DevToolsBridgeClientBrowserTest::TearDownOnMainThread() { - if (client_mock_.get()) - client_mock_->DeleteSelf(); - fake_token_service_.reset(); - fake_signin_manager_.reset(); - WebUIBrowserTest::TearDownOnMainThread(); -} - -content::WebUIMessageHandler* -DevToolsBridgeClientBrowserTest::GetMockMessageHandler() { - if (!handler_.get()) - handler_.reset(new MessageHandler(this)); - return handler_.get(); -} diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.h b/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.h deleted file mode 100644 index bfd5a7d..0000000 --- a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_BROWSERTEST_H_ -#define CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_BROWSERTEST_H_ - -#include "chrome/browser/signin/fake_signin_manager_builder.h" -#include "chrome/test/base/web_ui_browser_test.h" - -class ProfileOAuth2TokenService; - -namespace content { -class WebUIMessageHandler; -} - -class DevToolsBridgeClientBrowserTest : public WebUIBrowserTest { - public: - DevToolsBridgeClientBrowserTest(); - ~DevToolsBridgeClientBrowserTest() override; - - // InProcessBrowserTest overrides. - void SetUpOnMainThread() override; - void TearDownOnMainThread() override; - content::WebUIMessageHandler* GetMockMessageHandler() override; - - private: - class DevToolsBridgeClientMock; - class GCDApiFlowMock; - class MessageHandler; - - scoped_ptr<FakeSigninManagerForTesting> fake_signin_manager_; - scoped_ptr<ProfileOAuth2TokenService> fake_token_service_; - base::WeakPtr<DevToolsBridgeClientMock> client_mock_; - scoped_ptr<MessageHandler> handler_; - std::map<int, GCDApiFlowMock*> flows_; - int last_flow_id_; -}; - -#endif // CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_BROWSERTEST_H_ diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js b/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js deleted file mode 100644 index dbb6738..0000000 --- a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -GEN('#include "chrome/browser/devtools/device/webrtc/' + - 'devtools_bridge_client_browsertest.h"'); - -/** - * Test fixture for DevToolsBridgeClientBrowserTest. - * @constructor - * @extends {testing.Test} - */ -function DevToolsBridgeClientBrowserTest() {} - -var DEVICES_URL = "https://www.googleapis.com/clouddevices/v1/devices"; - -DevToolsBridgeClientBrowserTest.prototype = { - __proto__: testing.Test.prototype, - - /** @override */ - typedefCppFixture: 'DevToolsBridgeClientBrowserTest', - - /** @override */ - isAsync: true, - - /** @override */ - browsePreload: DUMMY_URL, - - setUp: function() { - this.callbacksMock = mock(DevToolsBridgeClientBrowserTest.NativeCallbacks); - window.callbacks = this.callbacksMock.proxy(); - }, - - /** - * Simulates user sign in. DevToolsBridgeClient creates - * background_worker only in this case. - */ - signIn: function() { - chrome.send('signIn', []); - return new Promise(function(resolve) { - this.callbacksMock.expects(once()).workerLoaded().will( - callFunction(resolve)); - }.bind(this)); - }, - - /** - * Creates GCD device definition which could be recognized as a - * DevToolsBridge. - * - * @param {string} id GCD instance id. - * @param {string} displayName Display name. - */ - createInstanceDef: function(id, displayName) { - return { - 'kind': 'clouddevices#device', - 'deviceKind': 'vendor', - 'id': id, - 'displayName': displayName, - 'commandDefs': { - 'base': { - '_iceExchange': {'kind': 'clouddevices#commandDef'}, - '_renegotiate': {'kind': 'clouddevices#commandDef'}, - '_startSession': {'kind': 'clouddevices#commandDef'}, - } - }, - }; - } -}; - -/** - * Callbacks from native DevToolsBridgeClientBrowserTest. - * @constructor - */ -DevToolsBridgeClientBrowserTest.NativeCallbacks = function() {} - -DevToolsBridgeClientBrowserTest.NativeCallbacks.prototype = { - workerLoaded: function() {}, - gcdApiRequest: function(id, body) {}, - browserListUpdated: function(count) {}, -}; - -TEST_F('DevToolsBridgeClientBrowserTest', 'testSetUpOnMainThread', function() { - testDone(); -}); - -TEST_F('DevToolsBridgeClientBrowserTest', 'testSignIn', function() { - this.signIn().then(testDone); -}); - -TEST_F('DevToolsBridgeClientBrowserTest', 'testQueryBrowsers', function() { - this.signIn().then(function() { - chrome.send('queryDevices'); - }); - var savedArgs = new SaveMockArguments(); - this.callbacksMock.expects(once()).gcdApiRequest( - savedArgs.match(ANYTHING), DEVICES_URL, '').will( - callFunctionWithSavedArgs(savedArgs, function(id) { - var response = { - 'kind': 'clouddevices#devicesListResponse', - 'devices': [ - this.createInstanceDef( - 'ab911465-83c7-e335-ea64-cb656868cbe0', 'Test 1'), - this.createInstanceDef( - 'ab911465-83c7-e335-ea64-cb656868cbe1', 'Test 2'), - this.createInstanceDef( - 'ab911465-83c7-e335-ea64-cb656868cbe2', 'Test 3'), - ], - }; - chrome.send('gcdApiResponse', [id, response]); - }.bind(this))); - - var browsersCount = 3; - - this.callbacksMock.expects(once()).browserListUpdated(browsersCount).will( - callFunction(testDone)); -}); diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.cc b/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.cc deleted file mode 100644 index 1ddf6e6..0000000 --- a/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.h" - -#include "base/values.h" -#include "components/cloud_devices/common/cloud_devices_urls.h" -#include "net/base/url_util.h" - -namespace { - -std::string GetKind(const base::DictionaryValue& value) { - std::string result; - value.GetString("kind", &result); - return result; -} - -bool HasCommand(const base::DictionaryValue& commands_defs_value, - const std::string& command_name) { - const base::DictionaryValue* command_value; - return commands_defs_value.GetDictionary(command_name, &command_value) && - GetKind(*command_value) == "clouddevices#commandDef"; -} - -} // namespace - -DevToolsBridgeInstancesRequest::Instance::~Instance() { -} - -DevToolsBridgeInstancesRequest::DevToolsBridgeInstancesRequest( - Delegate* delegate) - : delegate_(delegate) { - DCHECK(delegate_); -} - -DevToolsBridgeInstancesRequest::~DevToolsBridgeInstancesRequest() { -} - -void DevToolsBridgeInstancesRequest::OnGCDAPIFlowError( - local_discovery::GCDApiFlow::Status status) { - delegate_->OnDevToolsBridgeInstancesRequestFailed(); -} - -void DevToolsBridgeInstancesRequest::OnGCDAPIFlowComplete( - const base::DictionaryValue& value) { - const base::ListValue* device_list_value = NULL; - if (GetKind(value) == "clouddevices#devicesListResponse" && - value.GetList("devices", &device_list_value)) { - for (const auto& device_value : *device_list_value) { - const base::DictionaryValue* dictionary; - if (device_value->GetAsDictionary(&dictionary)) - TryAddInstance(*dictionary); - } - } - - delegate_->OnDevToolsBridgeInstancesRequestSucceeded(result_); -} - -GURL DevToolsBridgeInstancesRequest::GetURL() { - return cloud_devices::GetCloudDevicesRelativeURL("devices"); -} - -void DevToolsBridgeInstancesRequest::TryAddInstance( - const base::DictionaryValue& device_value) { - if (GetKind(device_value) != "clouddevices#device") - return; - - const base::DictionaryValue* commands_defs_value; - if (!device_value.GetDictionary("commandDefs", &commands_defs_value)) - return; - - if (!HasCommand(*commands_defs_value, "base._startSession") || - !HasCommand(*commands_defs_value, "base._iceExchange") || - !HasCommand(*commands_defs_value, "base._renegotiate")) { - return; - } - - Instance instance; - if (!device_value.GetString("id", &instance.id)) - return; - if (!device_value.GetString("displayName", &instance.display_name)) - return; - - result_.push_back(instance); -} diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.h b/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.h deleted file mode 100644 index 3763b7e..0000000 --- a/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_INSTANCES_REQUEST_H_ -#define CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_INSTANCES_REQUEST_H_ - -#include "base/macros.h" -#include "chrome/browser/devtools/device/android_device_manager.h" -#include "chrome/browser/local_discovery/gcd_api_flow.h" - -class DevToolsBridgeInstancesRequest - : public local_discovery::GCDApiFlowRequest { - public: - struct Instance { - std::string id; - std::string display_name; - - ~Instance(); - }; - - using InstanceList = std::vector<Instance>; - - class Delegate { - public: - virtual void OnDevToolsBridgeInstancesRequestSucceeded( - const InstanceList& result) = 0; - virtual void OnDevToolsBridgeInstancesRequestFailed() = 0; - - protected: - ~Delegate() {} - }; - - explicit DevToolsBridgeInstancesRequest(Delegate* delegate); - ~DevToolsBridgeInstancesRequest() override; - - // Implementation of GCDApiFlowRequest. - void OnGCDAPIFlowError(local_discovery::GCDApiFlow::Status status) override; - void OnGCDAPIFlowComplete(const base::DictionaryValue& value) override; - GURL GetURL() override; - - private: - void TryAddInstance(const base::DictionaryValue& device_value); - - Delegate* const delegate_; - InstanceList result_; - - DISALLOW_COPY_AND_ASSIGN(DevToolsBridgeInstancesRequest); -}; - -#endif // CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_INSTANCES_REQUEST_H_ diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request_unittest.cc b/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request_unittest.cc deleted file mode 100644 index 3b9710f..0000000 --- a/chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request_unittest.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/devtools/device/webrtc/devtools_bridge_instances_request.h" - -#include "base/files/file_util.h" -#include "base/json/json_reader.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/path_service.h" -#include "base/values.h" -#include "chrome/common/chrome_paths.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -class MockDelegate : public DevToolsBridgeInstancesRequest::Delegate { - public: - DevToolsBridgeInstancesRequest::InstanceList instances; - - void OnDevToolsBridgeInstancesRequestSucceeded( - const DevToolsBridgeInstancesRequest::InstanceList& result) override { - instances = result; - } - - void OnDevToolsBridgeInstancesRequestFailed() override {} -}; - -base::FilePath GetTestFilePath(const std::string& file_name) { - base::FilePath path; - if (!PathService::Get(chrome::DIR_TEST_DATA, &path)) - return base::FilePath(); - return path.AppendASCII("devtools") - .AppendASCII("webrtc_device_provider") - .AppendASCII(file_name); -} - -} // namespace - -TEST(DevToolsBridgeInstancesRequestTest, ParseResponse) { - std::string input; - ASSERT_TRUE(base::ReadFileToString( - GetTestFilePath("devtools_bridge_instances_response.json"), &input)); - base::JSONReader reader; - scoped_ptr<base::Value> root(reader.ReadToValue(input)); - ASSERT_TRUE(root.get()) << reader.GetErrorMessage(); - EXPECT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); - - const base::DictionaryValue* dictionary = NULL; - ASSERT_TRUE(root->GetAsDictionary(&dictionary)); - - MockDelegate delegate; - - delegate.instances.resize(10); - - DevToolsBridgeInstancesRequest(&delegate).OnGCDAPIFlowComplete(*dictionary); - - ASSERT_TRUE(delegate.instances.size() == 1); - ASSERT_EQ("ab911465-83c7-e335-ea64-cb656868cbe0", delegate.instances[0].id); -} diff --git a/chrome/browser/devtools/device/webrtc/js/webrtc_device_provider.js b/chrome/browser/devtools/device/webrtc/js/webrtc_device_provider.js deleted file mode 100644 index a9e67fe..0000000 --- a/chrome/browser/devtools/device/webrtc/js/webrtc_device_provider.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * @constructor - */ -function WebRTCDeviceProvider() { -} - -WebRTCDeviceProvider.prototype.handleCommandFailure = function() { - // TODO(serya): Remove debugging code and implement. - console.error('Command failed'); -}; - -WebRTCDeviceProvider.prototype.handleCommandSuccess = function(result) { - // TODO(serya): Remove debugging code and implement. - console.log('Command succeded', result); -}; - -WebRTCDeviceProvider.prototype.startSessionIfNeeded = function(deviceId) { - // TODO(serya): Remove debugging code and implement. - this.lastDeviceId = deviceId; -}; - -addEventListener('DOMContentLoaded', function() { - window.WebRTCDeviceProvider.instance = new WebRTCDeviceProvider(); -}, false); diff --git a/chrome/browser/devtools/device/webrtc/resources.grd b/chrome/browser/devtools/device/webrtc/resources.grd deleted file mode 100644 index 01524333..0000000 --- a/chrome/browser/devtools/device/webrtc/resources.grd +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<grit latest_public_release="0" current_release="1"> - <outputs> - <output filename="grit/webrtc_device_provider_resources.h" type="rc_header"> - <emit emit_type='prepend'></emit> - </output> - <output filename="grit/webrtc_device_provider_resources_map.cc" type="resource_file_map_source" /> - <output filename="grit/webrtc_device_provider_resources_map.h" type="resource_map_header" /> - <output filename="webrtc_device_provider_resources.pak" type="data_package" /> - </outputs> - <release seq="1"> - <includes> - <include name="IDR_BACKGROUND_WORKER_HTML" file="background_worker.html" flattenhtml="false" allowexternalscript="true" type="BINDATA" /> - <include name="IDR_WEBRTC_DEVICE_PROVIDER_JS" file="js/webrtc_device_provider.js" type="BINDATA" /> - </includes> - </release> -</grit> diff --git a/chrome/browser/devtools/device/webrtc/send_command_request.cc b/chrome/browser/devtools/device/webrtc/send_command_request.cc deleted file mode 100644 index 7bfe5f4..0000000 --- a/chrome/browser/devtools/device/webrtc/send_command_request.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/devtools/device/webrtc/send_command_request.h" - -#include "base/json/json_writer.h" -#include "base/values.h" -#include "components/cloud_devices/common/cloud_devices_urls.h" -#include "net/base/url_util.h" - -using local_discovery::GCDApiFlow; -using local_discovery::GCDApiFlowRequest; - -namespace { - -const char kContentTypeJSON[] = "application/json"; -const char kCommandTimeoutMs[] = "20000"; - -} // namespace - -SendCommandRequest::SendCommandRequest(const base::DictionaryValue* request, - Delegate* delegate) - : delegate_(delegate) { - base::JSONWriter::Write(*request, &upload_data_); - DCHECK(delegate_); -} - -net::URLFetcher::RequestType SendCommandRequest::GetRequestType() { - return net::URLFetcher::POST; -} - -void SendCommandRequest::GetUploadData(std::string* upload_type, - std::string* upload_data) { - *upload_type = kContentTypeJSON; - *upload_data = upload_data_; -} - -void SendCommandRequest::OnGCDAPIFlowError(GCDApiFlow::Status status) { - delegate_->OnCommandFailed(); -} - -void SendCommandRequest::OnGCDAPIFlowComplete( - const base::DictionaryValue& value) { - delegate_->OnCommandSucceeded(value); -} - -GURL SendCommandRequest::GetURL() { - GURL url = cloud_devices::GetCloudDevicesRelativeURL("commands"); - url = net::AppendQueryParameter(url, "expireInMs", kCommandTimeoutMs); - url = net::AppendQueryParameter(url, "responseAwaitMs", kCommandTimeoutMs); - return url; -} diff --git a/chrome/browser/devtools/device/webrtc/send_command_request.h b/chrome/browser/devtools/device/webrtc/send_command_request.h deleted file mode 100644 index 045dd7c..0000000 --- a/chrome/browser/devtools/device/webrtc/send_command_request.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_SEND_COMMAND_REQUEST_H_ -#define CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_SEND_COMMAND_REQUEST_H_ - -#include "base/macros.h" -#include "chrome/browser/local_discovery/gcd_api_flow.h" - -class SendCommandRequest : public local_discovery::GCDApiFlowRequest { - public: - class Delegate { - public: - // It's safe to destroy SendCommandRequest in these methods. - virtual void OnCommandSucceeded(const base::DictionaryValue& value) = 0; - virtual void OnCommandFailed() = 0; - - protected: - ~Delegate() {} - }; - - SendCommandRequest(const base::DictionaryValue* request, Delegate* delegate); - - // Implementation of GCDApiFlowRequest. - net::URLFetcher::RequestType GetRequestType() override; - void GetUploadData(std::string* upload_type, - std::string* upload_data) override; - void OnGCDAPIFlowError(local_discovery::GCDApiFlow::Status status) override; - void OnGCDAPIFlowComplete(const base::DictionaryValue& value) override; - GURL GetURL() override; - - private: - std::string upload_data_; - Delegate* const delegate_; - - DISALLOW_COPY_AND_ASSIGN(SendCommandRequest); -}; - -#endif // CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_SEND_COMMAND_REQUEST_H_ diff --git a/chrome/browser/devtools/device/webrtc/webrtc_device_provider.cc b/chrome/browser/devtools/device/webrtc/webrtc_device_provider.cc deleted file mode 100644 index ec49e2e..0000000 --- a/chrome/browser/devtools/device/webrtc/webrtc_device_provider.cc +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/devtools/device/webrtc/webrtc_device_provider.h" - -#include <stddef.h> - -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" -#include "chrome/browser/devtools/device/webrtc/devtools_bridge_client.h" -#include "chrome/common/url_constants.h" -#include "content/public/browser/web_ui.h" -#include "content/public/browser/web_ui_data_source.h" -#include "grit/webrtc_device_provider_resources_map.h" -#include "net/base/net_errors.h" -#include "net/socket/stream_socket.h" - -using content::BrowserThread; -using content::WebUIDataSource; - -// WebRTCDeviceProvider::WebUI ------------------------------------------------- - -WebRTCDeviceProvider::WebUI::WebUI(content::WebUI* web_ui) - : content::WebUIController(web_ui) { - Profile* profile = Profile::FromWebUI(web_ui); - - WebUIDataSource* source = WebUIDataSource::Create( - chrome::kChromeUIWebRTCDeviceProviderHost); - - for (size_t i = 0; i < kWebrtcDeviceProviderResourcesSize; i++) { - source->AddResourcePath(kWebrtcDeviceProviderResources[i].name, - kWebrtcDeviceProviderResources[i].value); - } - - auto client = - DevToolsBridgeClient::FromWebContents(web_ui->GetWebContents()); - if (client) - client->RegisterMessageHandlers(web_ui); - - WebUIDataSource::Add(profile, source); -} - -WebRTCDeviceProvider::WebUI::~WebUI() { -} - -// WebRTCDeviceProvider -------------------------------------------------------- - -WebRTCDeviceProvider::WebRTCDeviceProvider( - Profile* profile, - SigninManagerBase* signin_manager, - ProfileOAuth2TokenService* token_service) - : client_(DevToolsBridgeClient::Create( - profile, signin_manager, token_service)) { -} - -WebRTCDeviceProvider::~WebRTCDeviceProvider() { - BrowserThread::PostTask( - BrowserThread::UI, - FROM_HERE, - base::Bind(&DevToolsBridgeClient::DeleteSelf, client_)); -} - -void WebRTCDeviceProvider::QueryDevices(const SerialsCallback& callback) { - BrowserThread::PostTaskAndReplyWithResult( - BrowserThread::UI, - FROM_HERE, - base::Bind(&DevToolsBridgeClient::GetDevices, client_), - callback); -} - -void WebRTCDeviceProvider::QueryDeviceInfo(const std::string& serial, - const DeviceInfoCallback& callback) { - BrowserThread::PostTaskAndReplyWithResult( - BrowserThread::UI, - FROM_HERE, - base::Bind(&DevToolsBridgeClient::GetDeviceInfo, client_, serial), - callback); -} - -void WebRTCDeviceProvider::OpenSocket(const std::string& serial, - const std::string& socket_name, - const SocketCallback& callback) { - BrowserThread::PostTask( - BrowserThread::UI, - FROM_HERE, - base::Bind(&DevToolsBridgeClient::StartSessionIfNeeded, - client_, socket_name)); - // TODO(serya): Implement - scoped_ptr<net::StreamSocket> socket; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(callback, net::ERR_FAILED, base::Passed(&socket))); -} diff --git a/chrome/browser/devtools/device/webrtc/webrtc_device_provider.h b/chrome/browser/devtools/device/webrtc/webrtc_device_provider.h deleted file mode 100644 index 0663fe9..0000000 --- a/chrome/browser/devtools/device/webrtc/webrtc_device_provider.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_WEBRTC_DEVICE_PROVIDER_H_ -#define CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_WEBRTC_DEVICE_PROVIDER_H_ - -#include "base/macros.h" -#include "chrome/browser/devtools/device/android_device_manager.h" -#include "content/public/browser/web_ui_controller.h" - -namespace content { -class WebUI; -} - -class DevToolsBridgeClient; -class OAuth2TokenService; -class Profile; -class ProfileOAuth2TokenService; -class SigninManagerBase; - -// Provides access to remote DevTools targets over WebRTC data channel and GCD. -class WebRTCDeviceProvider final : public AndroidDeviceManager::DeviceProvider { - public: - /** - * Provides resources for provider's background worker. Background worker - * is a windowless page that implements most of functionality of the - * provider. It sandboxes WebRTC connections with remote devices and other - * provider implementation details. - */ - class WebUI : public content::WebUIController { - public: - explicit WebUI(content::WebUI* web_ui); - ~WebUI() override; - }; - - WebRTCDeviceProvider(Profile* profile, - SigninManagerBase* signin_manager, - ProfileOAuth2TokenService* token_service); - - // AndroidDeviceManager::DeviceProvider implementation. - void QueryDevices(const SerialsCallback& callback) override; - - void QueryDeviceInfo(const std::string& serial, - const DeviceInfoCallback& callback) override; - - void OpenSocket(const std::string& serial, - const std::string& socket_name, - const SocketCallback& callback) override; - - private: - ~WebRTCDeviceProvider() override; - - const base::WeakPtr<DevToolsBridgeClient> client_; - - DISALLOW_COPY_AND_ASSIGN(WebRTCDeviceProvider); -}; - -#endif // CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_WEBRTC_DEVICE_PROVIDER_H_ diff --git a/chrome/browser/devtools/device/webrtc/webrtc_device_provider_browsertest.cc b/chrome/browser/devtools/device/webrtc/webrtc_device_provider_browsertest.cc deleted file mode 100644 index 3b461ff..0000000 --- a/chrome/browser/devtools/device/webrtc/webrtc_device_provider_browsertest.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/bind.h" -#include "chrome/browser/devtools/device/webrtc/webrtc_device_provider.h" -#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" -#include "chrome/browser/signin/signin_manager_factory.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "components/signin/core/browser/signin_manager.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/test/test_utils.h" - -using content::BrowserThread; -using content::MessageLoopRunner; - -class WebRtcDeviceProviderTest : public InProcessBrowserTest { - protected: - scoped_refptr<WebRTCDeviceProvider> CreateProvider(); - static void Unreference( - scoped_refptr<WebRTCDeviceProvider> provider); - - scoped_refptr<WebRTCDeviceProvider> provider_; -}; - -scoped_refptr<WebRTCDeviceProvider> -WebRtcDeviceProviderTest::CreateProvider() { - return new WebRTCDeviceProvider( - browser()->profile(), - SigninManagerFactory::GetForProfile(browser()->profile()), - ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile())); -} - -// static -void WebRtcDeviceProviderTest::Unreference( - scoped_refptr<WebRTCDeviceProvider> provider) { -} - -IN_PROC_BROWSER_TEST_F(WebRtcDeviceProviderTest, TestDeleteSelf) { - scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; - BrowserThread::PostTaskAndReply( - BrowserThread::IO, - FROM_HERE, - base::Bind(&Unreference, CreateProvider()), - runner->QuitClosure()); - runner->Run(); -} - -IN_PROC_BROWSER_TEST_F(WebRtcDeviceProviderTest, OutliveProfile) { - provider_ = CreateProvider(); -} diff --git a/chrome/browser/devtools/webrtc_device_provider_resources.gyp b/chrome/browser/devtools/webrtc_device_provider_resources.gyp deleted file mode 100644 index 35d645f..0000000 --- a/chrome/browser/devtools/webrtc_device_provider_resources.gyp +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'targets': [ - { - # GN version: //chrome/browser/devtools:webrtc_device_provider_resources - 'target_name': 'webrtc_device_provider_resources', - 'type': 'none', - 'variables': { - 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome', - }, - 'actions': [ - { - 'action_name': 'generate_webrtc_device_provider_resources', - 'variables': { - 'grit_grd_file': 'device/webrtc/resources.grd', - }, - 'includes': [ '../../../build/grit_action.gypi' ], - }, - ], - 'includes': [ '../../../build/grit_target.gypi' ], - }, - ] -} diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 2689679..6dfad8b 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -115,7 +115,6 @@ #if defined(OS_ANDROID) || defined(OS_IOS) #include "chrome/browser/ui/webui/net_export_ui.h" #else -#include "chrome/browser/devtools/device/webrtc/webrtc_device_provider.h" #include "chrome/browser/signin/easy_unlock_service.h" #include "chrome/browser/signin/easy_unlock_service_factory.h" #include "chrome/browser/ui/webui/copresence_ui.h" @@ -504,8 +503,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, return &NewWebUI<InlineLoginUI>; if (url.SchemeIs(content::kChromeDevToolsScheme)) return &NewWebUI<DevToolsUI>; - if (url.host() == chrome::kChromeUIWebRTCDeviceProviderHost) - return &NewWebUI<WebRTCDeviceProvider::WebUI>; // chrome://inspect isn't supported on Android nor iOS. Page debugging is // handled by a remote devtools on the host machine, and other elements, i.e. diff --git a/chrome/chrome_debugger.gypi b/chrome/chrome_debugger.gypi index fd98495..cf38e6a 100644 --- a/chrome/chrome_debugger.gypi +++ b/chrome/chrome_debugger.gypi @@ -13,7 +13,6 @@ '../base/base.gyp:base', '../content/content.gyp:content_browser', '../net/net.gyp:net', - 'browser/devtools/webrtc_device_provider_resources.gyp:webrtc_device_provider_resources', 'browser/devtools/devtools_protocol_constants.gyp:devtools_protocol_constants', 'chrome_features.gyp:chrome_common_features', ], @@ -62,8 +61,6 @@ 'common/extensions/api/api.gyp:chrome_api', ], 'sources': [ - '<(SHARED_INTERMEDIATE_DIR)/chrome/grit/webrtc_device_provider_resources_map.cc', - '<(SHARED_INTERMEDIATE_DIR)/chrome/grit/webrtc_device_provider_resources_map.h', 'browser/devtools/chrome_devtools_discovery_provider.cc', 'browser/devtools/chrome_devtools_discovery_provider.h', 'browser/devtools/device/adb/adb_client_socket.cc', @@ -90,14 +87,6 @@ 'browser/devtools/device/usb/android_usb_socket.h', 'browser/devtools/device/usb/usb_device_provider.cc', 'browser/devtools/device/usb/usb_device_provider.h', - 'browser/devtools/device/webrtc/devtools_bridge_client.cc', - 'browser/devtools/device/webrtc/devtools_bridge_client.h', - 'browser/devtools/device/webrtc/devtools_bridge_instances_request.cc', - 'browser/devtools/device/webrtc/devtools_bridge_instances_request.h', - 'browser/devtools/device/webrtc/send_command_request.cc', - 'browser/devtools/device/webrtc/send_command_request.h', - 'browser/devtools/device/webrtc/webrtc_device_provider.cc', - 'browser/devtools/device/webrtc/webrtc_device_provider.h', 'browser/devtools/devtools_contents_resizing_strategy.cc', 'browser/devtools/devtools_contents_resizing_strategy.h', 'browser/devtools/devtools_embedder_message_dispatcher.cc', diff --git a/chrome/chrome_repack_resources.gypi b/chrome/chrome_repack_resources.gypi index 4668372..94cad45 100644 --- a/chrome/chrome_repack_resources.gypi +++ b/chrome/chrome_repack_resources.gypi @@ -53,7 +53,6 @@ '<(grit_out_dir)/quota_internals_resources.pak', '<(grit_out_dir)/settings_resources.pak', '<(grit_out_dir)/sync_file_system_internals_resources.pak', - '<(grit_out_dir)/webrtc_device_provider_resources.pak', ], }], ['enable_extensions==1', { diff --git a/chrome/chrome_resources.gyp b/chrome/chrome_resources.gyp index e501c72..d78b04f 100644 --- a/chrome/chrome_resources.gyp +++ b/chrome/chrome_resources.gyp @@ -85,7 +85,6 @@ '../components/components_resources.gyp:components_resources', '../content/browser/devtools/devtools_resources.gyp:devtools_resources', '../content/browser/tracing/tracing_resources.gyp:tracing_resources', - 'browser/devtools/webrtc_device_provider_resources.gyp:webrtc_device_provider_resources', ], 'actions': [ { diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index a11a90e..8c47293 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -97,9 +97,6 @@ 'browser/devtools/device/adb/mock_adb_server.h', 'browser/devtools/device/port_forwarding_browsertest.cc', 'browser/devtools/device/usb/android_usb_browsertest.cc', - 'browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc', - 'browser/devtools/device/webrtc/devtools_bridge_client_browsertest.h', - 'browser/devtools/device/webrtc/webrtc_device_provider_browsertest.cc', 'browser/devtools/devtools_sanity_browsertest.cc', 'browser/devtools/devtools_window_testing.cc', 'browser/devtools/devtools_window_testing.h', @@ -922,7 +919,6 @@ # and are handled by a rule, but in the GN build they're in a separate # action so need to be separated out. 'chrome_browser_tests_webui_js_sources': [ - 'browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js', 'browser/ui/webui/app_list/start_page_browsertest.js', 'browser/ui/webui/chromeos/bluetooth_pairing_ui_browsertest.js', 'browser/ui/webui/chromeos/certificate_manager_dialog_browsertest.js', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 3764b24..1a9f2ff 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -86,7 +86,6 @@ 'browser/data_usage/tab_id_annotator_unittest.cc', 'browser/data_usage/tab_id_provider_unittest.cc', 'browser/devtools/device/cast_device_provider_unittest.cc', - 'browser/devtools/device/webrtc/devtools_bridge_instances_request_unittest.cc', 'browser/devtools/devtools_network_controller_unittest.cc', 'browser/download/all_download_item_notifier_unittest.cc', 'browser/download/chrome_download_manager_delegate_unittest.cc', @@ -2732,7 +2731,6 @@ ['OS=="android" or OS=="ios"', { 'sources!': [ 'browser/devtools/device/cast_device_provider_unittest.cc', - 'browser/devtools/device/webrtc/devtools_bridge_instances_request_unittest.cc', 'browser/ui/bookmarks/bookmark_ui_utils_desktop_unittest.cc', 'browser/ui/sync/sync_promo_ui_unittest.cc', ], diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 7c72273..3f81c2e 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -252,8 +252,6 @@ const char kChromeUIUberFrameHost[] = "uber-frame"; const char kChromeUIUberHost[] = "chrome"; const char kChromeUIUserActionsHost[] = "user-actions"; const char kChromeUIVersionHost[] = "version"; -const char kChromeUIWebRTCDeviceProviderHost[] = - "webrtc-device-provider"; const char kChromeUIWorkersHost[] = "workers"; const char kChromeUIThemePath[] = "theme"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 805a75a..fc35006 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -239,7 +239,6 @@ extern const char kChromeUIUberFrameHost[]; extern const char kChromeUIUberHost[]; extern const char kChromeUIUserActionsHost[]; extern const char kChromeUIVersionHost[]; -extern const char kChromeUIWebRTCDeviceProviderHost[]; extern const char kChromeUIWorkersHost[]; extern const char kChromeUIThemePath[]; diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index e3eb827..cd0146f 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn @@ -2037,7 +2037,6 @@ test("unit_tests") { if (is_android || is_ios) { sources -= [ "../browser/devtools/device/cast_device_provider_unittest.cc", - "../browser/devtools/device/webrtc/devtools_bridge_instances_request_unittest.cc", "../browser/ui/bookmarks/bookmark_ui_utils_desktop_unittest.cc", "../browser/ui/sync/sync_promo_ui_unittest.cc", ] diff --git a/tools/gritsettings/resource_ids b/tools/gritsettings/resource_ids index 93949e3..9324518 100644 --- a/tools/gritsettings/resource_ids +++ b/tools/gritsettings/resource_ids @@ -298,9 +298,6 @@ "includes": [30370], "structures": [30670], }, - "chrome/browser/devtools/device/webrtc/resources.grd": { - "includes": [30820], - }, "chrome/browser/resources/md_policy/policy_resources.grd": { "structures": [30900], }, |