OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chromecast/shell/browser/cast_content_browser_client.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "chromecast/shell/browser/cast_browser_context.h" |
| 9 #include "chromecast/shell/browser/cast_browser_main_parts.h" |
| 10 #include "chromecast/shell/browser/geolocation/cast_access_token_store.h" |
| 11 #include "chromecast/shell/browser/url_request_context_factory.h" |
| 12 #include "content/public/browser/certificate_request_result_type.h" |
| 13 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/common/content_descriptors.h" |
| 15 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/common/url_constants.h" |
| 17 #include "content/public/common/web_preferences.h" |
| 18 |
| 19 namespace chromecast { |
| 20 namespace shell { |
| 21 |
| 22 CastContentBrowserClient::CastContentBrowserClient() |
| 23 : url_request_context_factory_(new URLRequestContextFactory()) { |
| 24 } |
| 25 |
| 26 CastContentBrowserClient::~CastContentBrowserClient() { |
| 27 } |
| 28 |
| 29 content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts( |
| 30 const content::MainFunctionParams& parameters) { |
| 31 shell_browser_main_parts_.reset( |
| 32 new CastBrowserMainParts(parameters, url_request_context_factory_.get())); |
| 33 return shell_browser_main_parts_.get(); |
| 34 } |
| 35 |
| 36 void CastContentBrowserClient::RenderProcessWillLaunch( |
| 37 content::RenderProcessHost* host) { |
| 38 } |
| 39 |
| 40 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext( |
| 41 content::BrowserContext* browser_context, |
| 42 content::ProtocolHandlerMap* protocol_handlers, |
| 43 content::URLRequestInterceptorScopedVector request_interceptors) { |
| 44 return url_request_context_factory_->CreateMainGetter( |
| 45 browser_context, |
| 46 protocol_handlers, |
| 47 request_interceptors.Pass()); |
| 48 } |
| 49 |
| 50 bool CastContentBrowserClient::IsHandledURL(const GURL& url) { |
| 51 if (!url.is_valid()) |
| 52 return false; |
| 53 |
| 54 static const char* const kProtocolList[] = { |
| 55 url::kBlobScheme, |
| 56 url::kFileSystemScheme, |
| 57 content::kChromeUIScheme, |
| 58 content::kChromeDevToolsScheme, |
| 59 url::kDataScheme, |
| 60 }; |
| 61 |
| 62 const std::string& scheme = url.scheme(); |
| 63 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { |
| 64 if (scheme == kProtocolList[i]) |
| 65 return true; |
| 66 } |
| 67 return false; |
| 68 } |
| 69 |
| 70 void CastContentBrowserClient::AppendExtraCommandLineSwitches( |
| 71 base::CommandLine* command_line, |
| 72 int child_process_id) { |
| 73 |
| 74 std::string process_type = |
| 75 command_line->GetSwitchValueNative(switches::kProcessType); |
| 76 // Renderer process comamndline |
| 77 if (process_type == switches::kRendererProcess) { |
| 78 // Any browser command-line switches that should be propagated to |
| 79 // the renderer go here. |
| 80 } |
| 81 } |
| 82 |
| 83 content::AccessTokenStore* CastContentBrowserClient::CreateAccessTokenStore() { |
| 84 return new CastAccessTokenStore(shell_browser_main_parts_->browser_context()); |
| 85 } |
| 86 |
| 87 void CastContentBrowserClient::OverrideWebkitPrefs( |
| 88 content::RenderViewHost* render_view_host, |
| 89 const GURL& url, |
| 90 content::WebPreferences* prefs) { |
| 91 prefs->allow_scripts_to_close_windows = true; |
| 92 // TODO(lcwu): http://crbug.com/391089. This pref is set to true by default |
| 93 // because some content providers such as YouTube use plain http requests |
| 94 // to retrieve media data chunks while running in a https page. This pref |
| 95 // should be disabled once all the content providers are no longer doing that. |
| 96 prefs->allow_running_insecure_content = true; |
| 97 } |
| 98 |
| 99 std::string CastContentBrowserClient::GetApplicationLocale() { |
| 100 return "en-US"; |
| 101 } |
| 102 |
| 103 void CastContentBrowserClient::AllowCertificateError( |
| 104 int render_process_id, |
| 105 int render_view_id, |
| 106 int cert_error, |
| 107 const net::SSLInfo& ssl_info, |
| 108 const GURL& request_url, |
| 109 content::ResourceType::Type resource_type, |
| 110 bool overridable, |
| 111 bool strict_enforcement, |
| 112 const base::Callback<void(bool)>& callback, |
| 113 content::CertificateRequestResultType* result) { |
| 114 // Allow developers to override certificate errors. |
| 115 // Otherwise, any fatal certificate errors will cause an abort. |
| 116 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; |
| 117 return; |
| 118 } |
| 119 |
| 120 bool CastContentBrowserClient::CanCreateWindow( |
| 121 const GURL& opener_url, |
| 122 const GURL& opener_top_level_frame_url, |
| 123 const GURL& source_origin, |
| 124 WindowContainerType container_type, |
| 125 const GURL& target_url, |
| 126 const content::Referrer& referrer, |
| 127 WindowOpenDisposition disposition, |
| 128 const blink::WebWindowFeatures& features, |
| 129 bool user_gesture, |
| 130 bool opener_suppressed, |
| 131 content::ResourceContext* context, |
| 132 int render_process_id, |
| 133 int opener_id, |
| 134 bool* no_javascript_access) { |
| 135 *no_javascript_access = true; |
| 136 return false; |
| 137 } |
| 138 |
| 139 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 140 const base::CommandLine& command_line, |
| 141 int child_process_id, |
| 142 std::vector<content::FileDescriptorInfo>* mappings) { |
| 143 } |
| 144 |
| 145 } // namespace shell |
| 146 } // namespace chromecast |
OLD | NEW |