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

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

Issue 223143003: Initial checkin of chromecast content embedder (cast_shell) and related build scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add an additional function in gl_surface_cast.cc Created 6 years, 8 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
(Empty)
1 // Copyright (c) 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 "webkit/common/webpreferences.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::ProtocolHandlerScopedVector protocol_interceptors) {
44 return url_request_context_factory_->CreateMainGetter(browser_context,
45 protocol_handlers);
46 }
47
48 bool CastContentBrowserClient::IsHandledURL(const GURL& url) {
49 if (!url.is_valid())
50 return false;
51 // Keep in sync with ProtocolHandlers added by
52 // URLRequestContextFactory::CreateMainGetter.
53 static const char* const kProtocolList[] = {
54 content::kBlobScheme,
55 content::kFileSystemScheme,
56 content::kChromeUIScheme,
57 content::kChromeDevToolsScheme,
58 content::kDataScheme,
59 };
60 for (size_t i = 0; i < arraysize(kProtocolList); ++i) {
61 if (url.scheme() == kProtocolList[i])
62 return true;
63 }
64 return false;
65 }
66
67 void CastContentBrowserClient::AppendExtraCommandLineSwitches(
68 base::CommandLine* command_line,
69 int child_process_id) {
70
71 std::string process_type =
72 command_line->GetSwitchValueNative(switches::kProcessType);
73 // Renderer process comamndline
74 if (process_type == switches::kRendererProcess) {
75 // TODO(lcwu): Append the browser command-line switches we want to
76 // propagate to renderer here.
77 }
78 }
79
80 content::AccessTokenStore* CastContentBrowserClient::CreateAccessTokenStore() {
81 return new CastAccessTokenStore(shell_browser_main_parts_->browser_context());
82 }
83
84 void CastContentBrowserClient::OverrideWebkitPrefs(
85 content::RenderViewHost* render_view_host,
86 const GURL& url,
87 WebPreferences* prefs) {
88 prefs->allow_scripts_to_close_windows = true;
89 // Enable accelerated compositing to allow compositing mode.
90 // TODO(lcwu): follow up with compositor team to see if this is really
91 // necessary.
92 prefs->accelerated_compositing_enabled = true;
93 // TODO(lcwu): We have to set this pref to true by default because some
94 // content providers such as YouTube use plain http requests to retrieve
95 // media data chunks while running in a https page. This pref should be
96 // disabled once all the content providers are no longer doing that.
97 prefs->allow_running_insecure_content = true;
98 }
99
100 std::string CastContentBrowserClient::GetApplicationLocale() {
101 return "en-US";
102 }
103
104 void CastContentBrowserClient::AllowCertificateError(
105 int render_process_id,
106 int render_view_id,
107 int cert_error,
108 const net::SSLInfo& ssl_info,
109 const GURL& request_url,
110 ResourceType::Type resource_type,
111 bool overridable,
112 bool strict_enforcement,
113 const base::Callback<void(bool)>& callback,
114 content::CertificateRequestResultType* result) {
115 // Allow developers to override certificate errors.
116 // Otherwise, any fatal certificate errors will cause an abort.
117 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
118 return;
119 }
120
121 bool CastContentBrowserClient::CanCreateWindow(
122 const GURL& opener_url,
123 const GURL& opener_top_level_frame_url,
124 const GURL& source_origin,
125 WindowContainerType container_type,
126 const GURL& target_url,
127 const content::Referrer& referrer,
128 WindowOpenDisposition disposition,
129 const blink::WebWindowFeatures& features,
130 bool user_gesture,
131 bool opener_suppressed,
132 content::ResourceContext* context,
133 int render_process_id,
134 bool is_guest,
135 int opener_id,
136 bool* no_javascript_access) {
137 *no_javascript_access = true;
138 return false;
139 }
140
141 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
142 const base::CommandLine& command_line,
143 int child_process_id,
144 std::vector<content::FileDescriptorInfo>* mappings) {
145 // TODO(lcwu): Push crash dump signal fd here.
146 }
147
148 } // namespace shell
149 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698