Chromium Code Reviews| 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" |
| 11 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/common/chrome_features.h" | 15 #include "chrome/common/chrome_features.h" |
| 16 #include "chrome/common/features.h" | 16 #include "chrome/common/features.h" |
| 17 #include "chrome/common/prerender_messages.h" | 17 #include "chrome/common/prerender_messages.h" |
| 18 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
| 19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 20 #include "chrome/grit/renderer_resources.h" | 20 #include "chrome/grit/renderer_resources.h" |
| 21 #include "chrome/renderer/chrome_content_renderer_client.h" | 21 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 22 #include "chrome/renderer/content_settings_observer.h" | 22 #include "chrome/renderer/content_settings_observer.h" |
| 23 #include "chrome/renderer/custom_menu_commands.h" | 23 #include "chrome/renderer/custom_menu_commands.h" |
| 24 #include "chrome/renderer/plugins/plugin_preroller.h" | 24 #include "chrome/renderer/plugins/plugin_preroller.h" |
| 25 #include "chrome/renderer/plugins/plugin_uma.h" | 25 #include "chrome/renderer/plugins/plugin_uma.h" |
| 26 #include "components/strings/grit/components_strings.h" | 26 #include "components/strings/grit/components_strings.h" |
| 27 #include "components/url_formatter/elide_url.h" | |
| 27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/common/context_menu_params.h" | 29 #include "content/public/common/context_menu_params.h" |
| 29 #include "content/public/renderer/render_frame.h" | 30 #include "content/public/renderer/render_frame.h" |
| 30 #include "content/public/renderer/render_thread.h" | 31 #include "content/public/renderer/render_thread.h" |
| 31 #include "gin/object_template_builder.h" | 32 #include "gin/object_template_builder.h" |
| 32 #include "third_party/WebKit/public/platform/URLConversion.h" | 33 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 33 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 34 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 34 #include "third_party/WebKit/public/platform/WebMouseEvent.h" | 35 #include "third_party/WebKit/public/platform/WebMouseEvent.h" |
| 36 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | |
| 35 #include "third_party/WebKit/public/web/WebDocument.h" | 37 #include "third_party/WebKit/public/web/WebDocument.h" |
| 36 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 38 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 37 #include "third_party/WebKit/public/web/WebScriptSource.h" | 39 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 38 #include "third_party/WebKit/public/web/WebView.h" | 40 #include "third_party/WebKit/public/web/WebView.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 41 #include "ui/base/webui/jstemplate_builder.h" | 43 #include "ui/base/webui/jstemplate_builder.h" |
| 42 #include "ui/gfx/geometry/size.h" | 44 #include "ui/gfx/geometry/size.h" |
| 43 #include "url/origin.h" | 45 #include "url/origin.h" |
| 44 #include "url/url_util.h" | 46 #include "url/url_util.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 MarkPluginEssential( | 308 MarkPluginEssential( |
| 307 content::PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK); | 309 content::PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK); |
| 308 LoadPlugin(); | 310 LoadPlugin(); |
| 309 break; | 311 break; |
| 310 } | 312 } |
| 311 case chrome::MENU_COMMAND_PLUGIN_HIDE: { | 313 case chrome::MENU_COMMAND_PLUGIN_HIDE: { |
| 312 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Hide_Menu")); | 314 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Hide_Menu")); |
| 313 HidePlugin(); | 315 HidePlugin(); |
| 314 break; | 316 break; |
| 315 } | 317 } |
| 318 case chrome::MENU_COMMAND_ENABLE_FLASH: { | |
| 319 ShowPermissionBubbleCallback(); | |
| 320 break; | |
| 321 } | |
| 316 default: | 322 default: |
| 317 NOTREACHED(); | 323 NOTREACHED(); |
| 318 } | 324 } |
| 319 } | 325 } |
| 320 | 326 |
| 321 void ChromePluginPlaceholder::OnMenuClosed(int request_id) { | 327 void ChromePluginPlaceholder::OnMenuClosed(int request_id) { |
| 322 DCHECK_EQ(context_menu_request_id_, request_id); | 328 DCHECK_EQ(context_menu_request_id_, request_id); |
| 323 context_menu_request_id_ = 0; | 329 context_menu_request_id_ = 0; |
| 324 } | 330 } |
| 325 | 331 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 338 if (!title_.empty()) { | 344 if (!title_.empty()) { |
| 339 content::MenuItem name_item; | 345 content::MenuItem name_item; |
| 340 name_item.label = title_; | 346 name_item.label = title_; |
| 341 params.custom_items.push_back(name_item); | 347 params.custom_items.push_back(name_item); |
| 342 | 348 |
| 343 content::MenuItem separator_item; | 349 content::MenuItem separator_item; |
| 344 separator_item.type = content::MenuItem::SEPARATOR; | 350 separator_item.type = content::MenuItem::SEPARATOR; |
| 345 params.custom_items.push_back(separator_item); | 351 params.custom_items.push_back(separator_item); |
| 346 } | 352 } |
| 347 | 353 |
| 348 if (!GetPluginInfo().path.value().empty()) { | 354 bool flash_hidden = |
| 355 status_ == ChromeViewHostMsg_GetPluginInfo_Status::kFlashHiddenPreferHtml; | |
| 356 if (!GetPluginInfo().path.value().empty() && !flash_hidden) { | |
| 349 content::MenuItem run_item; | 357 content::MenuItem run_item; |
| 350 run_item.action = chrome::MENU_COMMAND_PLUGIN_RUN; | 358 run_item.action = chrome::MENU_COMMAND_PLUGIN_RUN; |
| 351 // Disable this menu item if the plugin is blocked by policy. | 359 // Disable this menu item if the plugin is blocked by policy. |
| 352 run_item.enabled = LoadingAllowed(); | 360 run_item.enabled = LoadingAllowed(); |
| 353 run_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_RUN); | 361 run_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_RUN); |
| 354 params.custom_items.push_back(run_item); | 362 params.custom_items.push_back(run_item); |
| 355 } | 363 } |
| 356 | 364 |
| 365 if (flash_hidden) { | |
| 366 content::MenuItem enable_flash_item; | |
| 367 enable_flash_item.action = chrome::MENU_COMMAND_ENABLE_FLASH; | |
| 368 enable_flash_item.enabled = true; | |
| 369 base::string16 display_origin = url_formatter::FormatUrlForSecurityDisplay( | |
|
tommycli
2017/02/24 20:09:02
Same technique as https://cs.chromium.org/chromium
| |
| 370 url::Origin(GetFrame()->top()->getSecurityOrigin()).GetURL(), | |
| 371 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); | |
|
raymes
2017/02/27 03:51:45
What's the motivation for displaying the origin he
tommycli
2017/02/27 19:15:33
Hey see https://bugs.chromium.org/p/chromium/issue
raymes
2017/02/27 22:55:57
Ahh thanks for explaining.
I actually think it's
| |
| 372 enable_flash_item.label = l10n_util::GetStringFUTF16( | |
| 373 IDS_CONTENT_CONTEXT_ENABLE_FLASH, display_origin); | |
| 374 params.custom_items.push_back(enable_flash_item); | |
| 375 } | |
| 376 | |
| 357 content::MenuItem hide_item; | 377 content::MenuItem hide_item; |
| 358 hide_item.action = chrome::MENU_COMMAND_PLUGIN_HIDE; | 378 hide_item.action = chrome::MENU_COMMAND_PLUGIN_HIDE; |
| 359 bool is_main_frame_plugin_document = | 379 bool is_main_frame_plugin_document = |
| 360 GetFrame()->view()->mainFrame()->isWebLocalFrame() && | 380 GetFrame()->view()->mainFrame()->isWebLocalFrame() && |
| 361 GetFrame()->view()->mainFrame()->document().isPluginDocument(); | 381 GetFrame()->view()->mainFrame()->document().isPluginDocument(); |
| 362 hide_item.enabled = !is_main_frame_plugin_document; | 382 hide_item.enabled = !is_main_frame_plugin_document; |
| 363 hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE); | 383 hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE); |
| 364 params.custom_items.push_back(hide_item); | 384 params.custom_items.push_back(hide_item); |
| 365 | 385 |
| 366 params.x = event.windowX; | 386 params.x = event.windowX; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 | 433 |
| 414 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 434 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 415 switches::kEnablePluginPlaceholderTesting)) { | 435 switches::kEnablePluginPlaceholderTesting)) { |
| 416 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( | 436 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( |
| 417 "didFinishIconRepositionForTesting", | 437 "didFinishIconRepositionForTesting", |
| 418 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); | 438 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); |
| 419 } | 439 } |
| 420 | 440 |
| 421 return builder; | 441 return builder; |
| 422 } | 442 } |
| OLD | NEW |