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_PRINTING) | 106 #if defined(ENABLE_PRINTING) |
lazyboy
2015/04/30 16:33:31
Move the added include before this one (sorted).
Deepak
2015/05/02 06:25:20
Done.
| |
107 #include "chrome/browser/printing/print_view_manager_common.h" | 107 #include "chrome/browser/printing/print_view_manager_common.h" |
108 #include "components/printing/common/print_messages.h" | 108 #include "components/printing/common/print_messages.h" |
109 | 109 |
110 #if defined(ENABLE_PRINT_PREVIEW) | 110 #if defined(ENABLE_PRINT_PREVIEW) |
111 #include "chrome/browser/printing/print_preview_context_menu_observer.h" | 111 #include "chrome/browser/printing/print_preview_context_menu_observer.h" |
112 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 112 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
113 #endif // defined(ENABLE_PRINT_PREVIEW) | 113 #endif // defined(ENABLE_PRINT_PREVIEW) |
114 #endif // defined(ENABLE_PRINTING) | 114 #endif // defined(ENABLE_PRINTING) |
115 | 115 |
116 #if defined(ENABLE_EXTENSIONS) | |
117 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" | |
118 #endif | |
119 | |
116 using base::UserMetricsAction; | 120 using base::UserMetricsAction; |
117 using blink::WebContextMenuData; | 121 using blink::WebContextMenuData; |
118 using blink::WebMediaPlayerAction; | 122 using blink::WebMediaPlayerAction; |
119 using blink::WebPluginAction; | 123 using blink::WebPluginAction; |
120 using blink::WebString; | 124 using blink::WebString; |
121 using blink::WebURL; | 125 using blink::WebURL; |
122 using content::BrowserContext; | 126 using content::BrowserContext; |
123 using content::ChildProcessSecurityPolicy; | 127 using content::ChildProcessSecurityPolicy; |
124 using content::DownloadManager; | 128 using content::DownloadManager; |
125 using content::DownloadUrlParameters; | 129 using content::DownloadUrlParameters; |
(...skipping 170 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 we're viewing in a MimeHandlerViewGuest, use its embedder WebContents. | |
312 #if defined(ENABLE_EXTENSIONS) | |
313 auto guest_view = | |
314 extensions::MimeHandlerViewGuest::FromWebContents(web_contents); | |
315 if (guest_view) | |
316 return guest_view->embedder_web_contents(); | |
317 #endif | |
318 return web_contents; | |
319 } | |
320 | |
306 bool g_custom_id_ranges_initialized = false; | 321 bool g_custom_id_ranges_initialized = false; |
307 | 322 |
308 const int kSpellcheckRadioGroup = 1; | 323 const int kSpellcheckRadioGroup = 1; |
309 | 324 |
310 } // namespace | 325 } // namespace |
311 | 326 |
312 // static | 327 // static |
313 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { | 328 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { |
314 return url.SchemeIs(content::kChromeDevToolsScheme); | 329 return url.SchemeIs(content::kChromeDevToolsScheme); |
315 } | 330 } |
(...skipping 16 matching lines...) Expand all Loading... | |
332 protocol_handler_submenu_model_(this), | 347 protocol_handler_submenu_model_(this), |
333 protocol_handler_registry_( | 348 protocol_handler_registry_( |
334 ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())) { | 349 ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())) { |
335 if (!g_custom_id_ranges_initialized) { | 350 if (!g_custom_id_ranges_initialized) { |
336 g_custom_id_ranges_initialized = true; | 351 g_custom_id_ranges_initialized = true; |
337 SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, | 352 SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, |
338 IDC_CONTENT_CONTEXT_CUSTOM_LAST); | 353 IDC_CONTENT_CONTEXT_CUSTOM_LAST); |
339 } | 354 } |
340 set_content_type(ContextMenuContentTypeFactory::Create( | 355 set_content_type(ContextMenuContentTypeFactory::Create( |
341 source_web_contents_, params)); | 356 source_web_contents_, params)); |
357 embedder_web_contents_ = GetWebContentsToUse(source_web_contents_); | |
lazyboy
2015/04/30 16:33:31
Can we move this to member initializer list above?
Deepak
2015/05/02 06:25:20
Done.
| |
342 } | 358 } |
343 | 359 |
344 RenderViewContextMenu::~RenderViewContextMenu() { | 360 RenderViewContextMenu::~RenderViewContextMenu() { |
345 } | 361 } |
346 | 362 |
347 // Menu construction functions ------------------------------------------------- | 363 // Menu construction functions ------------------------------------------------- |
348 | 364 |
349 #if defined(ENABLE_EXTENSIONS) | 365 #if defined(ENABLE_EXTENSIONS) |
350 // static | 366 // static |
351 bool RenderViewContextMenu::ExtensionContextAndPatternMatch( | 367 bool RenderViewContextMenu::ExtensionContextAndPatternMatch( |
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1818 source_web_contents_->GetRenderViewHost()-> | 1834 source_web_contents_->GetRenderViewHost()-> |
1819 ExecuteMediaPlayerActionAtLocation(location, action); | 1835 ExecuteMediaPlayerActionAtLocation(location, action); |
1820 } | 1836 } |
1821 | 1837 |
1822 void RenderViewContextMenu::PluginActionAt( | 1838 void RenderViewContextMenu::PluginActionAt( |
1823 const gfx::Point& location, | 1839 const gfx::Point& location, |
1824 const WebPluginAction& action) { | 1840 const WebPluginAction& action) { |
1825 source_web_contents_->GetRenderViewHost()-> | 1841 source_web_contents_->GetRenderViewHost()-> |
1826 ExecutePluginActionAtLocation(location, action); | 1842 ExecutePluginActionAtLocation(location, action); |
1827 } | 1843 } |
OLD | NEW |