Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugin_placeholder.h" | 5 #include "chrome/renderer/plugins/plugin_placeholder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 // static | 102 // static |
| 103 PluginPlaceholder* PluginPlaceholder::CreateMissingPlugin( | 103 PluginPlaceholder* PluginPlaceholder::CreateMissingPlugin( |
| 104 RenderView* render_view, | 104 RenderView* render_view, |
| 105 WebFrame* frame, | 105 WebFrame* frame, |
| 106 const WebPluginParams& params) { | 106 const WebPluginParams& params) { |
| 107 const base::StringPiece template_html( | 107 const base::StringPiece template_html( |
| 108 ResourceBundle::GetSharedInstance().GetRawDataResource( | 108 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 109 IDR_BLOCKED_PLUGIN_HTML)); | 109 IDR_BLOCKED_PLUGIN_HTML)); |
| 110 | 110 |
| 111 DictionaryValue values; | 111 DictionaryValue values; |
| 112 #if defined(ENABLE_PLUGIN_INSTALLATION) | |
| 112 values.SetString("message", l10n_util::GetStringUTF8(IDS_PLUGIN_SEARCHING)); | 113 values.SetString("message", l10n_util::GetStringUTF8(IDS_PLUGIN_SEARCHING)); |
| 114 #else | |
| 115 values.SetString("message", | |
| 116 l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED)); | |
| 117 #endif | |
| 113 | 118 |
| 114 std::string html_data = | 119 std::string html_data = |
| 115 jstemplate_builder::GetI18nTemplateHtml(template_html, &values); | 120 jstemplate_builder::GetI18nTemplateHtml(template_html, &values); |
| 116 | 121 |
| 117 // |missing_plugin| will destroy itself when its WebViewPlugin is going away. | 122 // |missing_plugin| will destroy itself when its WebViewPlugin is going away. |
| 118 PluginPlaceholder* missing_plugin = new PluginPlaceholder( | 123 PluginPlaceholder* missing_plugin = new PluginPlaceholder( |
| 119 render_view, frame, params, html_data, params.mimeType); | 124 render_view, frame, params, html_data, params.mimeType); |
| 120 missing_plugin->set_allow_loading(true); | 125 missing_plugin->set_allow_loading(true); |
| 121 #if defined(ENABLE_PLUGIN_INSTALLATION) | 126 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 122 RenderThread::Get()->Send(new ChromeViewHostMsg_FindMissingPlugin( | 127 RenderThread::Get()->Send(new ChromeViewHostMsg_FindMissingPlugin( |
| 123 missing_plugin->routing_id(), missing_plugin->CreateRoutingId(), | 128 missing_plugin->routing_id(), missing_plugin->CreateRoutingId(), |
| 124 params.mimeType.utf8())); | 129 params.mimeType.utf8())); |
| 125 #else | |
| 126 missing_plugin->OnDidNotFindMissingPlugin(); | |
| 127 #endif | 130 #endif |
| 128 return missing_plugin; | 131 return missing_plugin; |
| 129 } | 132 } |
| 130 | 133 |
| 131 PluginPlaceholder* PluginPlaceholder::CreateErrorPlugin( | 134 PluginPlaceholder* PluginPlaceholder::CreateErrorPlugin( |
| 132 RenderView* render_view, | 135 RenderView* render_view, |
| 133 const FilePath& file_path) { | 136 const FilePath& file_path) { |
| 134 DictionaryValue values; | 137 DictionaryValue values; |
| 135 values.SetString("message", | 138 values.SetString("message", |
| 136 l10n_util::GetStringUTF8(IDS_PLUGIN_INITIALIZATION_ERROR)); | 139 l10n_util::GetStringUTF8(IDS_PLUGIN_INITIALIZATION_ERROR)); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 element.setAttribute("style", "display: none;"); | 403 element.setAttribute("style", "display: none;"); |
| 401 } | 404 } |
| 402 } | 405 } |
| 403 } | 406 } |
| 404 } | 407 } |
| 405 | 408 |
| 406 void PluginPlaceholder::WillDestroyPlugin() { | 409 void PluginPlaceholder::WillDestroyPlugin() { |
| 407 delete this; | 410 delete this; |
| 408 } | 411 } |
| 409 | 412 |
| 410 void PluginPlaceholder::OnDidNotFindMissingPlugin() { | 413 void PluginPlaceholder::OnDidNotFindMissingPlugin() { |
|
Bernhard Bauer
2012/11/30 14:58:33
Could you move this into the #if defined(ENABLE_PL
newt (away)
2012/11/30 19:41:18
Done.
| |
| 411 SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_FOUND)); | 414 SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_FOUND)); |
| 412 } | 415 } |
| 413 | 416 |
| 414 #if defined(ENABLE_PLUGIN_INSTALLATION) | 417 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 415 void PluginPlaceholder::OnFoundMissingPlugin(const string16& plugin_name) { | 418 void PluginPlaceholder::OnFoundMissingPlugin(const string16& plugin_name) { |
| 416 if (status_->value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) | 419 if (status_->value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) |
| 417 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_FOUND, plugin_name)); | 420 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_FOUND, plugin_name)); |
| 418 has_host_ = true; | 421 has_host_ = true; |
| 419 plugin_name_ = plugin_name; | 422 plugin_name_ = plugin_name; |
| 420 } | 423 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 bool PluginPlaceholder::IsYouTubeURL(const GURL& url, | 648 bool PluginPlaceholder::IsYouTubeURL(const GURL& url, |
| 646 const std::string& mime_type) { | 649 const std::string& mime_type) { |
| 647 std::string host = url.host(); | 650 std::string host = url.host(); |
| 648 bool is_youtube = EndsWith(host, "youtube.com", true) || | 651 bool is_youtube = EndsWith(host, "youtube.com", true) || |
| 649 EndsWith(host, "youtube-nocookie.com", true); | 652 EndsWith(host, "youtube-nocookie.com", true); |
| 650 | 653 |
| 651 return is_youtube && IsValidYouTubeVideo(url.path()) && | 654 return is_youtube && IsValidYouTubeVideo(url.path()) && |
| 652 LowerCaseEqualsASCII(mime_type, kFlashPluginSwfMimeType); | 655 LowerCaseEqualsASCII(mime_type, kFlashPluginSwfMimeType); |
| 653 } | 656 } |
| 654 #endif | 657 #endif |
| OLD | NEW |