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

Side by Side Diff: chromecast/browser/cast_content_browser_client.cc

Issue 2562393005: [Chromecast] Reference internal services manifest. (Closed)
Patch Set: Fix CastContentClient header Created 4 years 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
OLDNEW
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 "chromecast/browser/cast_content_browser_client.h" 5 #include "chromecast/browser/cast_content_browser_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 30 matching lines...) Expand all
41 #include "chromecast/public/media/media_pipeline_backend.h" 41 #include "chromecast/public/media/media_pipeline_backend.h"
42 #include "components/crash/content/app/breakpad_linux.h" 42 #include "components/crash/content/app/breakpad_linux.h"
43 #include "components/crash/content/browser/crash_handler_host_linux.h" 43 #include "components/crash/content/browser/crash_handler_host_linux.h"
44 #include "components/network_hints/browser/network_hints_message_filter.h" 44 #include "components/network_hints/browser/network_hints_message_filter.h"
45 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
46 #include "content/public/browser/certificate_request_result_type.h" 46 #include "content/public/browser/certificate_request_result_type.h"
47 #include "content/public/browser/client_certificate_delegate.h" 47 #include "content/public/browser/client_certificate_delegate.h"
48 #include "content/public/browser/render_process_host.h" 48 #include "content/public/browser/render_process_host.h"
49 #include "content/public/browser/resource_dispatcher_host.h" 49 #include "content/public/browser/resource_dispatcher_host.h"
50 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
51 #include "content/public/common/connection_filter.h"
51 #include "content/public/common/content_descriptors.h" 52 #include "content/public/common/content_descriptors.h"
52 #include "content/public/common/content_switches.h" 53 #include "content/public/common/content_switches.h"
53 #include "content/public/common/service_names.mojom.h" 54 #include "content/public/common/service_names.mojom.h"
54 #include "content/public/common/url_constants.h" 55 #include "content/public/common/url_constants.h"
55 #include "content/public/common/web_preferences.h" 56 #include "content/public/common/web_preferences.h"
56 #include "net/ssl/ssl_cert_request_info.h" 57 #include "net/ssl/ssl_cert_request_info.h"
57 #include "net/url_request/url_request_context_getter.h" 58 #include "net/url_request/url_request_context_getter.h"
59 #include "services/service_manager/public/cpp/connector.h"
58 #include "services/service_manager/public/cpp/interface_registry.h" 60 #include "services/service_manager/public/cpp/interface_registry.h"
59 #include "ui/base/resource/resource_bundle.h" 61 #include "ui/base/resource/resource_bundle.h"
60 #include "ui/display/display.h" 62 #include "ui/display/display.h"
61 #include "ui/display/screen.h" 63 #include "ui/display/screen.h"
62 #include "ui/gl/gl_switches.h" 64 #include "ui/gl/gl_switches.h"
63 65
64 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) 66 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
65 #include "chromecast/media/service/cast_mojo_media_client.h" 67 #include "chromecast/media/service/cast_mojo_media_client.h"
66 #include "media/mojo/services/media_service.h" // nogncheck 68 #include "media/mojo/services/media_service.h" // nogncheck
67 #endif // ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS 69 #endif // ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS
68 70
69 #if defined(OS_ANDROID) 71 #if defined(OS_ANDROID)
70 #include "components/crash/content/browser/crash_dump_manager_android.h" 72 #include "components/crash/content/browser/crash_dump_manager_android.h"
71 #else 73 #else
72 #include "chromecast/media/cdm/cast_cdm_factory.h" 74 #include "chromecast/media/cdm/cast_cdm_factory.h"
73 #endif // defined(OS_ANDROID) 75 #endif // defined(OS_ANDROID)
74 76
75 namespace chromecast { 77 namespace chromecast {
76 namespace shell { 78 namespace shell {
77 79
78 namespace { 80 namespace {
81
79 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) 82 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
80 static std::unique_ptr<service_manager::Service> CreateMediaService( 83 static std::unique_ptr<service_manager::Service> CreateMediaService(
81 CastContentBrowserClient* browser_client) { 84 CastContentBrowserClient* browser_client) {
82 std::unique_ptr<media::CastMojoMediaClient> mojo_media_client( 85 std::unique_ptr<media::CastMojoMediaClient> mojo_media_client(
83 new media::CastMojoMediaClient( 86 new media::CastMojoMediaClient(
84 base::Bind(&CastContentBrowserClient::CreateMediaPipelineBackend, 87 base::Bind(&CastContentBrowserClient::CreateMediaPipelineBackend,
85 base::Unretained(browser_client)), 88 base::Unretained(browser_client)),
86 base::Bind(&CastContentBrowserClient::CreateCdmFactory, 89 base::Bind(&CastContentBrowserClient::CreateCdmFactory,
87 base::Unretained(browser_client)), 90 base::Unretained(browser_client)),
88 browser_client->GetVideoResolutionPolicy(), 91 browser_client->GetVideoResolutionPolicy(),
89 browser_client->media_resource_tracker())); 92 browser_client->media_resource_tracker()));
90 return std::unique_ptr<service_manager::Service>( 93 return std::unique_ptr<service_manager::Service>(
91 new ::media::MediaService(std::move(mojo_media_client))); 94 new ::media::MediaService(std::move(mojo_media_client)));
92 } 95 }
93 #endif // defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) 96 #endif // defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
94 97
98 // This filter will be added to the ServiceManagerConnection for the browser
99 // process, registering these interfaces in "service:content_browser" so any
100 // external service can use them. This allows another service to connect to an
101 // interface "mojom::Foo" registered here by calling:
102 //
103 // mojom::FooPtr remote_foo;
104 // connector()->GetInterface("service:content_browser", &remote_foo");
105 //
106 // Note: Service manifests will also need to be updated. For the example above,
107 // chromecast/browser/cast_content_browser_manifest_overlay.json will need to
108 // "provide" the interface...
109 //
110 // provides: {
111 // "foo_interfaces": [ "mojom::Foo" ]
112 // }
113 //
114 // ...and the service manifest for the remote service will need to "require" it
115 // from "content_browser":
116 //
117 // requires: {
118 // "content_browser": [ "foo_interfaces" ]
119 // }
120 //
121 // We will not filter on |remote_identity| here; instead, connection
122 // constraints will be enforced only by the manifests.
123 class ContentBrowserConnectionFilter : public content::ConnectionFilter {
alokp 2016/12/14 05:46:16 Are we using connection filter anywhere? If not I
slan 2016/12/19 17:58:18 Removed.
124 public:
125 ContentBrowserConnectionFilter() {}
126 ~ContentBrowserConnectionFilter() override {}
127
128 // content::ConnectionFilter implementation:
129 bool OnConnect(const service_manager::Identity& remote_identity,
130 service_manager::InterfaceRegistry* registry,
131 service_manager::Connector* connector) {
132 DCHECK(registry);
133 return true;
134 }
135
136 private:
137 DISALLOW_COPY_AND_ASSIGN(ContentBrowserConnectionFilter);
138 };
139
95 } // namespace 140 } // namespace
96 141
97 CastContentBrowserClient::CastContentBrowserClient() 142 CastContentBrowserClient::CastContentBrowserClient()
98 : cast_browser_main_parts_(nullptr), 143 : cast_browser_main_parts_(nullptr),
99 url_request_context_factory_(new URLRequestContextFactory()) {} 144 url_request_context_factory_(new URLRequestContextFactory()) {}
100 145
101 CastContentBrowserClient::~CastContentBrowserClient() { 146 CastContentBrowserClient::~CastContentBrowserClient() {
102 content::BrowserThread::DeleteSoon( 147 content::BrowserThread::DeleteSoon(
103 content::BrowserThread::IO, 148 content::BrowserThread::IO,
104 FROM_HERE, 149 FROM_HERE,
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 460
416 void CastContentBrowserClient::ExposeInterfacesToRenderer( 461 void CastContentBrowserClient::ExposeInterfacesToRenderer(
417 service_manager::InterfaceRegistry* registry, 462 service_manager::InterfaceRegistry* registry,
418 content::RenderProcessHost* render_process_host) { 463 content::RenderProcessHost* render_process_host) {
419 registry->AddInterface( 464 registry->AddInterface(
420 base::Bind(&media::MediaCapsImpl::AddBinding, 465 base::Bind(&media::MediaCapsImpl::AddBinding,
421 base::Unretained(cast_browser_main_parts_->media_caps())), 466 base::Unretained(cast_browser_main_parts_->media_caps())),
422 base::ThreadTaskRunnerHandle::Get()); 467 base::ThreadTaskRunnerHandle::Get());
423 } 468 }
424 469
470 // When registering an in-process service, also update the manifest overlay in
471 // chromecast/browser/BUILD.gn to include the service.
425 void CastContentBrowserClient::RegisterInProcessServices( 472 void CastContentBrowserClient::RegisterInProcessServices(
426 StaticServiceMap* services) { 473 StaticServiceMap* services) {
427 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) 474 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
428 content::ServiceInfo info; 475 content::ServiceInfo info;
429 info.factory = base::Bind(&CreateMediaService, base::Unretained(this)); 476 info.factory = base::Bind(&CreateMediaService, base::Unretained(this));
430 info.task_runner = GetMediaTaskRunner(); 477 info.task_runner = GetMediaTaskRunner();
431 services->insert(std::make_pair("media", info)); 478 services->insert(std::make_pair("media", info));
432 #endif 479 #endif
433 } 480 }
434 481
482 void CastContentBrowserClient::AddConnectionFilters(
483 ConnectionFilterList* connection_filter_list) {
484 connection_filter_list->push_back(
485 base::MakeUnique<ContentBrowserConnectionFilter>());
486 }
487
435 std::unique_ptr<base::Value> 488 std::unique_ptr<base::Value>
436 CastContentBrowserClient::GetServiceManifestOverlay( 489 CastContentBrowserClient::GetServiceManifestOverlay(
437 const std::string& service_name) { 490 const std::string& service_name) {
438 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 491 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
439 if (service_name != content::mojom::kBrowserServiceName) 492 if (service_name != content::mojom::kBrowserServiceName)
440 return nullptr; 493 return nullptr;
441 base::StringPiece manifest_contents = 494 base::StringPiece manifest_contents =
442 rb.GetRawDataResourceForScale(IDR_CAST_CONTENT_BROWSER_MANIFEST_OVERLAY, 495 rb.GetRawDataResourceForScale(IDR_CAST_CONTENT_BROWSER_MANIFEST_OVERLAY,
443 ui::ScaleFactor::SCALE_FACTOR_NONE); 496 ui::ScaleFactor::SCALE_FACTOR_NONE);
444 return base::JSONReader::Read(manifest_contents); 497 return base::JSONReader::Read(manifest_contents);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 process_type, dumps_path, false /* upload */); 599 process_type, dumps_path, false /* upload */);
547 // StartUploaderThread() even though upload is diferred. 600 // StartUploaderThread() even though upload is diferred.
548 // Breakpad-related memory is freed in the uploader thread. 601 // Breakpad-related memory is freed in the uploader thread.
549 crash_handler->StartUploaderThread(); 602 crash_handler->StartUploaderThread();
550 return crash_handler; 603 return crash_handler;
551 } 604 }
552 #endif // !defined(OS_ANDROID) 605 #endif // !defined(OS_ANDROID)
553 606
554 } // namespace shell 607 } // namespace shell
555 } // namespace chromecast 608 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698