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/renderer/cast_content_renderer_client.h" | 5 #include "chromecast/renderer/cast_content_renderer_client.h" |
6 | 6 |
7 #include <sys/sysinfo.h> | 7 #include <sys/sysinfo.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 base::TimeDelta::FromMilliseconds(kPollingIntervalMS)); | 65 base::TimeDelta::FromMilliseconds(kPollingIntervalMS)); |
66 } | 66 } |
67 #endif | 67 #endif |
68 | 68 |
69 // Default background color to set for WebViews. WebColor is in ARGB format | 69 // Default background color to set for WebViews. WebColor is in ARGB format |
70 // though the comment of WebColor says it is in RGBA. | 70 // though the comment of WebColor says it is in RGBA. |
71 const blink::WebColor kColorBlack = 0xFF000000; | 71 const blink::WebColor kColorBlack = 0xFF000000; |
72 | 72 |
73 class CastRenderViewObserver : content::RenderViewObserver { | 73 class CastRenderViewObserver : content::RenderViewObserver { |
74 public: | 74 public: |
75 explicit CastRenderViewObserver(content::RenderView* render_view); | 75 CastRenderViewObserver(CastContentRendererClient* client, |
| 76 content::RenderView* render_view); |
76 ~CastRenderViewObserver() override {} | 77 ~CastRenderViewObserver() override {} |
77 | 78 |
78 void DidClearWindowObject(blink::WebLocalFrame* frame) override; | 79 void DidClearWindowObject(blink::WebLocalFrame* frame) override; |
| 80 |
| 81 private: |
| 82 CastContentRendererClient* const client_; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(CastRenderViewObserver); |
79 }; | 85 }; |
80 | 86 |
81 CastRenderViewObserver::CastRenderViewObserver(content::RenderView* render_view) | 87 CastRenderViewObserver::CastRenderViewObserver( |
82 : content::RenderViewObserver(render_view) { | 88 CastContentRendererClient* client, |
| 89 content::RenderView* render_view) |
| 90 : content::RenderViewObserver(render_view), |
| 91 client_(client) { |
83 } | 92 } |
84 | 93 |
85 void CastRenderViewObserver::DidClearWindowObject(blink::WebLocalFrame* frame) { | 94 void CastRenderViewObserver::DidClearWindowObject(blink::WebLocalFrame* frame) { |
86 PlatformAddRendererNativeBindings(frame); | 95 client_->AddRendererNativeBindings(frame); |
87 } | 96 } |
88 | 97 |
89 } // namespace | 98 } // namespace |
90 | 99 |
91 CastContentRendererClient::CastContentRendererClient() { | 100 CastContentRendererClient::CastContentRendererClient() { |
92 } | 101 } |
93 | 102 |
94 CastContentRendererClient::~CastContentRendererClient() { | 103 CastContentRendererClient::~CastContentRendererClient() { |
95 } | 104 } |
96 | 105 |
| 106 void CastContentRendererClient::AddRendererNativeBindings( |
| 107 blink::WebLocalFrame* frame) { |
| 108 } |
| 109 |
| 110 std::vector<scoped_refptr<IPC::MessageFilter>> |
| 111 CastContentRendererClient::GetRendererMessageFilters() { |
| 112 return std::vector<scoped_refptr<IPC::MessageFilter>>(); |
| 113 } |
| 114 |
97 void CastContentRendererClient::RenderThreadStarted() { | 115 void CastContentRendererClient::RenderThreadStarted() { |
98 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 116 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
99 #if defined(USE_NSS_CERTS) | 117 #if defined(USE_NSS_CERTS) |
100 // Note: Copied from chrome_render_process_observer.cc to fix b/8676652. | 118 // Note: Copied from chrome_render_process_observer.cc to fix b/8676652. |
101 // | 119 // |
102 // On platforms where the system NSS shared libraries are used, | 120 // On platforms where the system NSS shared libraries are used, |
103 // initialize NSS now because it won't be able to load the .so's | 121 // initialize NSS now because it won't be able to load the .so's |
104 // after entering the sandbox. | 122 // after entering the sandbox. |
105 if (!command_line->HasSwitch(switches::kSingleProcess)) | 123 if (!command_line->HasSwitch(switches::kSingleProcess)) |
106 crypto::InitNSSSafely(); | 124 crypto::InitNSSSafely(); |
107 #endif | 125 #endif |
108 | 126 |
109 #if defined(ARCH_CPU_ARM_FAMILY) && !defined(OS_ANDROID) | 127 #if defined(ARCH_CPU_ARM_FAMILY) && !defined(OS_ANDROID) |
110 PlatformPollFreemem(); | 128 PlatformPollFreemem(); |
111 #endif | 129 #endif |
112 | 130 |
113 // Set the initial known codecs mask. | 131 // Set the initial known codecs mask. |
114 if (command_line->HasSwitch(switches::kHdmiSinkSupportedCodecs)) { | 132 if (command_line->HasSwitch(switches::kHdmiSinkSupportedCodecs)) { |
115 int hdmi_codecs_mask; | 133 int hdmi_codecs_mask; |
116 if (base::StringToInt(command_line->GetSwitchValueASCII( | 134 if (base::StringToInt(command_line->GetSwitchValueASCII( |
117 switches::kHdmiSinkSupportedCodecs), | 135 switches::kHdmiSinkSupportedCodecs), |
118 &hdmi_codecs_mask)) { | 136 &hdmi_codecs_mask)) { |
119 ::media::SetHdmiSinkCodecs(hdmi_codecs_mask); | 137 ::media::SetHdmiSinkCodecs(hdmi_codecs_mask); |
120 } | 138 } |
121 } | 139 } |
122 | 140 |
123 cast_observer_.reset( | 141 cast_observer_.reset( |
124 new CastRenderProcessObserver(PlatformGetRendererMessageFilters())); | 142 new CastRenderProcessObserver(GetRendererMessageFilters())); |
125 | 143 |
126 prescient_networking_dispatcher_.reset( | 144 prescient_networking_dispatcher_.reset( |
127 new network_hints::PrescientNetworkingDispatcher()); | 145 new network_hints::PrescientNetworkingDispatcher()); |
128 | 146 |
129 std::string last_launched_app = | 147 std::string last_launched_app = |
130 command_line->GetSwitchValueNative(switches::kLastLaunchedApp); | 148 command_line->GetSwitchValueNative(switches::kLastLaunchedApp); |
131 if (!last_launched_app.empty()) | 149 if (!last_launched_app.empty()) |
132 base::debug::SetCrashKeyValue(crash_keys::kLastApp, last_launched_app); | 150 base::debug::SetCrashKeyValue(crash_keys::kLastApp, last_launched_app); |
133 | 151 |
134 std::string previous_app = | 152 std::string previous_app = |
(...skipping 19 matching lines...) Expand all Loading... |
154 // between Android and non-Android cast_shell. | 172 // between Android and non-Android cast_shell. |
155 webview->setDefaultPageScaleLimits(1.f, 1.f); | 173 webview->setDefaultPageScaleLimits(1.f, 1.f); |
156 webview->setInitialPageScaleOverride(1.f); | 174 webview->setInitialPageScaleOverride(1.f); |
157 | 175 |
158 // Disable application cache as Chromecast doesn't support off-line | 176 // Disable application cache as Chromecast doesn't support off-line |
159 // application running. | 177 // application running. |
160 webview->settings()->setOfflineWebApplicationCacheEnabled(false); | 178 webview->settings()->setOfflineWebApplicationCacheEnabled(false); |
161 } | 179 } |
162 | 180 |
163 // Note: RenderView will own the lifetime of its observer. | 181 // Note: RenderView will own the lifetime of its observer. |
164 new CastRenderViewObserver(render_view); | 182 new CastRenderViewObserver(this, render_view); |
165 } | 183 } |
166 | 184 |
167 void CastContentRendererClient::AddKeySystems( | 185 void CastContentRendererClient::AddKeySystems( |
168 std::vector< ::media::KeySystemInfo>* key_systems) { | 186 std::vector< ::media::KeySystemInfo>* key_systems) { |
169 AddChromecastKeySystems(key_systems); | 187 AddChromecastKeySystems(key_systems); |
170 AddChromecastPlatformKeySystems(key_systems); | |
171 } | 188 } |
172 | 189 |
173 #if !defined(OS_ANDROID) | 190 #if !defined(OS_ANDROID) |
174 scoped_ptr<::media::RendererFactory> | 191 scoped_ptr<::media::RendererFactory> |
175 CastContentRendererClient::CreateMediaRendererFactory( | 192 CastContentRendererClient::CreateMediaRendererFactory( |
176 ::content::RenderFrame* render_frame, | 193 ::content::RenderFrame* render_frame, |
177 const scoped_refptr<::media::MediaLog>& media_log) { | 194 const scoped_refptr<::media::MediaLog>& media_log) { |
178 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 195 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
179 if (!cmd_line->HasSwitch(switches::kEnableCmaMediaPipeline)) | 196 if (!cmd_line->HasSwitch(switches::kEnableCmaMediaPipeline)) |
180 return nullptr; | 197 return nullptr; |
(...skipping 16 matching lines...) Expand all Loading... |
197 closure.Run(); | 214 closure.Run(); |
198 return; | 215 return; |
199 } | 216 } |
200 | 217 |
201 // Lifetime is tied to |render_frame| via content::RenderFrameObserver. | 218 // Lifetime is tied to |render_frame| via content::RenderFrameObserver. |
202 new CastMediaLoadDeferrer(render_frame, closure); | 219 new CastMediaLoadDeferrer(render_frame, closure); |
203 } | 220 } |
204 | 221 |
205 } // namespace shell | 222 } // namespace shell |
206 } // namespace chromecast | 223 } // namespace chromecast |
OLD | NEW |