Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1293253002: Connect WebUSB client interface to the devices app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix memory leak in WeakBindingSet Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/usb/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 #include "content/renderer/stats_collection_controller.h" 108 #include "content/renderer/stats_collection_controller.h"
109 #include "content/renderer/web_ui_extension.h" 109 #include "content/renderer/web_ui_extension.h"
110 #include "content/renderer/websharedworker_proxy.h" 110 #include "content/renderer/websharedworker_proxy.h"
111 #include "gin/modules/module_registry.h" 111 #include "gin/modules/module_registry.h"
112 #include "media/base/audio_renderer_mixer_input.h" 112 #include "media/base/audio_renderer_mixer_input.h"
113 #include "media/base/media_log.h" 113 #include "media/base/media_log.h"
114 #include "media/blink/webencryptedmediaclient_impl.h" 114 #include "media/blink/webencryptedmediaclient_impl.h"
115 #include "media/blink/webmediaplayer_impl.h" 115 #include "media/blink/webmediaplayer_impl.h"
116 #include "media/blink/webmediaplayer_params.h" 116 #include "media/blink/webmediaplayer_params.h"
117 #include "media/renderers/gpu_video_accelerator_factories.h" 117 #include "media/renderers/gpu_video_accelerator_factories.h"
118 #include "mojo/common/url_type_converters.h"
118 #include "net/base/data_url.h" 119 #include "net/base/data_url.h"
119 #include "net/base/net_errors.h" 120 #include "net/base/net_errors.h"
120 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 121 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
121 #include "net/http/http_util.h" 122 #include "net/http/http_util.h"
122 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" 123 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h"
123 #include "third_party/WebKit/public/platform/WebString.h" 124 #include "third_party/WebKit/public/platform/WebString.h"
124 #include "third_party/WebKit/public/platform/WebURL.h" 125 #include "third_party/WebKit/public/platform/WebURL.h"
125 #include "third_party/WebKit/public/platform/WebURLError.h" 126 #include "third_party/WebKit/public/platform/WebURLError.h"
126 #include "third_party/WebKit/public/platform/WebURLResponse.h" 127 #include "third_party/WebKit/public/platform/WebURLResponse.h"
127 #include "third_party/WebKit/public/platform/WebVector.h" 128 #include "third_party/WebKit/public/platform/WebVector.h"
129 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h"
128 #include "third_party/WebKit/public/web/WebColorSuggestion.h" 130 #include "third_party/WebKit/public/web/WebColorSuggestion.h"
129 #include "third_party/WebKit/public/web/WebDocument.h" 131 #include "third_party/WebKit/public/web/WebDocument.h"
130 #include "third_party/WebKit/public/web/WebFrameWidget.h" 132 #include "third_party/WebKit/public/web/WebFrameWidget.h"
131 #include "third_party/WebKit/public/web/WebGlyphCache.h" 133 #include "third_party/WebKit/public/web/WebGlyphCache.h"
132 #include "third_party/WebKit/public/web/WebKit.h" 134 #include "third_party/WebKit/public/web/WebKit.h"
133 #include "third_party/WebKit/public/web/WebLocalFrame.h" 135 #include "third_party/WebKit/public/web/WebLocalFrame.h"
134 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" 136 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h"
135 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" 137 #include "third_party/WebKit/public/web/WebNavigationPolicy.h"
136 #include "third_party/WebKit/public/web/WebPlugin.h" 138 #include "third_party/WebKit/public/web/WebPlugin.h"
137 #include "third_party/WebKit/public/web/WebPluginParams.h" 139 #include "third_party/WebKit/public/web/WebPluginParams.h"
(...skipping 29 matching lines...) Expand all
167 #include <cpu-features.h> 169 #include <cpu-features.h>
168 170
169 #include "content/common/gpu/client/context_provider_command_buffer.h" 171 #include "content/common/gpu/client/context_provider_command_buffer.h"
170 #include "content/renderer/android/synchronous_compositor_factory.h" 172 #include "content/renderer/android/synchronous_compositor_factory.h"
171 #include "content/renderer/java/gin_java_bridge_dispatcher.h" 173 #include "content/renderer/java/gin_java_bridge_dispatcher.h"
172 #include "content/renderer/media/android/renderer_media_player_manager.h" 174 #include "content/renderer/media/android/renderer_media_player_manager.h"
173 #include "content/renderer/media/android/stream_texture_factory_impl.h" 175 #include "content/renderer/media/android/stream_texture_factory_impl.h"
174 #include "content/renderer/media/android/webmediaplayer_android.h" 176 #include "content/renderer/media/android/webmediaplayer_android.h"
175 #else 177 #else
176 #include "cc/blink/context_provider_web_context.h" 178 #include "cc/blink/context_provider_web_context.h"
179 #include "content/renderer/usb/web_usb_client_impl.h"
180 #include "device/devices_app/public/cpp/constants.h"
177 #endif 181 #endif
178 182
179 #if defined(ENABLE_PEPPER_CDMS) 183 #if defined(ENABLE_PEPPER_CDMS)
180 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" 184 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h"
181 #elif defined(ENABLE_BROWSER_CDMS) 185 #elif defined(ENABLE_BROWSER_CDMS)
182 #include "content/renderer/media/crypto/renderer_cdm_manager.h" 186 #include "content/renderer/media/crypto/renderer_cdm_manager.h"
183 #endif 187 #endif
184 188
185 #if defined(ENABLE_MOJO_MEDIA) 189 #if defined(ENABLE_MOJO_MEDIA)
186 #include "media/mojo/services/mojo_cdm_factory.h" 190 #include "media/mojo/services/mojo_cdm_factory.h"
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 // deleted when the RenderFrame gets deleted. 702 // deleted when the RenderFrame gets deleted.
699 #if defined(OS_ANDROID) 703 #if defined(OS_ANDROID)
700 new GinJavaBridgeDispatcher(this); 704 new GinJavaBridgeDispatcher(this);
701 #endif 705 #endif
702 706
703 #if defined(ENABLE_PLUGINS) 707 #if defined(ENABLE_PLUGINS)
704 plugin_power_saver_helper_ = new PluginPowerSaverHelper(this); 708 plugin_power_saver_helper_ = new PluginPowerSaverHelper(this);
705 #endif 709 #endif
706 710
707 manifest_manager_ = new ManifestManager(this); 711 manifest_manager_ = new ManifestManager(this);
712
713 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&mojo_shell_));
708 } 714 }
709 715
710 RenderFrameImpl::~RenderFrameImpl() { 716 RenderFrameImpl::~RenderFrameImpl() {
711 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone()); 717 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone());
712 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct()); 718 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct());
713 719
714 base::trace_event::TraceLog::GetInstance()->RemoveProcessLabel(routing_id_); 720 base::trace_event::TraceLog::GetInstance()->RemoveProcessLabel(routing_id_);
715 721
716 #if defined(VIDEO_HOLE) 722 #if defined(VIDEO_HOLE)
717 if (contains_media_player_) 723 if (contains_media_player_)
(...skipping 3086 matching lines...) Expand 10 before | Expand all | Expand 10 after
3804 3810
3805 blink::WebBluetooth* RenderFrameImpl::bluetooth() { 3811 blink::WebBluetooth* RenderFrameImpl::bluetooth() {
3806 if (!bluetooth_) { 3812 if (!bluetooth_) {
3807 bluetooth_.reset(new WebBluetoothImpl( 3813 bluetooth_.reset(new WebBluetoothImpl(
3808 ChildThreadImpl::current()->thread_safe_sender(), routing_id_)); 3814 ChildThreadImpl::current()->thread_safe_sender(), routing_id_));
3809 } 3815 }
3810 3816
3811 return bluetooth_.get(); 3817 return bluetooth_.get();
3812 } 3818 }
3813 3819
3820 blink::WebUSBClient* RenderFrameImpl::usbClient() {
3821 #if !defined(OS_ANDROID)
3822 if (!usb_client_) {
3823 mojo::ServiceProviderPtr device_services =
3824 ConnectToApplication(GURL(device::kDevicesMojoAppUrl));
3825 usb_client_.reset(new WebUSBClientImpl(device_services.Pass()));
3826 }
3827 #endif
3828 return usb_client_.get();
3829 }
3830
3814 #if defined(ENABLE_WEBVR) 3831 #if defined(ENABLE_WEBVR)
3815 blink::WebVRClient* RenderFrameImpl::webVRClient() { 3832 blink::WebVRClient* RenderFrameImpl::webVRClient() {
3816 if (!vr_dispatcher_) 3833 if (!vr_dispatcher_)
3817 vr_dispatcher_.reset(new VRDispatcher(GetServiceRegistry())); 3834 vr_dispatcher_.reset(new VRDispatcher(GetServiceRegistry()));
3818 3835
3819 return vr_dispatcher_.get(); 3836 return vr_dispatcher_.get();
3820 } 3837 }
3821 #endif 3838 #endif
3822 3839
3823 void RenderFrameImpl::DidPlay(WebMediaPlayer* player) { 3840 void RenderFrameImpl::DidPlay(WebMediaPlayer* player) {
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
4995 5012
4996 media::MediaPermission* RenderFrameImpl::GetMediaPermission() { 5013 media::MediaPermission* RenderFrameImpl::GetMediaPermission() {
4997 if (!media_permission_dispatcher_) 5014 if (!media_permission_dispatcher_)
4998 media_permission_dispatcher_ = new MediaPermissionDispatcher(this); 5015 media_permission_dispatcher_ = new MediaPermissionDispatcher(this);
4999 return media_permission_dispatcher_; 5016 return media_permission_dispatcher_;
5000 } 5017 }
5001 5018
5002 #if defined(ENABLE_MOJO_MEDIA) 5019 #if defined(ENABLE_MOJO_MEDIA)
5003 media::interfaces::ServiceFactory* RenderFrameImpl::GetMediaServiceFactory() { 5020 media::interfaces::ServiceFactory* RenderFrameImpl::GetMediaServiceFactory() {
5004 if (!media_service_factory_) { 5021 if (!media_service_factory_) {
5005 mojo::InterfacePtr<mojo::Shell> shell_ptr; 5022 mojo::ServiceProviderPtr service_provider =
5006 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&shell_ptr)); 5023 ConnectToApplication(GURL("mojo:media"));
5007
5008 mojo::ServiceProviderPtr service_provider;
5009 mojo::URLRequestPtr request(mojo::URLRequest::New());
5010 request->url = mojo::String::From("mojo:media");
5011 shell_ptr->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5012 nullptr, nullptr);
5013
5014 mojo::ConnectToService(service_provider.get(), &media_service_factory_); 5024 mojo::ConnectToService(service_provider.get(), &media_service_factory_);
5015
5016 media_service_factory_.set_connection_error_handler( 5025 media_service_factory_.set_connection_error_handler(
5017 base::Bind(&RenderFrameImpl::OnMediaServiceFactoryConnectionError, 5026 base::Bind(&RenderFrameImpl::OnMediaServiceFactoryConnectionError,
5018 base::Unretained(this))); 5027 base::Unretained(this)));
5019 } 5028 }
5020 5029
5021 return media_service_factory_.get(); 5030 return media_service_factory_.get();
5022 } 5031 }
5023 5032
5024 void RenderFrameImpl::OnMediaServiceFactoryConnectionError() { 5033 void RenderFrameImpl::OnMediaServiceFactoryConnectionError() {
5025 // TODO(xhwang): Resetting |media_service_factory_| could cause access 5034 // TODO(xhwang): Resetting |media_service_factory_| could cause access
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5067 5076
5068 void RenderFrameImpl::RegisterMojoServices() { 5077 void RenderFrameImpl::RegisterMojoServices() {
5069 // Only main frame have ImageDownloader service. 5078 // Only main frame have ImageDownloader service.
5070 if (!frame_->parent()) { 5079 if (!frame_->parent()) {
5071 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( 5080 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>(
5072 base::Bind(&ImageDownloaderImpl::CreateMojoService, 5081 base::Bind(&ImageDownloaderImpl::CreateMojoService,
5073 base::Unretained(this))); 5082 base::Unretained(this)));
5074 } 5083 }
5075 } 5084 }
5076 5085
5086 mojo::ServiceProviderPtr RenderFrameImpl::ConnectToApplication(
5087 const GURL& url) {
5088 DCHECK(mojo_shell_);
5089 mojo::ServiceProviderPtr service_provider;
5090 mojo::URLRequestPtr request(mojo::URLRequest::New());
5091 request->url = mojo::String::From(url);
5092 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5093 nullptr, nullptr);
5094 return service_provider.Pass();
5095 }
5096
5077 } // namespace content 5097 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/usb/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698