OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/plugins/chrome_plugin_placeholder.h" | 5 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/prerender_messages.h" | 10 #include "chrome/common/prerender_messages.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 content::RenderFrame* render_frame, | 57 content::RenderFrame* render_frame, |
58 blink::WebLocalFrame* frame, | 58 blink::WebLocalFrame* frame, |
59 const blink::WebPluginParams& params, | 59 const blink::WebPluginParams& params, |
60 const std::string& html_data, | 60 const std::string& html_data, |
61 const base::string16& title) | 61 const base::string16& title) |
62 : plugins::LoadablePluginPlaceholder(render_frame, | 62 : plugins::LoadablePluginPlaceholder(render_frame, |
63 frame, | 63 frame, |
64 params, | 64 params, |
65 html_data, | 65 html_data, |
66 GURL(kPluginPlaceholderDataURL)), | 66 GURL(kPluginPlaceholderDataURL)), |
67 status_(new ChromeViewHostMsg_GetPluginInfo_Status), | 67 status_(ChromeViewHostMsg_GetPluginInfo_Status::kAllowed), |
68 title_(title), | 68 title_(title), |
69 #if defined(ENABLE_PLUGIN_INSTALLATION) | 69 #if defined(ENABLE_PLUGIN_INSTALLATION) |
70 placeholder_routing_id_(MSG_ROUTING_NONE), | 70 placeholder_routing_id_(MSG_ROUTING_NONE), |
71 #endif | 71 #endif |
72 has_host_(false), | 72 has_host_(false), |
73 context_menu_request_id_(0) { | 73 context_menu_request_id_(0) { |
74 RenderThread::Get()->AddObserver(this); | 74 RenderThread::Get()->AddObserver(this); |
75 } | 75 } |
76 | 76 |
77 ChromePluginPlaceholder::~ChromePluginPlaceholder() { | 77 ChromePluginPlaceholder::~ChromePluginPlaceholder() { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 #if defined(ENABLE_PLUGINS) | 179 #if defined(ENABLE_PLUGINS) |
180 if (!poster_info.poster_attribute.empty()) | 180 if (!poster_info.poster_attribute.empty()) |
181 blocked_plugin->BlockForPowerSaverPoster(); | 181 blocked_plugin->BlockForPowerSaverPoster(); |
182 #endif | 182 #endif |
183 blocked_plugin->SetPluginInfo(info); | 183 blocked_plugin->SetPluginInfo(info); |
184 blocked_plugin->SetIdentifier(identifier); | 184 blocked_plugin->SetIdentifier(identifier); |
185 return blocked_plugin; | 185 return blocked_plugin; |
186 } | 186 } |
187 | 187 |
188 void ChromePluginPlaceholder::SetStatus( | 188 void ChromePluginPlaceholder::SetStatus( |
189 const ChromeViewHostMsg_GetPluginInfo_Status& status) { | 189 ChromeViewHostMsg_GetPluginInfo_Status status) { |
190 status_->value = status.value; | 190 status_ = status; |
191 } | 191 } |
192 | 192 |
193 #if defined(ENABLE_PLUGIN_INSTALLATION) | 193 #if defined(ENABLE_PLUGIN_INSTALLATION) |
194 int32 ChromePluginPlaceholder::CreateRoutingId() { | 194 int32 ChromePluginPlaceholder::CreateRoutingId() { |
195 placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); | 195 placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); |
196 RenderThread::Get()->AddRoute(placeholder_routing_id_, this); | 196 RenderThread::Get()->AddRoute(placeholder_routing_id_, this); |
197 return placeholder_routing_id_; | 197 return placeholder_routing_id_; |
198 } | 198 } |
199 #endif | 199 #endif |
200 | 200 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); | 235 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); |
236 } | 236 } |
237 | 237 |
238 #if defined(ENABLE_PLUGIN_INSTALLATION) | 238 #if defined(ENABLE_PLUGIN_INSTALLATION) |
239 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { | 239 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { |
240 SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_FOUND)); | 240 SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_FOUND)); |
241 } | 241 } |
242 | 242 |
243 void ChromePluginPlaceholder::OnFoundMissingPlugin( | 243 void ChromePluginPlaceholder::OnFoundMissingPlugin( |
244 const base::string16& plugin_name) { | 244 const base::string16& plugin_name) { |
245 if (status_->value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) | 245 if (status_ == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) |
246 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_FOUND, plugin_name)); | 246 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_FOUND, plugin_name)); |
247 has_host_ = true; | 247 has_host_ = true; |
248 plugin_name_ = plugin_name; | 248 plugin_name_ = plugin_name; |
249 } | 249 } |
250 | 250 |
251 void ChromePluginPlaceholder::OnStartedDownloadingPlugin() { | 251 void ChromePluginPlaceholder::OnStartedDownloadingPlugin() { |
252 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, plugin_name_)); | 252 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, plugin_name_)); |
253 } | 253 } |
254 | 254 |
255 void ChromePluginPlaceholder::OnFinishedDownloadingPlugin() { | 255 void ChromePluginPlaceholder::OnFinishedDownloadingPlugin() { |
256 bool is_installing = | 256 bool is_installing = |
257 status_->value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; | 257 status_ == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; |
258 SetMessage(l10n_util::GetStringFUTF16( | 258 SetMessage(l10n_util::GetStringFUTF16( |
259 is_installing ? IDS_PLUGIN_INSTALLING : IDS_PLUGIN_UPDATING, | 259 is_installing ? IDS_PLUGIN_INSTALLING : IDS_PLUGIN_UPDATING, |
260 plugin_name_)); | 260 plugin_name_)); |
261 } | 261 } |
262 | 262 |
263 void ChromePluginPlaceholder::OnErrorDownloadingPlugin( | 263 void ChromePluginPlaceholder::OnErrorDownloadingPlugin( |
264 const std::string& error) { | 264 const std::string& error) { |
265 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR, | 265 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR, |
266 base::UTF8ToUTF16(error))); | 266 base::UTF8ToUTF16(error))); |
267 } | 267 } |
(...skipping 12 matching lines...) Expand all Loading... |
280 return; | 280 return; |
281 | 281 |
282 ChromeViewHostMsg_GetPluginInfo_Output output; | 282 ChromeViewHostMsg_GetPluginInfo_Output output; |
283 std::string mime_type(GetPluginParams().mimeType.utf8()); | 283 std::string mime_type(GetPluginParams().mimeType.utf8()); |
284 render_frame()->Send( | 284 render_frame()->Send( |
285 new ChromeViewHostMsg_GetPluginInfo(routing_id(), | 285 new ChromeViewHostMsg_GetPluginInfo(routing_id(), |
286 GURL(GetPluginParams().url), | 286 GURL(GetPluginParams().url), |
287 document.url(), | 287 document.url(), |
288 mime_type, | 288 mime_type, |
289 &output)); | 289 &output)); |
290 if (output.status.value == status_->value) | 290 if (output.status == status_) |
291 return; | 291 return; |
292 WebPlugin* new_plugin = ChromeContentRendererClient::CreatePlugin( | 292 WebPlugin* new_plugin = ChromeContentRendererClient::CreatePlugin( |
293 render_frame(), GetFrame(), GetPluginParams(), output); | 293 render_frame(), GetFrame(), GetPluginParams(), output); |
294 ReplacePlugin(new_plugin); | 294 ReplacePlugin(new_plugin); |
295 if (!new_plugin) { | 295 if (!new_plugin) { |
296 PluginUMAReporter::GetInstance()->ReportPluginMissing( | 296 PluginUMAReporter::GetInstance()->ReportPluginMissing( |
297 GetPluginParams().mimeType.utf8(), GURL(GetPluginParams().url)); | 297 GetPluginParams().mimeType.utf8(), GURL(GetPluginParams().url)); |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 v8::Handle<v8::Object> global = context->Global(); | 377 v8::Handle<v8::Object> global = context->Global(); |
378 global->Set(gin::StringToV8(isolate, "plugin"), | 378 global->Set(gin::StringToV8(isolate, "plugin"), |
379 gin::CreateHandle(isolate, this).ToV8()); | 379 gin::CreateHandle(isolate, this).ToV8()); |
380 } | 380 } |
381 | 381 |
382 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( | 382 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( |
383 v8::Isolate* isolate) { | 383 v8::Isolate* isolate) { |
384 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( | 384 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( |
385 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); | 385 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); |
386 } | 386 } |
OLD | NEW |