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

Side by Side Diff: android_webview/renderer/aw_content_renderer_client.cc

Issue 2712983004: Simplify/Cleanup MediaClient (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "android_webview/renderer/aw_content_renderer_client.h" 5 #include "android_webview/renderer/aw_content_renderer_client.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "android_webview/common/aw_resource.h" 9 #include "android_webview/common/aw_resource.h"
10 #include "android_webview/common/aw_switches.h" 10 #include "android_webview/common/aw_switches.h"
(...skipping 15 matching lines...) Expand all
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "components/autofill/content/renderer/autofill_agent.h" 27 #include "components/autofill/content/renderer/autofill_agent.h"
28 #include "components/autofill/content/renderer/password_autofill_agent.h" 28 #include "components/autofill/content/renderer/password_autofill_agent.h"
29 #include "components/printing/renderer/print_web_view_helper.h" 29 #include "components/printing/renderer/print_web_view_helper.h"
30 #include "components/spellcheck/spellcheck_build_features.h" 30 #include "components/spellcheck/spellcheck_build_features.h"
31 #include "components/supervised_user_error_page/gin_wrapper.h" 31 #include "components/supervised_user_error_page/gin_wrapper.h"
32 #include "components/supervised_user_error_page/supervised_user_error_page_andro id.h" 32 #include "components/supervised_user_error_page/supervised_user_error_page_andro id.h"
33 #include "components/visitedlink/renderer/visitedlink_slave.h" 33 #include "components/visitedlink/renderer/visitedlink_slave.h"
34 #include "components/web_restrictions/interfaces/web_restrictions.mojom.h" 34 #include "components/web_restrictions/interfaces/web_restrictions.mojom.h"
35 #include "content/public/common/url_constants.h" 35 #include "content/public/common/url_constants.h"
36 #include "content/public/renderer/content_media_client.h"
36 #include "content/public/renderer/document_state.h" 37 #include "content/public/renderer/document_state.h"
37 #include "content/public/renderer/navigation_state.h" 38 #include "content/public/renderer/navigation_state.h"
38 #include "content/public/renderer/render_frame.h" 39 #include "content/public/renderer/render_frame.h"
39 #include "content/public/renderer/render_thread.h" 40 #include "content/public/renderer/render_thread.h"
40 #include "content/public/renderer/render_view.h" 41 #include "content/public/renderer/render_view.h"
42 #include "media/base/media_client.h"
41 #include "net/base/escape.h" 43 #include "net/base/escape.h"
42 #include "net/base/net_errors.h" 44 #include "net/base/net_errors.h"
43 #include "services/service_manager/public/cpp/interface_provider.h" 45 #include "services/service_manager/public/cpp/interface_provider.h"
44 #include "services/service_manager/public/cpp/interface_registry.h" 46 #include "services/service_manager/public/cpp/interface_registry.h"
45 #include "third_party/WebKit/public/platform/WebString.h" 47 #include "third_party/WebKit/public/platform/WebString.h"
46 #include "third_party/WebKit/public/platform/WebURL.h" 48 #include "third_party/WebKit/public/platform/WebURL.h"
47 #include "third_party/WebKit/public/platform/WebURLError.h" 49 #include "third_party/WebKit/public/platform/WebURLError.h"
48 #include "third_party/WebKit/public/platform/WebURLRequest.h" 50 #include "third_party/WebKit/public/platform/WebURLRequest.h"
49 #include "third_party/WebKit/public/web/WebFrame.h" 51 #include "third_party/WebKit/public/web/WebFrame.h"
50 #include "third_party/WebKit/public/web/WebNavigationType.h" 52 #include "third_party/WebKit/public/web/WebNavigationType.h"
(...skipping 24 matching lines...) Expand all
75 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave); 77 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave);
76 thread->GetInterfaceRegistry()->AddInterface( 78 thread->GetInterfaceRegistry()->AddInterface(
77 visited_link_slave_->GetBindCallback()); 79 visited_link_slave_->GetBindCallback());
78 80
79 #if BUILDFLAG(ENABLE_SPELLCHECK) 81 #if BUILDFLAG(ENABLE_SPELLCHECK)
80 if (!spellcheck_) { 82 if (!spellcheck_) {
81 spellcheck_ = base::MakeUnique<SpellCheck>(); 83 spellcheck_ = base::MakeUnique<SpellCheck>();
82 thread->AddObserver(spellcheck_.get()); 84 thread->AddObserver(spellcheck_.get());
83 } 85 }
84 #endif 86 #endif
87
88 ::media::SetMediaClient(new ::content::ContentMediaClient(this));
85 } 89 }
86 90
87 bool AwContentRendererClient::HandleNavigation( 91 bool AwContentRendererClient::HandleNavigation(
88 content::RenderFrame* render_frame, 92 content::RenderFrame* render_frame,
89 bool is_content_initiated, 93 bool is_content_initiated,
90 bool render_view_was_created_by_renderer, 94 bool render_view_was_created_by_renderer,
91 blink::WebFrame* frame, 95 blink::WebFrame* frame,
92 const blink::WebURLRequest& request, 96 const blink::WebURLRequest& request,
93 blink::WebNavigationType type, 97 blink::WebNavigationType type,
94 blink::WebNavigationPolicy default_policy, 98 blink::WebNavigationPolicy default_policy,
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 size_t length) { 273 size_t length) {
270 return visited_link_slave_->ComputeURLFingerprint(canonical_url, length); 274 return visited_link_slave_->ComputeURLFingerprint(canonical_url, length);
271 } 275 }
272 276
273 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) { 277 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) {
274 return visited_link_slave_->IsVisited(link_hash); 278 return visited_link_slave_->IsVisited(link_hash);
275 } 279 }
276 280
277 void AwContentRendererClient::AddSupportedKeySystems( 281 void AwContentRendererClient::AddSupportedKeySystems(
278 std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems) { 282 std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems) {
283 DVLOG(3) << __func__;
279 AwAddKeySystems(key_systems); 284 AwAddKeySystems(key_systems);
280 } 285 }
281 286
282 bool AwContentRendererClient::ShouldUseMediaPlayerForURL(const GURL& url) { 287 bool AwContentRendererClient::ShouldUseMediaPlayerForURL(const GURL& url) {
283 // Android WebView needs to support codecs that Chrome does not, for these 288 // Android WebView needs to support codecs that Chrome does not, for these
284 // cases we must force the usage of Android MediaPlayer instead of Chrome's 289 // cases we must force the usage of Android MediaPlayer instead of Chrome's
285 // internal player. 290 // internal player.
286 // 291 //
287 // Note: Despite these extensions being forwarded for playback to MediaPlayer, 292 // Note: Despite these extensions being forwarded for playback to MediaPlayer,
288 // HTMLMediaElement.canPlayType() will return empty for these containers. 293 // HTMLMediaElement.canPlayType() will return empty for these containers.
289 // TODO(boliu): If this is important, extend media::MimeUtil for WebView. 294 // TODO(boliu): If this is important, extend media::MimeUtil for WebView.
290 // 295 //
291 // Format list mirrors: 296 // Format list mirrors:
292 // http://developer.android.com/guide/appendix/media-formats.html 297 // http://developer.android.com/guide/appendix/media-formats.html
293 static const char* kMediaPlayerExtensions[] = { 298 static const char* kMediaPlayerExtensions[] = {
294 ".3gp", ".ts", ".flac", ".mid", ".xmf", 299 ".3gp", ".ts", ".flac", ".mid", ".xmf",
295 ".mxmf", ".rtttl", ".rtx", ".ota", ".imy"}; 300 ".mxmf", ".rtttl", ".rtx", ".ota", ".imy"};
296 for (auto* extension : kMediaPlayerExtensions) { 301 for (auto* extension : kMediaPlayerExtensions) {
297 if (base::EndsWith(url.path(), extension, 302 if (base::EndsWith(url.path(), extension,
298 base::CompareCase::INSENSITIVE_ASCII)) { 303 base::CompareCase::INSENSITIVE_ASCII)) {
299 return true; 304 return true;
300 } 305 }
301 } 306 }
302 return false; 307 return false;
303 } 308 }
304 309
305 } // namespace android_webview 310 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/chrome_content_renderer_client.cc » ('j') | content/public/renderer/content_media_client.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698