| 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 "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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 context_menu_request_id_ = 0; | 324 context_menu_request_id_ = 0; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void ChromePluginPlaceholder::ShowContextMenu(const WebMouseEvent& event) { | 327 void ChromePluginPlaceholder::ShowContextMenu(const WebMouseEvent& event) { |
| 328 #if !defined(OS_ANDROID) // The context menu is not applicable on Android. | 328 #if !defined(OS_ANDROID) // The context menu is not applicable on Android. |
| 329 if (context_menu_request_id_) | 329 if (context_menu_request_id_) |
| 330 return; // Don't allow nested context menu requests. | 330 return; // Don't allow nested context menu requests. |
| 331 | 331 |
| 332 content::ContextMenuParams params; | 332 content::ContextMenuParams params; |
| 333 | 333 |
| 334 content::MenuItem name_item; | 334 if (!title_.empty()) { |
| 335 name_item.label = title_; | 335 content::MenuItem name_item; |
| 336 params.custom_items.push_back(name_item); | 336 name_item.label = title_; |
| 337 params.custom_items.push_back(name_item); |
| 337 | 338 |
| 338 content::MenuItem separator_item; | 339 content::MenuItem separator_item; |
| 339 separator_item.type = content::MenuItem::SEPARATOR; | 340 separator_item.type = content::MenuItem::SEPARATOR; |
| 340 params.custom_items.push_back(separator_item); | 341 params.custom_items.push_back(separator_item); |
| 342 } |
| 341 | 343 |
| 342 if (!GetPluginInfo().path.value().empty()) { | 344 if (!GetPluginInfo().path.value().empty()) { |
| 343 content::MenuItem run_item; | 345 content::MenuItem run_item; |
| 344 run_item.action = chrome::MENU_COMMAND_PLUGIN_RUN; | 346 run_item.action = chrome::MENU_COMMAND_PLUGIN_RUN; |
| 345 // Disable this menu item if the plugin is blocked by policy. | 347 // Disable this menu item if the plugin is blocked by policy. |
| 346 run_item.enabled = LoadingAllowed(); | 348 run_item.enabled = LoadingAllowed(); |
| 347 run_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_RUN); | 349 run_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_RUN); |
| 348 params.custom_items.push_back(run_item); | 350 params.custom_items.push_back(run_item); |
| 349 } | 351 } |
| 350 | 352 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 372 v8::Handle<v8::Object> global = context->Global(); | 374 v8::Handle<v8::Object> global = context->Global(); |
| 373 global->Set(gin::StringToV8(isolate, "plugin"), | 375 global->Set(gin::StringToV8(isolate, "plugin"), |
| 374 gin::CreateHandle(isolate, this).ToV8()); | 376 gin::CreateHandle(isolate, this).ToV8()); |
| 375 } | 377 } |
| 376 | 378 |
| 377 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( | 379 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( |
| 378 v8::Isolate* isolate) { | 380 v8::Isolate* isolate) { |
| 379 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( | 381 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( |
| 380 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); | 382 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); |
| 381 } | 383 } |
| OLD | NEW |