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/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/prerender_messages.h" | 9 #include "chrome/common/prerender_messages.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 RenderThread::Get()->Send(new ChromeViewHostMsg_CouldNotLoadPlugin( | 141 RenderThread::Get()->Send(new ChromeViewHostMsg_CouldNotLoadPlugin( |
142 plugin->routing_id(), file_path)); | 142 plugin->routing_id(), file_path)); |
143 return plugin; | 143 return plugin; |
144 } | 144 } |
145 | 145 |
146 // static | 146 // static |
147 ChromePluginPlaceholder* ChromePluginPlaceholder::CreateBlockedPlugin( | 147 ChromePluginPlaceholder* ChromePluginPlaceholder::CreateBlockedPlugin( |
148 content::RenderFrame* render_frame, | 148 content::RenderFrame* render_frame, |
149 WebLocalFrame* frame, | 149 WebLocalFrame* frame, |
150 const WebPluginParams& params, | 150 const WebPluginParams& params, |
151 const content::WebPluginInfo& plugin, | 151 const content::WebPluginInfo& info, |
152 const std::string& identifier, | 152 const std::string& identifier, |
153 const base::string16& name, | 153 const base::string16& name, |
154 int template_id, | 154 int template_id, |
155 const base::string16& message, | 155 const base::string16& message, |
156 const GURL& poster_url) { | 156 const GURL& poster_url, |
157 blink::WebPlugin* premade_plugin, | |
158 content::PluginInstanceThrottler* premade_throttler) { | |
157 base::DictionaryValue values; | 159 base::DictionaryValue values; |
158 values.SetString("message", message); | 160 values.SetString("message", message); |
159 values.SetString("name", name); | 161 values.SetString("name", name); |
160 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); | 162 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); |
161 | 163 |
162 if (poster_url.is_valid()) | 164 if (poster_url.is_valid()) |
163 values.SetString("background", "url('" + poster_url.spec() + "')"); | 165 values.SetString("background", "url('" + poster_url.spec() + "')"); |
164 | 166 |
165 const base::StringPiece template_html( | 167 const base::StringPiece template_html( |
166 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); | 168 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); |
167 | 169 |
168 DCHECK(!template_html.empty()) << "unable to load template. ID: " | 170 DCHECK(!template_html.empty()) << "unable to load template. ID: " |
169 << template_id; | 171 << template_id; |
170 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); | 172 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); |
171 | 173 |
172 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. | 174 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. |
173 ChromePluginPlaceholder* blocked_plugin = new ChromePluginPlaceholder( | 175 ChromePluginPlaceholder* blocked_plugin = new ChromePluginPlaceholder( |
174 render_frame, frame, params, html_data, name); | 176 render_frame, frame, params, html_data, name); |
175 | 177 |
176 #if defined(ENABLE_PLUGINS) | 178 #if defined(ENABLE_PLUGINS) |
177 if (poster_url.is_valid()) | 179 if (poster_url.is_valid()) |
178 blocked_plugin->BlockForPowerSaverPoster(); | 180 blocked_plugin->BlockForPowerSaverPoster(); |
179 #endif | 181 #endif |
180 blocked_plugin->SetPluginInfo(plugin); | 182 if (premade_plugin && premade_throttler) |
Lei Zhang
2015/01/30 21:50:07
Can the CreateBlockedPlugin() caller do this inste
tommycli
2015/02/02 18:35:47
Done.
| |
183 blocked_plugin->SetPremadePlugin(premade_plugin, premade_throttler); | |
184 blocked_plugin->SetPluginInfo(info); | |
181 blocked_plugin->SetIdentifier(identifier); | 185 blocked_plugin->SetIdentifier(identifier); |
182 return blocked_plugin; | 186 return blocked_plugin; |
183 } | 187 } |
184 | 188 |
185 void ChromePluginPlaceholder::SetStatus( | 189 void ChromePluginPlaceholder::SetStatus( |
186 const ChromeViewHostMsg_GetPluginInfo_Status& status) { | 190 const ChromeViewHostMsg_GetPluginInfo_Status& status) { |
187 status_->value = status.value; | 191 status_->value = status.value; |
188 } | 192 } |
189 | 193 |
190 #if defined(ENABLE_PLUGIN_INSTALLATION) | 194 #if defined(ENABLE_PLUGIN_INSTALLATION) |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 v8::Handle<v8::Object> global = context->Global(); | 376 v8::Handle<v8::Object> global = context->Global(); |
373 global->Set(gin::StringToV8(isolate, "plugin"), | 377 global->Set(gin::StringToV8(isolate, "plugin"), |
374 gin::CreateHandle(isolate, this).ToV8()); | 378 gin::CreateHandle(isolate, this).ToV8()); |
375 } | 379 } |
376 | 380 |
377 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( | 381 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( |
378 v8::Isolate* isolate) { | 382 v8::Isolate* isolate) { |
379 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( | 383 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( |
380 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); | 384 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); |
381 } | 385 } |
OLD | NEW |