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

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

Issue 1528653002: Revert of Plugin Power Saver: Improve Poster behavior for essential plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // static 103 // static
104 ChromePluginPlaceholder* ChromePluginPlaceholder::CreateBlockedPlugin( 104 ChromePluginPlaceholder* ChromePluginPlaceholder::CreateBlockedPlugin(
105 content::RenderFrame* render_frame, 105 content::RenderFrame* render_frame,
106 blink::WebLocalFrame* frame, 106 blink::WebLocalFrame* frame,
107 const blink::WebPluginParams& params, 107 const blink::WebPluginParams& params,
108 const content::WebPluginInfo& info, 108 const content::WebPluginInfo& info,
109 const std::string& identifier, 109 const std::string& identifier,
110 const base::string16& name, 110 const base::string16& name,
111 int template_id, 111 int template_id,
112 const base::string16& message, 112 const base::string16& message,
113 const PowerSaverInfo& power_saver_info) { 113 const PlaceholderPosterInfo& poster_info) {
114 base::DictionaryValue values; 114 base::DictionaryValue values;
115 values.SetString("message", message); 115 values.SetString("message", message);
116 values.SetString("name", name); 116 values.SetString("name", name);
117 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); 117 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE));
118 values.SetString("pluginType", 118 values.SetString("pluginType",
119 frame->view()->mainFrame()->isWebLocalFrame() && 119 frame->view()->mainFrame()->isWebLocalFrame() &&
120 frame->view()->mainFrame()->document().isPluginDocument() 120 frame->view()->mainFrame()->document().isPluginDocument()
121 ? "document" 121 ? "document"
122 : "embedded"); 122 : "embedded");
123 123
124 if (!power_saver_info.poster_attribute.empty()) { 124 if (!poster_info.poster_attribute.empty()) {
125 values.SetString("poster", power_saver_info.poster_attribute); 125 values.SetString("poster", poster_info.poster_attribute);
126 values.SetString("baseurl", power_saver_info.base_url.spec()); 126 values.SetString("baseurl", poster_info.base_url.spec());
127 127
128 if (!power_saver_info.custom_poster_size.IsEmpty()) { 128 if (!poster_info.custom_poster_size.IsEmpty()) {
129 float zoom_factor = 129 float zoom_factor =
130 blink::WebView::zoomLevelToZoomFactor(frame->view()->zoomLevel()); 130 blink::WebView::zoomLevelToZoomFactor(frame->view()->zoomLevel());
131 int width = 131 int width = roundf(poster_info.custom_poster_size.width() / zoom_factor);
132 roundf(power_saver_info.custom_poster_size.width() / zoom_factor);
133 int height = 132 int height =
134 roundf(power_saver_info.custom_poster_size.height() / zoom_factor); 133 roundf(poster_info.custom_poster_size.height() / zoom_factor);
135 values.SetString("visibleWidth", base::IntToString(width) + "px"); 134 values.SetString("visibleWidth", base::IntToString(width) + "px");
136 values.SetString("visibleHeight", base::IntToString(height) + "px"); 135 values.SetString("visibleHeight", base::IntToString(height) + "px");
137 } 136 }
138 } 137 }
139 138
140 const base::StringPiece template_html( 139 const base::StringPiece template_html(
141 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); 140 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
142 141
143 DCHECK(!template_html.empty()) << "unable to load template. ID: " 142 DCHECK(!template_html.empty()) << "unable to load template. ID: "
144 << template_id; 143 << template_id;
145 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); 144 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
146 145
147 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. 146 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away.
148 ChromePluginPlaceholder* blocked_plugin = new ChromePluginPlaceholder( 147 ChromePluginPlaceholder* blocked_plugin = new ChromePluginPlaceholder(
149 render_frame, frame, params, html_data, name); 148 render_frame, frame, params, html_data, name);
150 149
151 if (!power_saver_info.poster_attribute.empty()) 150 if (!poster_info.poster_attribute.empty())
152 blocked_plugin->BlockForPowerSaverPoster(); 151 blocked_plugin->BlockForPowerSaverPoster();
153 blocked_plugin->SetPluginInfo(info); 152 blocked_plugin->SetPluginInfo(info);
154 blocked_plugin->SetIdentifier(identifier); 153 blocked_plugin->SetIdentifier(identifier);
155
156 blocked_plugin->set_power_saver_enabled(power_saver_info.power_saver_enabled);
157 blocked_plugin->set_blocked_for_background_tab(
158 power_saver_info.blocked_for_background_tab);
159
160 return blocked_plugin; 154 return blocked_plugin;
161 } 155 }
162 156
163 void ChromePluginPlaceholder::SetStatus( 157 void ChromePluginPlaceholder::SetStatus(
164 ChromeViewHostMsg_GetPluginInfo_Status status) { 158 ChromeViewHostMsg_GetPluginInfo_Status status) {
165 status_ = status; 159 status_ = status;
166 } 160 }
167 161
168 #if defined(ENABLE_PLUGIN_INSTALLATION) 162 #if defined(ENABLE_PLUGIN_INSTALLATION)
169 int32 ChromePluginPlaceholder::CreateRoutingId() { 163 int32 ChromePluginPlaceholder::CreateRoutingId() {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 374
381 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 375 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
382 switches::kEnablePluginPlaceholderTesting)) { 376 switches::kEnablePluginPlaceholderTesting)) {
383 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( 377 builder.SetMethod<void (ChromePluginPlaceholder::*)()>(
384 "didFinishIconRepositionForTesting", 378 "didFinishIconRepositionForTesting",
385 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); 379 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback);
386 } 380 }
387 381
388 return builder; 382 return builder;
389 } 383 }
OLDNEW
« no previous file with comments | « chrome/renderer/plugins/chrome_plugin_placeholder.h ('k') | chrome/renderer/plugins/plugin_preroller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698