| OLD | NEW |
| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 void ChromePluginPlaceholder::OnSetPrerenderMode( | 227 void ChromePluginPlaceholder::OnSetPrerenderMode( |
| 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 // Checking with GetFrame() is equivalent to checking render_frame(). |
| 237 DCHECK(render_frame()); |
| 238 |
| 236 ChromeViewHostMsg_GetPluginInfo_Output output; | 239 ChromeViewHostMsg_GetPluginInfo_Output output; |
| 237 std::string mime_type(GetPluginParams().mime_type.Utf8()); | 240 std::string mime_type(GetPluginParams().mime_type.Utf8()); |
| 238 render_frame()->Send(new ChromeViewHostMsg_GetPluginInfo( | 241 render_frame()->Send(new ChromeViewHostMsg_GetPluginInfo( |
| 239 routing_id(), GURL(GetPluginParams().url), | 242 routing_id(), GURL(GetPluginParams().url), |
| 240 GetFrame()->Top()->GetSecurityOrigin(), mime_type, &output)); | 243 GetFrame()->Top()->GetSecurityOrigin(), mime_type, &output)); |
| 241 if (output.status == status_) | 244 if (output.status == status_) |
| 242 return; | 245 return; |
| 243 blink::WebPlugin* new_plugin = ChromeContentRendererClient::CreatePlugin( | 246 blink::WebPlugin* new_plugin = ChromeContentRendererClient::CreatePlugin( |
| 244 render_frame(), GetFrame(), GetPluginParams(), output); | 247 render_frame(), GetFrame(), GetPluginParams(), output); |
| 245 ReplacePlugin(new_plugin); | 248 ReplacePlugin(new_plugin); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 285 |
| 283 v8::Local<v8::Value> ChromePluginPlaceholder::GetV8Handle( | 286 v8::Local<v8::Value> ChromePluginPlaceholder::GetV8Handle( |
| 284 v8::Isolate* isolate) { | 287 v8::Isolate* isolate) { |
| 285 return gin::CreateHandle(isolate, this).ToV8(); | 288 return gin::CreateHandle(isolate, this).ToV8(); |
| 286 } | 289 } |
| 287 | 290 |
| 288 void ChromePluginPlaceholder::ShowContextMenu( | 291 void ChromePluginPlaceholder::ShowContextMenu( |
| 289 const blink::WebMouseEvent& event) { | 292 const blink::WebMouseEvent& event) { |
| 290 if (context_menu_request_id_) | 293 if (context_menu_request_id_) |
| 291 return; // Don't allow nested context menu requests. | 294 return; // Don't allow nested context menu requests. |
| 295 if (!render_frame()) |
| 296 return; |
| 292 | 297 |
| 293 content::ContextMenuParams params; | 298 content::ContextMenuParams params; |
| 294 | 299 |
| 295 if (!title_.empty()) { | 300 if (!title_.empty()) { |
| 296 content::MenuItem name_item; | 301 content::MenuItem name_item; |
| 297 name_item.label = title_; | 302 name_item.label = title_; |
| 298 params.custom_items.push_back(name_item); | 303 params.custom_items.push_back(name_item); |
| 299 | 304 |
| 300 content::MenuItem separator_item; | 305 content::MenuItem separator_item; |
| 301 separator_item.type = content::MenuItem::SEPARATOR; | 306 separator_item.type = content::MenuItem::SEPARATOR; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 new PluginPreroller(render_frame(), GetFrame(), GetPluginParams(), | 359 new PluginPreroller(render_frame(), GetFrame(), GetPluginParams(), |
| 355 GetPluginInfo(), GetIdentifier(), title_, | 360 GetPluginInfo(), GetIdentifier(), title_, |
| 356 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, title_), | 361 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, title_), |
| 357 throttler.get()); | 362 throttler.get()); |
| 358 } | 363 } |
| 359 return render_frame()->CreatePlugin(GetFrame(), GetPluginInfo(), | 364 return render_frame()->CreatePlugin(GetFrame(), GetPluginInfo(), |
| 360 GetPluginParams(), std::move(throttler)); | 365 GetPluginParams(), std::move(throttler)); |
| 361 } | 366 } |
| 362 | 367 |
| 363 void ChromePluginPlaceholder::OnBlockedTinyContent() { | 368 void ChromePluginPlaceholder::OnBlockedTinyContent() { |
| 369 DCHECK(render_frame()); |
| 364 if (did_send_blocked_content_notification_) | 370 if (did_send_blocked_content_notification_) |
| 365 return; | 371 return; |
| 366 | 372 |
| 367 did_send_blocked_content_notification_ = true; | 373 did_send_blocked_content_notification_ = true; |
| 368 ContentSettingsObserver::Get(render_frame()) | 374 ContentSettingsObserver::Get(render_frame()) |
| 369 ->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, title_); | 375 ->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, title_); |
| 370 } | 376 } |
| 371 | 377 |
| 372 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( | 378 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( |
| 373 v8::Isolate* isolate) { | 379 v8::Isolate* isolate) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 385 | 391 |
| 386 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 392 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 387 switches::kEnablePluginPlaceholderTesting)) { | 393 switches::kEnablePluginPlaceholderTesting)) { |
| 388 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( | 394 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( |
| 389 "didFinishIconRepositionForTesting", | 395 "didFinishIconRepositionForTesting", |
| 390 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); | 396 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); |
| 391 } | 397 } |
| 392 | 398 |
| 393 return builder; | 399 return builder; |
| 394 } | 400 } |
| OLD | NEW |