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

Side by Side Diff: chrome/renderer/plugins/chrome_plugin_placeholder.cc

Issue 981623003: Plugin Power Saver: Implement srcset syntax for posters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
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& info, 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 std::string& poster_attribute,
157 const GURL& base_url) {
157 base::DictionaryValue values; 158 base::DictionaryValue values;
158 values.SetString("message", message); 159 values.SetString("message", message);
159 values.SetString("name", name); 160 values.SetString("name", name);
160 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); 161 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE));
161 162
162 if (poster_url.is_valid()) 163 if (!poster_attribute.empty()) {
163 values.SetString("background", "url('" + poster_url.spec() + "')"); 164 values.SetString("poster", poster_attribute);
165 values.SetString("baseurl", base_url.spec());
166 }
164 167
165 const base::StringPiece template_html( 168 const base::StringPiece template_html(
166 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); 169 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
167 170
168 DCHECK(!template_html.empty()) << "unable to load template. ID: " 171 DCHECK(!template_html.empty()) << "unable to load template. ID: "
169 << template_id; 172 << template_id;
170 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); 173 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
171 174
172 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. 175 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away.
173 ChromePluginPlaceholder* blocked_plugin = new ChromePluginPlaceholder( 176 ChromePluginPlaceholder* blocked_plugin = new ChromePluginPlaceholder(
174 render_frame, frame, params, html_data, name); 177 render_frame, frame, params, html_data, name);
175 178
176 #if defined(ENABLE_PLUGINS) 179 #if defined(ENABLE_PLUGINS)
177 if (poster_url.is_valid()) 180 if (!poster_attribute.empty())
178 blocked_plugin->BlockForPowerSaverPoster(); 181 blocked_plugin->BlockForPowerSaverPoster();
179 #endif 182 #endif
180 blocked_plugin->SetPluginInfo(info); 183 blocked_plugin->SetPluginInfo(info);
181 blocked_plugin->SetIdentifier(identifier); 184 blocked_plugin->SetIdentifier(identifier);
182 return blocked_plugin; 185 return blocked_plugin;
183 } 186 }
184 187
185 void ChromePluginPlaceholder::SetStatus( 188 void ChromePluginPlaceholder::SetStatus(
186 const ChromeViewHostMsg_GetPluginInfo_Status& status) { 189 const ChromeViewHostMsg_GetPluginInfo_Status& status) {
187 status_->value = status.value; 190 status_->value = status.value;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 v8::Handle<v8::Object> global = context->Global(); 377 v8::Handle<v8::Object> global = context->Global();
375 global->Set(gin::StringToV8(isolate, "plugin"), 378 global->Set(gin::StringToV8(isolate, "plugin"),
376 gin::CreateHandle(isolate, this).ToV8()); 379 gin::CreateHandle(isolate, this).ToV8());
377 } 380 }
378 381
379 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( 382 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder(
380 v8::Isolate* isolate) { 383 v8::Isolate* isolate) {
381 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( 384 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod(
382 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); 385 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback);
383 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698