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

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

Issue 1015023002: Plugin Power Saver: Throttle 'large' plugins that appear small. (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/string_number_conversions.h"
7 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 #include "chrome/common/prerender_messages.h" 10 #include "chrome/common/prerender_messages.h"
10 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
11 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
12 #include "chrome/grit/renderer_resources.h" 13 #include "chrome/grit/renderer_resources.h"
13 #include "chrome/renderer/chrome_content_renderer_client.h" 14 #include "chrome/renderer/chrome_content_renderer_client.h"
14 #include "chrome/renderer/custom_menu_commands.h" 15 #include "chrome/renderer/custom_menu_commands.h"
15 #include "chrome/renderer/plugins/plugin_uma.h" 16 #include "chrome/renderer/plugins/plugin_uma.h"
16 #include "content/app/strings/grit/content_strings.h" 17 #include "content/app/strings/grit/content_strings.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ChromePluginPlaceholder* ChromePluginPlaceholder::CreateBlockedPlugin( 148 ChromePluginPlaceholder* ChromePluginPlaceholder::CreateBlockedPlugin(
148 content::RenderFrame* render_frame, 149 content::RenderFrame* render_frame,
149 WebLocalFrame* frame, 150 WebLocalFrame* frame,
150 const WebPluginParams& params, 151 const WebPluginParams& params,
151 const content::WebPluginInfo& info, 152 const content::WebPluginInfo& info,
152 const std::string& identifier, 153 const std::string& identifier,
153 const base::string16& name, 154 const base::string16& name,
154 int template_id, 155 int template_id,
155 const base::string16& message, 156 const base::string16& message,
156 const std::string& poster_attribute, 157 const std::string& poster_attribute,
157 const GURL& base_url) { 158 const GURL& base_url,
159 int custom_poster_width,
160 int custom_poster_height) {
158 base::DictionaryValue values; 161 base::DictionaryValue values;
159 values.SetString("message", message); 162 values.SetString("message", message);
160 values.SetString("name", name); 163 values.SetString("name", name);
161 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); 164 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE));
162 165
163 if (!poster_attribute.empty()) { 166 if (!poster_attribute.empty()) {
164 values.SetString("poster", poster_attribute); 167 values.SetString("poster", poster_attribute);
165 values.SetString("baseurl", base_url.spec()); 168 values.SetString("baseurl", base_url.spec());
169
170 if (custom_poster_width > 0) {
171 values.SetString("visibleWidth",
172 base::Int64ToString(custom_poster_width) + "px");
173 }
174 if (custom_poster_height > 0) {
175 values.SetString("visibleHeight",
176 base::Int64ToString(custom_poster_height) + "px");
177 }
166 } 178 }
167 179
168 const base::StringPiece template_html( 180 const base::StringPiece template_html(
169 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); 181 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
170 182
171 DCHECK(!template_html.empty()) << "unable to load template. ID: " 183 DCHECK(!template_html.empty()) << "unable to load template. ID: "
172 << template_id; 184 << template_id;
173 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); 185 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
174 186
175 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. 187 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 v8::Handle<v8::Object> global = context->Global(); 389 v8::Handle<v8::Object> global = context->Global();
378 global->Set(gin::StringToV8(isolate, "plugin"), 390 global->Set(gin::StringToV8(isolate, "plugin"),
379 gin::CreateHandle(isolate, this).ToV8()); 391 gin::CreateHandle(isolate, this).ToV8());
380 } 392 }
381 393
382 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( 394 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder(
383 v8::Isolate* isolate) { 395 v8::Isolate* isolate) {
384 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( 396 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod(
385 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); 397 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback);
386 } 398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698