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

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

Issue 866173002: Plugin Power Saver: Add UI Overlay to throttled plugin using placeholder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::DictionaryValue values; 157 base::DictionaryValue values;
158 values.SetString("message", message); 158 values.SetString("message", message);
159 values.SetString("name", name); 159 values.SetString("name", name);
160 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); 160 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE));
161 161
162 if (poster_url.is_valid()) 162 if (poster_url.is_valid())
163 values.SetString("background", "url('" + poster_url.spec() + "')"); 163 values.SetString("background", "url('" + poster_url.spec() + "')");
164 164
165 const base::StringPiece template_html( 165 const base::StringPiece template_html(
166 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); 166 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
167 167
168 DCHECK(!template_html.empty()) << "unable to load template. ID: " 168 DCHECK(!template_html.empty()) << "unable to load template. ID: "
169 << template_id; 169 << template_id;
170 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); 170 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
171 171
172 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. 172 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away.
173 ChromePluginPlaceholder* blocked_plugin = new ChromePluginPlaceholder( 173 ChromePluginPlaceholder* blocked_plugin = new ChromePluginPlaceholder(
174 render_frame, frame, params, html_data, name); 174 render_frame, frame, params, html_data, name);
175 175
176 #if defined(ENABLE_PLUGINS) 176 #if defined(ENABLE_PLUGINS)
177 if (poster_url.is_valid()) 177 if (poster_url.is_valid())
178 blocked_plugin->BlockForPowerSaverPoster(); 178 blocked_plugin->BlockForPowerSaverPoster();
179 #endif 179 #endif
180 blocked_plugin->SetPluginInfo(plugin); 180 blocked_plugin->SetPluginInfo(info);
181 blocked_plugin->SetIdentifier(identifier); 181 blocked_plugin->SetIdentifier(identifier);
182 return blocked_plugin; 182 return blocked_plugin;
183 } 183 }
184 184
185 void ChromePluginPlaceholder::SetStatus( 185 void ChromePluginPlaceholder::SetStatus(
186 const ChromeViewHostMsg_GetPluginInfo_Status& status) { 186 const ChromeViewHostMsg_GetPluginInfo_Status& status) {
187 status_->value = status.value; 187 status_->value = status.value;
188 } 188 }
189 189
190 #if defined(ENABLE_PLUGIN_INSTALLATION) 190 #if defined(ENABLE_PLUGIN_INSTALLATION)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 v8::Handle<v8::Object> global = context->Global(); 372 v8::Handle<v8::Object> global = context->Global();
373 global->Set(gin::StringToV8(isolate, "plugin"), 373 global->Set(gin::StringToV8(isolate, "plugin"),
374 gin::CreateHandle(isolate, this).ToV8()); 374 gin::CreateHandle(isolate, this).ToV8());
375 } 375 }
376 376
377 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( 377 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder(
378 v8::Isolate* isolate) { 378 v8::Isolate* isolate) {
379 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( 379 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod(
380 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); 380 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback);
381 } 381 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | chrome/renderer/plugins/plugin_preroller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698