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

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: use gfx::Size 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"
17 #include "content/public/common/context_menu_params.h" 18 #include "content/public/common/context_menu_params.h"
18 #include "content/public/renderer/render_frame.h" 19 #include "content/public/renderer/render_frame.h"
19 #include "content/public/renderer/render_thread.h" 20 #include "content/public/renderer/render_thread.h"
20 #include "gin/handle.h" 21 #include "gin/handle.h"
21 #include "gin/object_template_builder.h" 22 #include "gin/object_template_builder.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 23 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebInputEvent.h" 24 #include "third_party/WebKit/public/web/WebInputEvent.h"
24 #include "third_party/WebKit/public/web/WebKit.h" 25 #include "third_party/WebKit/public/web/WebKit.h"
25 #include "third_party/WebKit/public/web/WebLocalFrame.h" 26 #include "third_party/WebKit/public/web/WebLocalFrame.h"
26 #include "third_party/WebKit/public/web/WebScriptSource.h" 27 #include "third_party/WebKit/public/web/WebScriptSource.h"
27 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
29 #include "ui/base/webui/jstemplate_builder.h" 30 #include "ui/base/webui/jstemplate_builder.h"
31 #include "ui/gfx/geometry/size.h"
30 #include "url/url_util.h" 32 #include "url/url_util.h"
31 33
32 using base::UserMetricsAction; 34 using base::UserMetricsAction;
33 using blink::WebDocument; 35 using blink::WebDocument;
34 using blink::WebElement; 36 using blink::WebElement;
35 using blink::WebFrame; 37 using blink::WebFrame;
36 using blink::WebLocalFrame; 38 using blink::WebLocalFrame;
37 using blink::WebMouseEvent; 39 using blink::WebMouseEvent;
38 using blink::WebNode; 40 using blink::WebNode;
39 using blink::WebPlugin; 41 using blink::WebPlugin;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ChromePluginPlaceholder* ChromePluginPlaceholder::CreateBlockedPlugin( 149 ChromePluginPlaceholder* ChromePluginPlaceholder::CreateBlockedPlugin(
148 content::RenderFrame* render_frame, 150 content::RenderFrame* render_frame,
149 WebLocalFrame* frame, 151 WebLocalFrame* frame,
150 const WebPluginParams& params, 152 const WebPluginParams& params,
151 const content::WebPluginInfo& info, 153 const content::WebPluginInfo& info,
152 const std::string& identifier, 154 const std::string& identifier,
153 const base::string16& name, 155 const base::string16& name,
154 int template_id, 156 int template_id,
155 const base::string16& message, 157 const base::string16& message,
156 const std::string& poster_attribute, 158 const std::string& poster_attribute,
157 const GURL& base_url) { 159 const GURL& base_url,
160 const gfx::Size& custom_poster_size) {
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_size.IsEmpty()) {
171 values.SetString("visibleWidth",
172 base::Int64ToString(custom_poster_size.width()) + "px");
173 values.SetString("visibleHeight",
174 base::Int64ToString(custom_poster_size.height()) + "px");
175 }
166 } 176 }
167 177
168 const base::StringPiece template_html( 178 const base::StringPiece template_html(
169 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); 179 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
170 180
171 DCHECK(!template_html.empty()) << "unable to load template. ID: " 181 DCHECK(!template_html.empty()) << "unable to load template. ID: "
172 << template_id; 182 << template_id;
173 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); 183 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
174 184
175 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. 185 // |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(); 387 v8::Handle<v8::Object> global = context->Global();
378 global->Set(gin::StringToV8(isolate, "plugin"), 388 global->Set(gin::StringToV8(isolate, "plugin"),
379 gin::CreateHandle(isolate, this).ToV8()); 389 gin::CreateHandle(isolate, this).ToV8());
380 } 390 }
381 391
382 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( 392 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder(
383 v8::Isolate* isolate) { 393 v8::Isolate* isolate) {
384 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( 394 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod(
385 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); 395 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback);
386 } 396 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698