| OLD | NEW | 
|     1 // Copyright 2014 The Chromium Authors. All rights reserved. |     1 // Copyright 2014 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/browser/renderer_context_menu/render_view_context_menu.h" |     5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 
|     6  |     6  | 
|     7 #include <algorithm> |     7 #include <algorithm> | 
|     8 #include <set> |     8 #include <set> | 
|     9 #include <utility> |     9 #include <utility> | 
|    10  |    10  | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    96 #include "third_party/WebKit/public/web/WebContextMenuData.h" |    96 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 
|    97 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |    97 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" | 
|    98 #include "third_party/WebKit/public/web/WebPluginAction.h" |    98 #include "third_party/WebKit/public/web/WebPluginAction.h" | 
|    99 #include "ui/base/clipboard/clipboard.h" |    99 #include "ui/base/clipboard/clipboard.h" | 
|   100 #include "ui/base/l10n/l10n_util.h" |   100 #include "ui/base/l10n/l10n_util.h" | 
|   101 #include "ui/gfx/favicon_size.h" |   101 #include "ui/gfx/favicon_size.h" | 
|   102 #include "ui/gfx/geometry/point.h" |   102 #include "ui/gfx/geometry/point.h" | 
|   103 #include "ui/gfx/geometry/size.h" |   103 #include "ui/gfx/geometry/size.h" | 
|   104 #include "ui/gfx/text_elider.h" |   104 #include "ui/gfx/text_elider.h" | 
|   105  |   105  | 
 |   106 #if defined(ENABLE_EXTENSIONS) | 
 |   107 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
      t.h" | 
 |   108 #endif | 
 |   109  | 
|   106 #if defined(ENABLE_PRINTING) |   110 #if defined(ENABLE_PRINTING) | 
|   107 #include "chrome/browser/printing/print_view_manager_common.h" |   111 #include "chrome/browser/printing/print_view_manager_common.h" | 
|   108 #include "components/printing/common/print_messages.h" |   112 #include "components/printing/common/print_messages.h" | 
|   109  |   113  | 
|   110 #if defined(ENABLE_PRINT_PREVIEW) |   114 #if defined(ENABLE_PRINT_PREVIEW) | 
|   111 #include "chrome/browser/printing/print_preview_context_menu_observer.h" |   115 #include "chrome/browser/printing/print_preview_context_menu_observer.h" | 
|   112 #include "chrome/browser/printing/print_preview_dialog_controller.h" |   116 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 
|   113 #endif  // defined(ENABLE_PRINT_PREVIEW) |   117 #endif  // defined(ENABLE_PRINT_PREVIEW) | 
|   114 #endif  // defined(ENABLE_PRINTING) |   118 #endif  // defined(ENABLE_PRINTING) | 
|   115  |   119  | 
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   296  |   300  | 
|   297 content::Referrer CreateSaveAsReferrer( |   301 content::Referrer CreateSaveAsReferrer( | 
|   298     const GURL& url, |   302     const GURL& url, | 
|   299     const content::ContextMenuParams& params) { |   303     const content::ContextMenuParams& params) { | 
|   300   const GURL& referring_url = GetDocumentURL(params); |   304   const GURL& referring_url = GetDocumentURL(params); | 
|   301   return content::Referrer::SanitizeForRequest( |   305   return content::Referrer::SanitizeForRequest( | 
|   302       url, |   306       url, | 
|   303       content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy)); |   307       content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy)); | 
|   304 } |   308 } | 
|   305  |   309  | 
 |   310 content::WebContents* GetWebContentsToUse(content::WebContents* web_contents) { | 
 |   311 #if defined(ENABLE_EXTENSIONS) | 
 |   312   // If we're viewing in a MimeHandlerViewGuest, use its embedder WebContents. | 
 |   313   if (extensions::MimeHandlerViewGuest::FromWebContents(web_contents)) { | 
 |   314     WebContents* top_level_web_contents = | 
 |   315         guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); | 
 |   316     if (top_level_web_contents) | 
 |   317       return top_level_web_contents; | 
 |   318   } | 
 |   319 #endif | 
 |   320   return web_contents; | 
 |   321 } | 
 |   322  | 
|   306 bool g_custom_id_ranges_initialized = false; |   323 bool g_custom_id_ranges_initialized = false; | 
|   307  |   324  | 
|   308 const int kSpellcheckRadioGroup = 1; |   325 const int kSpellcheckRadioGroup = 1; | 
|   309  |   326  | 
|   310 }  // namespace |   327 }  // namespace | 
|   311  |   328  | 
|   312 // static |   329 // static | 
|   313 gfx::Vector2d RenderViewContextMenu::GetOffset( |   330 gfx::Vector2d RenderViewContextMenu::GetOffset( | 
|   314     RenderFrameHost* render_frame_host) { |   331     RenderFrameHost* render_frame_host) { | 
|   315   gfx::Vector2d offset; |   332   gfx::Vector2d offset; | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|   343 RenderViewContextMenu::RenderViewContextMenu( |   360 RenderViewContextMenu::RenderViewContextMenu( | 
|   344     content::RenderFrameHost* render_frame_host, |   361     content::RenderFrameHost* render_frame_host, | 
|   345     const content::ContextMenuParams& params) |   362     const content::ContextMenuParams& params) | 
|   346     : RenderViewContextMenuBase(render_frame_host, params), |   363     : RenderViewContextMenuBase(render_frame_host, params), | 
|   347       extension_items_(browser_context_, |   364       extension_items_(browser_context_, | 
|   348                        this, |   365                        this, | 
|   349                        &menu_model_, |   366                        &menu_model_, | 
|   350                        base::Bind(MenuItemMatchesParams, params_)), |   367                        base::Bind(MenuItemMatchesParams, params_)), | 
|   351       protocol_handler_submenu_model_(this), |   368       protocol_handler_submenu_model_(this), | 
|   352       protocol_handler_registry_( |   369       protocol_handler_registry_( | 
|   353           ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())) { |   370           ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())), | 
 |   371       embedder_web_contents_(GetWebContentsToUse(source_web_contents_)) { | 
|   354   if (!g_custom_id_ranges_initialized) { |   372   if (!g_custom_id_ranges_initialized) { | 
|   355     g_custom_id_ranges_initialized = true; |   373     g_custom_id_ranges_initialized = true; | 
|   356     SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, |   374     SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, | 
|   357                                    IDC_CONTENT_CONTEXT_CUSTOM_LAST); |   375                                    IDC_CONTENT_CONTEXT_CUSTOM_LAST); | 
|   358   } |   376   } | 
|   359   set_content_type(ContextMenuContentTypeFactory::Create( |   377   set_content_type(ContextMenuContentTypeFactory::Create( | 
|   360       source_web_contents_, params)); |   378       source_web_contents_, params)); | 
|   361 } |   379 } | 
|   362  |   380  | 
|   363 RenderViewContextMenu::~RenderViewContextMenu() { |   381 RenderViewContextMenu::~RenderViewContextMenu() { | 
| (...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1837   source_web_contents_->GetRenderViewHost()-> |  1855   source_web_contents_->GetRenderViewHost()-> | 
|  1838       ExecuteMediaPlayerActionAtLocation(location, action); |  1856       ExecuteMediaPlayerActionAtLocation(location, action); | 
|  1839 } |  1857 } | 
|  1840  |  1858  | 
|  1841 void RenderViewContextMenu::PluginActionAt( |  1859 void RenderViewContextMenu::PluginActionAt( | 
|  1842     const gfx::Point& location, |  1860     const gfx::Point& location, | 
|  1843     const WebPluginAction& action) { |  1861     const WebPluginAction& action) { | 
|  1844   source_web_contents_->GetRenderViewHost()-> |  1862   source_web_contents_->GetRenderViewHost()-> | 
|  1845       ExecutePluginActionAtLocation(location, action); |  1863       ExecutePluginActionAtLocation(location, action); | 
|  1846 } |  1864 } | 
| OLD | NEW |