Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 #include "content/public/browser/render_frame_host.h" 97 #include "content/public/browser/render_frame_host.h"
98 #include "content/public/browser/render_process_host.h" 98 #include "content/public/browser/render_process_host.h"
99 #include "content/public/browser/render_view_host.h" 99 #include "content/public/browser/render_view_host.h"
100 #include "content/public/browser/render_widget_host_view.h" 100 #include "content/public/browser/render_widget_host_view.h"
101 #include "content/public/browser/ssl_status.h" 101 #include "content/public/browser/ssl_status.h"
102 #include "content/public/browser/storage_partition.h" 102 #include "content/public/browser/storage_partition.h"
103 #include "content/public/browser/user_metrics.h" 103 #include "content/public/browser/user_metrics.h"
104 #include "content/public/browser/web_contents.h" 104 #include "content/public/browser/web_contents.h"
105 #include "content/public/common/menu_item.h" 105 #include "content/public/common/menu_item.h"
106 #include "content/public/common/url_utils.h" 106 #include "content/public/common/url_utils.h"
107 #include "extensions/features/features.h"
107 #include "net/base/escape.h" 108 #include "net/base/escape.h"
108 #include "printing/features/features.h" 109 #include "printing/features/features.h"
109 #include "third_party/WebKit/public/public_features.h" 110 #include "third_party/WebKit/public/public_features.h"
110 #include "third_party/WebKit/public/web/WebContextMenuData.h" 111 #include "third_party/WebKit/public/web/WebContextMenuData.h"
111 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" 112 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h"
112 #include "third_party/WebKit/public/web/WebPluginAction.h" 113 #include "third_party/WebKit/public/web/WebPluginAction.h"
113 #include "ui/base/clipboard/clipboard.h" 114 #include "ui/base/clipboard/clipboard.h"
114 #include "ui/base/clipboard/scoped_clipboard_writer.h" 115 #include "ui/base/clipboard/scoped_clipboard_writer.h"
115 #include "ui/base/l10n/l10n_util.h" 116 #include "ui/base/l10n/l10n_util.h"
116 #include "ui/gfx/canvas.h" 117 #include "ui/gfx/canvas.h"
117 #include "ui/gfx/favicon_size.h" 118 #include "ui/gfx/favicon_size.h"
118 #include "ui/gfx/geometry/point.h" 119 #include "ui/gfx/geometry/point.h"
119 #include "ui/gfx/geometry/size.h" 120 #include "ui/gfx/geometry/size.h"
120 #include "ui/gfx/path.h" 121 #include "ui/gfx/path.h"
121 #include "ui/gfx/text_elider.h" 122 #include "ui/gfx/text_elider.h"
122 123
123 #if !defined(USE_BROWSER_SPELLCHECKER) 124 #if !defined(USE_BROWSER_SPELLCHECKER)
124 #include "chrome/browser/renderer_context_menu/spelling_options_submenu_observer .h" 125 #include "chrome/browser/renderer_context_menu/spelling_options_submenu_observer .h"
125 #endif 126 #endif
126 127
127 #if defined(ENABLE_EXTENSIONS) 128 #if BUILDFLAG(ENABLE_EXTENSIONS)
128 #include "chrome/browser/extensions/devtools_util.h" 129 #include "chrome/browser/extensions/devtools_util.h"
129 #include "chrome/browser/extensions/extension_service.h" 130 #include "chrome/browser/extensions/extension_service.h"
130 #include "extensions/browser/extension_host.h" 131 #include "extensions/browser/extension_host.h"
131 #include "extensions/browser/extension_system.h" 132 #include "extensions/browser/extension_system.h"
132 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" 133 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h"
133 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 134 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
134 #include "extensions/browser/view_type_utils.h" 135 #include "extensions/browser/view_type_utils.h"
135 #include "extensions/common/extension.h" 136 #include "extensions/common/extension.h"
136 #endif 137 #endif
137 138
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 401
401 content::Referrer CreateReferrer(const GURL& url, 402 content::Referrer CreateReferrer(const GURL& url,
402 const content::ContextMenuParams& params) { 403 const content::ContextMenuParams& params) {
403 const GURL& referring_url = GetDocumentURL(params); 404 const GURL& referring_url = GetDocumentURL(params);
404 return content::Referrer::SanitizeForRequest( 405 return content::Referrer::SanitizeForRequest(
405 url, 406 url,
406 content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy)); 407 content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy));
407 } 408 }
408 409
409 content::WebContents* GetWebContentsToUse(content::WebContents* web_contents) { 410 content::WebContents* GetWebContentsToUse(content::WebContents* web_contents) {
410 #if defined(ENABLE_EXTENSIONS) 411 #if BUILDFLAG(ENABLE_EXTENSIONS)
411 // If we're viewing in a MimeHandlerViewGuest, use its embedder WebContents. 412 // If we're viewing in a MimeHandlerViewGuest, use its embedder WebContents.
412 if (extensions::MimeHandlerViewGuest::FromWebContents(web_contents)) { 413 if (extensions::MimeHandlerViewGuest::FromWebContents(web_contents)) {
413 WebContents* top_level_web_contents = 414 WebContents* top_level_web_contents =
414 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); 415 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents);
415 if (top_level_web_contents) 416 if (top_level_web_contents)
416 return top_level_web_contents; 417 return top_level_web_contents;
417 } 418 }
418 #endif 419 #endif
419 return web_contents; 420 return web_contents;
420 } 421 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 chrome::Navigate(&nav_params); 496 chrome::Navigate(&nav_params);
496 } 497 }
497 } 498 }
498 499
499 } // namespace 500 } // namespace
500 501
501 // static 502 // static
502 gfx::Vector2d RenderViewContextMenu::GetOffset( 503 gfx::Vector2d RenderViewContextMenu::GetOffset(
503 RenderFrameHost* render_frame_host) { 504 RenderFrameHost* render_frame_host) {
504 gfx::Vector2d offset; 505 gfx::Vector2d offset;
505 #if defined(ENABLE_EXTENSIONS) 506 #if BUILDFLAG(ENABLE_EXTENSIONS)
506 // When --use-cross-process-frames-for-guests is enabled, the position is 507 // When --use-cross-process-frames-for-guests is enabled, the position is
507 // transformed in the browser process hittesting code. 508 // transformed in the browser process hittesting code.
508 WebContents* web_contents = 509 WebContents* web_contents =
509 WebContents::FromRenderFrameHost(render_frame_host); 510 WebContents::FromRenderFrameHost(render_frame_host);
510 // TODO(ekaramad): For now, MimeHandlerView is based on BrowserPlugin even 511 // TODO(ekaramad): For now, MimeHandlerView is based on BrowserPlugin even
511 // when guests use OOPIF. Remove the check below when MimeHandlerView is also 512 // when guests use OOPIF. Remove the check below when MimeHandlerView is also
512 // based on OOPIF (https://crbug.com/642826). 513 // based on OOPIF (https://crbug.com/642826).
513 if (!content::GuestMode::IsCrossProcessFrameGuest(web_contents)) { 514 if (!content::GuestMode::IsCrossProcessFrameGuest(web_contents)) {
514 WebContents* top_level_web_contents = 515 WebContents* top_level_web_contents =
515 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); 516 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents);
516 if (web_contents && top_level_web_contents && 517 if (web_contents && top_level_web_contents &&
517 web_contents != top_level_web_contents) { 518 web_contents != top_level_web_contents) {
518 gfx::Rect bounds = web_contents->GetContainerBounds(); 519 gfx::Rect bounds = web_contents->GetContainerBounds();
519 gfx::Rect top_level_bounds = top_level_web_contents->GetContainerBounds(); 520 gfx::Rect top_level_bounds = top_level_web_contents->GetContainerBounds();
520 offset = bounds.origin() - top_level_bounds.origin(); 521 offset = bounds.origin() - top_level_bounds.origin();
521 } 522 }
522 } 523 }
523 #endif // defined(ENABLE_EXTENSIONS) 524 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
524 return offset; 525 return offset;
525 } 526 }
526 527
527 // static 528 // static
528 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { 529 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) {
529 return url.SchemeIs(content::kChromeDevToolsScheme); 530 return url.SchemeIs(content::kChromeDevToolsScheme);
530 } 531 }
531 532
532 // static 533 // static
533 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) { 534 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 base::FieldTrialList::FindFullName("SaveAsMenuText") == "download") { 584 base::FieldTrialList::FindFullName("SaveAsMenuText") == "download") {
584 save_as_text_experiement_enabled_ = true; 585 save_as_text_experiement_enabled_ = true;
585 } 586 }
586 } 587 }
587 588
588 RenderViewContextMenu::~RenderViewContextMenu() { 589 RenderViewContextMenu::~RenderViewContextMenu() {
589 } 590 }
590 591
591 // Menu construction functions ------------------------------------------------- 592 // Menu construction functions -------------------------------------------------
592 593
593 #if defined(ENABLE_EXTENSIONS) 594 #if BUILDFLAG(ENABLE_EXTENSIONS)
594 // static 595 // static
595 bool RenderViewContextMenu::ExtensionContextAndPatternMatch( 596 bool RenderViewContextMenu::ExtensionContextAndPatternMatch(
596 const content::ContextMenuParams& params, 597 const content::ContextMenuParams& params,
597 const MenuItem::ContextList& contexts, 598 const MenuItem::ContextList& contexts,
598 const extensions::URLPatternSet& target_url_patterns) { 599 const extensions::URLPatternSet& target_url_patterns) {
599 const bool has_link = !params.link_url.is_empty(); 600 const bool has_link = !params.link_url.is_empty();
600 const bool has_selection = !params.selection_text.empty(); 601 const bool has_selection = !params.selection_text.empty();
601 const bool in_frame = !params.frame_url.is_empty(); 602 const bool in_frame = !params.frame_url.is_empty();
602 603
603 if (contexts.Contains(MenuItem::ALL) || 604 if (contexts.Contains(MenuItem::ALL) ||
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 web_view_guest->view_instance_id()); 732 web_view_guest->view_instance_id());
732 } else { 733 } else {
733 key = MenuItem::ExtensionKey(extension->id()); 734 key = MenuItem::ExtensionKey(extension->id());
734 } 735 }
735 736
736 // Only add extension items from this extension. 737 // Only add extension items from this extension.
737 int index = 0; 738 int index = 0;
738 extension_items_.AppendExtensionItems(key, PrintableSelectionText(), &index, 739 extension_items_.AppendExtensionItems(key, PrintableSelectionText(), &index,
739 false /* is_action_menu */); 740 false /* is_action_menu */);
740 } 741 }
741 #endif // defined(ENABLE_EXTENSIONS) 742 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
742 743
743 void RenderViewContextMenu::InitMenu() { 744 void RenderViewContextMenu::InitMenu() {
744 RenderViewContextMenuBase::InitMenu(); 745 RenderViewContextMenuBase::InitMenu();
745 746
746 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) 747 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE))
747 AppendPageItems(); 748 AppendPageItems();
748 749
749 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) { 750 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) {
750 AppendLinkItems(); 751 AppendLinkItems();
751 if (params_.media_type != WebContextMenuData::MediaTypeNone) 752 if (params_.media_type != WebContextMenuData::MediaTypeNone)
(...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 void RenderViewContextMenu::PluginActionAt( 2500 void RenderViewContextMenu::PluginActionAt(
2500 const gfx::Point& location, 2501 const gfx::Point& location,
2501 const WebPluginAction& action) { 2502 const WebPluginAction& action) {
2502 source_web_contents_->GetRenderViewHost()-> 2503 source_web_contents_->GetRenderViewHost()->
2503 ExecutePluginActionAtLocation(location, action); 2504 ExecutePluginActionAtLocation(location, action);
2504 } 2505 }
2505 2506
2506 Browser* RenderViewContextMenu::GetBrowser() const { 2507 Browser* RenderViewContextMenu::GetBrowser() const {
2507 return chrome::FindBrowserWithWebContents(embedder_web_contents_); 2508 return chrome::FindBrowserWithWebContents(embedder_web_contents_);
2508 } 2509 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698