OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "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> |
11 | 11 |
12 #include "base/base_switches.h" | 12 #include "base/base_switches.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/scoped_file.h" | 14 #include "base/files/scoped_file.h" |
15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "chromecast/base/cast_constants.h" | 21 #include "chromecast/base/cast_constants.h" |
22 #include "chromecast/base/cast_paths.h" | 22 #include "chromecast/base/cast_paths.h" |
23 #include "chromecast/base/chromecast_switches.h" | 23 #include "chromecast/base/chromecast_switches.h" |
24 #include "chromecast/browser/cast_browser_context.h" | 24 #include "chromecast/browser/cast_browser_context.h" |
25 #include "chromecast/browser/cast_browser_main_parts.h" | 25 #include "chromecast/browser/cast_browser_main_parts.h" |
26 #include "chromecast/browser/cast_browser_process.h" | 26 #include "chromecast/browser/cast_browser_process.h" |
27 #include "chromecast/browser/cast_network_delegate.h" | 27 #include "chromecast/browser/cast_network_delegate.h" |
28 #include "chromecast/browser/cast_quota_permission_context.h" | 28 #include "chromecast/browser/cast_quota_permission_context.h" |
29 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h" | 29 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h" |
30 #include "chromecast/browser/cast_web_contents_user_data.h" | |
30 #include "chromecast/browser/geolocation/cast_access_token_store.h" | 31 #include "chromecast/browser/geolocation/cast_access_token_store.h" |
31 #include "chromecast/browser/media/cma_message_filter_host.h" | 32 #include "chromecast/browser/media/cma_message_filter_host.h" |
32 #include "chromecast/browser/service/cast_service_simple.h" | 33 #include "chromecast/browser/service/cast_service_simple.h" |
33 #include "chromecast/browser/url_request_context_factory.h" | 34 #include "chromecast/browser/url_request_context_factory.h" |
34 #include "chromecast/common/global_descriptors.h" | 35 #include "chromecast/common/global_descriptors.h" |
35 #include "chromecast/media/audio/cast_audio_manager.h" | 36 #include "chromecast/media/audio/cast_audio_manager.h" |
36 #include "chromecast/media/cma/backend/media_pipeline_backend_manager.h" | 37 #include "chromecast/media/cma/backend/media_pipeline_backend_manager.h" |
37 #include "chromecast/public/media/media_pipeline_backend.h" | 38 #include "chromecast/public/media/media_pipeline_backend.h" |
38 #include "components/crash/content/app/breakpad_linux.h" | 39 #include "components/crash/content/app/breakpad_linux.h" |
39 #include "components/crash/content/browser/crash_handler_host_linux.h" | 40 #include "components/crash/content/browser/crash_handler_host_linux.h" |
40 #include "components/network_hints/browser/network_hints_message_filter.h" | 41 #include "components/network_hints/browser/network_hints_message_filter.h" |
41 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/certificate_request_result_type.h" | 43 #include "content/public/browser/certificate_request_result_type.h" |
43 #include "content/public/browser/client_certificate_delegate.h" | 44 #include "content/public/browser/client_certificate_delegate.h" |
44 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
45 #include "content/public/browser/resource_dispatcher_host.h" | 46 #include "content/public/browser/resource_dispatcher_host.h" |
46 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
47 #include "content/public/common/content_descriptors.h" | 48 #include "content/public/common/content_descriptors.h" |
48 #include "content/public/common/content_switches.h" | 49 #include "content/public/common/content_switches.h" |
49 #include "content/public/common/url_constants.h" | 50 #include "content/public/common/url_constants.h" |
50 #include "content/public/common/web_preferences.h" | 51 #include "content/public/common/web_preferences.h" |
51 #include "net/ssl/ssl_cert_request_info.h" | 52 #include "net/ssl/ssl_cert_request_info.h" |
52 #include "net/url_request/url_request_context_getter.h" | 53 #include "net/url_request/url_request_context_getter.h" |
54 #include "ui/gfx/screen.h" | |
53 #include "ui/gl/gl_switches.h" | 55 #include "ui/gl/gl_switches.h" |
54 | 56 |
55 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) | 57 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
56 #include "chromecast/browser/media/cast_mojo_media_client.h" | 58 #include "chromecast/browser/media/cast_mojo_media_client.h" |
57 #include "media/mojo/services/mojo_media_application.h" // nogncheck | 59 #include "media/mojo/services/mojo_media_application.h" // nogncheck |
58 #endif // ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS | 60 #endif // ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS |
59 | 61 |
60 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
61 #include "components/crash/content/browser/crash_dump_manager_android.h" | 63 #include "components/crash/content/browser/crash_dump_manager_android.h" |
62 #include "components/external_video_surface/browser/android/external_video_surfa ce_container_impl.h" | 64 #include "components/external_video_surface/browser/android/external_video_surfa ce_container_impl.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 prefs->allow_scripts_to_close_windows = true; | 271 prefs->allow_scripts_to_close_windows = true; |
270 // TODO(lcwu): http://crbug.com/391089. This pref is set to true by default | 272 // TODO(lcwu): http://crbug.com/391089. This pref is set to true by default |
271 // because some content providers such as YouTube use plain http requests | 273 // because some content providers such as YouTube use plain http requests |
272 // to retrieve media data chunks while running in a https page. This pref | 274 // to retrieve media data chunks while running in a https page. This pref |
273 // should be disabled once all the content providers are no longer doing that. | 275 // should be disabled once all the content providers are no longer doing that. |
274 prefs->allow_running_insecure_content = true; | 276 prefs->allow_running_insecure_content = true; |
275 | 277 |
276 // Enable 5% margins for WebVTT cues to keep within title-safe area | 278 // Enable 5% margins for WebVTT cues to keep within title-safe area |
277 prefs->text_track_margin_percentage = 5; | 279 prefs->text_track_margin_percentage = 5; |
278 | 280 |
281 // This block of logic allows us to force 720p resolution for apps which don't | |
282 // handle scaling to higher resolutions (i.e. were built assuming 720p and | |
283 // have layout or performance problems at anything else). | |
284 // We use the viewport tag approach and ViewportStyle::TELEVISION to force a | |
285 // 720p layout viewport in this case. | |
286 // TODO(halliwell): require apps to handle scaling to any resolution; then | |
287 // we can simply run at the platform's native resolution. | |
279 #if defined(OS_ANDROID) | 288 #if defined(OS_ANDROID) |
280 // Enable the television style for viewport so that all cast apps have a | 289 // Android has viewport enabled by default. Disable for consistency with |
281 // 1280px wide layout viewport by default. | 290 // Linux (only enable below for 720p app case). |
282 DCHECK(prefs->viewport_enabled); | 291 DCHECK(prefs->viewport_enabled); |
283 DCHECK(prefs->viewport_meta_enabled); | 292 DCHECK(prefs->viewport_meta_enabled); |
284 prefs->viewport_style = content::ViewportStyle::TELEVISION; | 293 prefs->viewport_enabled = false; |
alokp
2016/05/11 16:46:53
This seems risky to me. I am not sure what else we
| |
294 prefs->viewport_meta_enabled = false; | |
285 #endif // defined(OS_ANDROID) | 295 #endif // defined(OS_ANDROID) |
296 | |
297 content::WebContents* web_contents = | |
298 content::WebContents::FromRenderViewHost(render_view_host); | |
299 if (web_contents) { | |
300 CastWebContentsUserData* user_data = | |
301 static_cast<CastWebContentsUserData*>( | |
302 web_contents->GetUserData(CastWebContentsUserData::UserDataKey())); | |
303 if (user_data->resolution_height() == 720) { | |
304 prefs->viewport_enabled = true; | |
305 prefs->viewport_meta_enabled = true; | |
306 prefs->viewport_style = content::ViewportStyle::TELEVISION; | |
307 | |
308 gfx::Size display_size = | |
309 gfx::Screen::GetScreen()->GetPrimaryDisplay().size(); | |
310 const float scale_factor = display_size.height() / 720.0f; | |
311 prefs->default_minimum_page_scale_factor = scale_factor; | |
312 prefs->default_maximum_page_scale_factor = scale_factor; | |
313 } | |
314 } | |
286 } | 315 } |
287 | 316 |
288 void CastContentBrowserClient::ResourceDispatcherHostCreated() { | 317 void CastContentBrowserClient::ResourceDispatcherHostCreated() { |
289 CastBrowserProcess::GetInstance()->SetResourceDispatcherHostDelegate( | 318 CastBrowserProcess::GetInstance()->SetResourceDispatcherHostDelegate( |
290 base::WrapUnique(new CastResourceDispatcherHostDelegate)); | 319 base::WrapUnique(new CastResourceDispatcherHostDelegate)); |
291 content::ResourceDispatcherHost::Get()->SetDelegate( | 320 content::ResourceDispatcherHost::Get()->SetDelegate( |
292 CastBrowserProcess::GetInstance()->resource_dispatcher_host_delegate()); | 321 CastBrowserProcess::GetInstance()->resource_dispatcher_host_delegate()); |
293 } | 322 } |
294 | 323 |
295 std::string CastContentBrowserClient::GetApplicationLocale() { | 324 std::string CastContentBrowserClient::GetApplicationLocale() { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 process_type, dumps_path, false /* upload */); | 538 process_type, dumps_path, false /* upload */); |
510 // StartUploaderThread() even though upload is diferred. | 539 // StartUploaderThread() even though upload is diferred. |
511 // Breakpad-related memory is freed in the uploader thread. | 540 // Breakpad-related memory is freed in the uploader thread. |
512 crash_handler->StartUploaderThread(); | 541 crash_handler->StartUploaderThread(); |
513 return crash_handler; | 542 return crash_handler; |
514 } | 543 } |
515 #endif // !defined(OS_ANDROID) | 544 #endif // !defined(OS_ANDROID) |
516 | 545 |
517 } // namespace shell | 546 } // namespace shell |
518 } // namespace chromecast | 547 } // namespace chromecast |
OLD | NEW |