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

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

Issue 2845413002: Plugin Power Saver: Add missing RenderFrame null-checks in placeholders (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | components/plugins/renderer/loadable_plugin_placeholder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 prerender::PrerenderMode mode) { 228 prerender::PrerenderMode mode) {
229 OnSetIsPrerendering(mode != prerender::NO_PRERENDER); 229 OnSetIsPrerendering(mode != prerender::NO_PRERENDER);
230 } 230 }
231 231
232 void ChromePluginPlaceholder::PluginListChanged() { 232 void ChromePluginPlaceholder::PluginListChanged() {
233 if (!GetFrame() || !plugin()) 233 if (!GetFrame() || !plugin())
234 return; 234 return;
235 235
236 ChromeViewHostMsg_GetPluginInfo_Output output; 236 ChromeViewHostMsg_GetPluginInfo_Output output;
237 std::string mime_type(GetPluginParams().mime_type.Utf8()); 237 std::string mime_type(GetPluginParams().mime_type.Utf8());
238 render_frame()->Send(new ChromeViewHostMsg_GetPluginInfo( 238 render_frame()->Send(new ChromeViewHostMsg_GetPluginInfo(
raymes 2017/04/30 23:34:33 Do we need to check on this occasion too?
tommycli 2017/05/01 15:37:18 Hi. GetFrame() is an equivalent check. It returns
raymes 2017/05/01 22:10:26 Ah that makes sense. Thanks :) Maybe add a comment
tommycli 2017/05/01 22:15:55 Done. Thanks. I added a comment and DCHECK on the
239 routing_id(), GURL(GetPluginParams().url), 239 routing_id(), GURL(GetPluginParams().url),
240 GetFrame()->Top()->GetSecurityOrigin(), mime_type, &output)); 240 GetFrame()->Top()->GetSecurityOrigin(), mime_type, &output));
241 if (output.status == status_) 241 if (output.status == status_)
242 return; 242 return;
243 blink::WebPlugin* new_plugin = ChromeContentRendererClient::CreatePlugin( 243 blink::WebPlugin* new_plugin = ChromeContentRendererClient::CreatePlugin(
244 render_frame(), GetFrame(), GetPluginParams(), output); 244 render_frame(), GetFrame(), GetPluginParams(), output);
245 ReplacePlugin(new_plugin); 245 ReplacePlugin(new_plugin);
246 if (!new_plugin) { 246 if (!new_plugin) {
247 PluginUMAReporter::GetInstance()->ReportPluginMissing( 247 PluginUMAReporter::GetInstance()->ReportPluginMissing(
248 GetPluginParams().mime_type.Utf8(), GURL(GetPluginParams().url)); 248 GetPluginParams().mime_type.Utf8(), GURL(GetPluginParams().url));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 v8::Local<v8::Value> ChromePluginPlaceholder::GetV8Handle( 283 v8::Local<v8::Value> ChromePluginPlaceholder::GetV8Handle(
284 v8::Isolate* isolate) { 284 v8::Isolate* isolate) {
285 return gin::CreateHandle(isolate, this).ToV8(); 285 return gin::CreateHandle(isolate, this).ToV8();
286 } 286 }
287 287
288 void ChromePluginPlaceholder::ShowContextMenu( 288 void ChromePluginPlaceholder::ShowContextMenu(
289 const blink::WebMouseEvent& event) { 289 const blink::WebMouseEvent& event) {
290 if (context_menu_request_id_) 290 if (context_menu_request_id_)
291 return; // Don't allow nested context menu requests. 291 return; // Don't allow nested context menu requests.
292 if (!render_frame())
293 return;
292 294
293 content::ContextMenuParams params; 295 content::ContextMenuParams params;
294 296
295 if (!title_.empty()) { 297 if (!title_.empty()) {
296 content::MenuItem name_item; 298 content::MenuItem name_item;
297 name_item.label = title_; 299 name_item.label = title_;
298 params.custom_items.push_back(name_item); 300 params.custom_items.push_back(name_item);
299 301
300 content::MenuItem separator_item; 302 content::MenuItem separator_item;
301 separator_item.type = content::MenuItem::SEPARATOR; 303 separator_item.type = content::MenuItem::SEPARATOR;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 new PluginPreroller(render_frame(), GetFrame(), GetPluginParams(), 356 new PluginPreroller(render_frame(), GetFrame(), GetPluginParams(),
355 GetPluginInfo(), GetIdentifier(), title_, 357 GetPluginInfo(), GetIdentifier(), title_,
356 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, title_), 358 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, title_),
357 throttler.get()); 359 throttler.get());
358 } 360 }
359 return render_frame()->CreatePlugin(GetFrame(), GetPluginInfo(), 361 return render_frame()->CreatePlugin(GetFrame(), GetPluginInfo(),
360 GetPluginParams(), std::move(throttler)); 362 GetPluginParams(), std::move(throttler));
361 } 363 }
362 364
363 void ChromePluginPlaceholder::OnBlockedTinyContent() { 365 void ChromePluginPlaceholder::OnBlockedTinyContent() {
366 DCHECK(render_frame());
364 if (did_send_blocked_content_notification_) 367 if (did_send_blocked_content_notification_)
365 return; 368 return;
366 369
367 did_send_blocked_content_notification_ = true; 370 did_send_blocked_content_notification_ = true;
368 ContentSettingsObserver::Get(render_frame()) 371 ContentSettingsObserver::Get(render_frame())
369 ->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, title_); 372 ->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, title_);
370 } 373 }
371 374
372 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( 375 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder(
373 v8::Isolate* isolate) { 376 v8::Isolate* isolate) {
(...skipping 11 matching lines...) Expand all
385 388
386 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 389 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
387 switches::kEnablePluginPlaceholderTesting)) { 390 switches::kEnablePluginPlaceholderTesting)) {
388 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( 391 builder.SetMethod<void (ChromePluginPlaceholder::*)()>(
389 "didFinishIconRepositionForTesting", 392 "didFinishIconRepositionForTesting",
390 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); 393 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback);
391 } 394 }
392 395
393 return builder; 396 return builder;
394 } 397 }
OLDNEW
« no previous file with comments | « no previous file | components/plugins/renderer/loadable_plugin_placeholder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698