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

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

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 3 months 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return -1; 366 return -1;
367 } 367 }
368 368
369 // Usually a new tab is expected where this function is used, 369 // Usually a new tab is expected where this function is used,
370 // however users should be able to open a tab in background 370 // however users should be able to open a tab in background
371 // or in a new window. 371 // or in a new window.
372 WindowOpenDisposition ForceNewTabDispositionFromEventFlags( 372 WindowOpenDisposition ForceNewTabDispositionFromEventFlags(
373 int event_flags) { 373 int event_flags) {
374 WindowOpenDisposition disposition = 374 WindowOpenDisposition disposition =
375 ui::DispositionFromEventFlags(event_flags); 375 ui::DispositionFromEventFlags(event_flags);
376 return disposition == CURRENT_TAB ? NEW_FOREGROUND_TAB : disposition; 376 return disposition == WindowOpenDisposition::CURRENT_TAB
377 ? WindowOpenDisposition::NEW_FOREGROUND_TAB
378 : disposition;
377 } 379 }
378 380
379 // Returns the preference of the profile represented by the |context|. 381 // Returns the preference of the profile represented by the |context|.
380 PrefService* GetPrefs(content::BrowserContext* context) { 382 PrefService* GetPrefs(content::BrowserContext* context) {
381 return user_prefs::UserPrefs::Get(context); 383 return user_prefs::UserPrefs::Get(context);
382 } 384 }
383 385
384 bool ExtensionPatternMatch(const extensions::URLPatternSet& patterns, 386 bool ExtensionPatternMatch(const extensions::URLPatternSet& patterns,
385 const GURL& url) { 387 const GURL& url) {
386 // No patterns means no restriction, so that implicitly matches. 388 // No patterns means no restriction, so that implicitly matches.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 } 479 }
478 480
479 void OnProfileCreated(const GURL& link_url, 481 void OnProfileCreated(const GURL& link_url,
480 const content::Referrer& referrer, 482 const content::Referrer& referrer,
481 Profile* profile, 483 Profile* profile,
482 Profile::CreateStatus status) { 484 Profile::CreateStatus status) {
483 if (status == Profile::CREATE_STATUS_INITIALIZED) { 485 if (status == Profile::CREATE_STATUS_INITIALIZED) {
484 Browser* browser = chrome::FindLastActiveWithProfile(profile); 486 Browser* browser = chrome::FindLastActiveWithProfile(profile);
485 chrome::NavigateParams nav_params(browser, link_url, 487 chrome::NavigateParams nav_params(browser, link_url,
486 ui::PAGE_TRANSITION_LINK); 488 ui::PAGE_TRANSITION_LINK);
487 nav_params.disposition = NEW_FOREGROUND_TAB; 489 nav_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
488 nav_params.referrer = referrer; 490 nav_params.referrer = referrer;
489 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; 491 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW;
490 chrome::Navigate(&nav_params); 492 chrome::Navigate(&nav_params);
491 } 493 }
492 } 494 }
493 495
494 } // namespace 496 } // namespace
495 497
496 // static 498 // static
497 gfx::Vector2d RenderViewContextMenu::GetOffset( 499 gfx::Vector2d RenderViewContextMenu::GetOffset(
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 ExecOpenLinkInProfile(id - IDC_OPEN_LINK_IN_PROFILE_FIRST); 1669 ExecOpenLinkInProfile(id - IDC_OPEN_LINK_IN_PROFILE_FIRST);
1668 return; 1670 return;
1669 } 1671 }
1670 1672
1671 switch (id) { 1673 switch (id) {
1672 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: 1674 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB:
1673 ExecOpenLinkNewTab(); 1675 ExecOpenLinkNewTab();
1674 break; 1676 break;
1675 1677
1676 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: 1678 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW:
1677 OpenURL(params_.link_url, GetDocumentURL(params_), NEW_WINDOW, 1679 OpenURL(params_.link_url, GetDocumentURL(params_),
1680 WindowOpenDisposition::NEW_WINDOW, ui::PAGE_TRANSITION_LINK);
1681 break;
1682
1683 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD:
1684 OpenURL(params_.link_url, GURL(), WindowOpenDisposition::OFF_THE_RECORD,
1678 ui::PAGE_TRANSITION_LINK); 1685 ui::PAGE_TRANSITION_LINK);
1679 break; 1686 break;
1680 1687
1681 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD:
1682 OpenURL(params_.link_url, GURL(), OFF_THE_RECORD,
1683 ui::PAGE_TRANSITION_LINK);
1684 break;
1685
1686 case IDC_CONTENT_CONTEXT_SAVELINKAS: 1688 case IDC_CONTENT_CONTEXT_SAVELINKAS:
1687 ExecSaveLinkAs(); 1689 ExecSaveLinkAs();
1688 break; 1690 break;
1689 1691
1690 case IDC_CONTENT_CONTEXT_SAVEAVAS: 1692 case IDC_CONTENT_CONTEXT_SAVEAVAS:
1691 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: 1693 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS:
1692 ExecSaveAs(); 1694 ExecSaveAs();
1693 break; 1695 break;
1694 1696
1695 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1697 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
(...skipping 12 matching lines...) Expand all
1708 case IDC_CONTENT_CONTEXT_COPYIMAGE: 1710 case IDC_CONTENT_CONTEXT_COPYIMAGE:
1709 ExecCopyImageAt(); 1711 ExecCopyImageAt();
1710 break; 1712 break;
1711 1713
1712 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: 1714 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE:
1713 ExecSearchWebForImage(); 1715 ExecSearchWebForImage();
1714 break; 1716 break;
1715 1717
1716 case IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB: 1718 case IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB:
1717 OpenURLWithExtraHeaders( 1719 OpenURLWithExtraHeaders(
1718 params_.src_url, GetDocumentURL(params_), NEW_BACKGROUND_TAB, 1720 params_.src_url, GetDocumentURL(params_),
1719 ui::PAGE_TRANSITION_LINK, 1721 WindowOpenDisposition::NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_LINK,
1720 data_reduction_proxy::kDataReductionPassThroughHeader); 1722 data_reduction_proxy::kDataReductionPassThroughHeader);
1721 break; 1723 break;
1722 1724
1723 case IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE: 1725 case IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE:
1724 ExecLoadOriginalImage(); 1726 ExecLoadOriginalImage();
1725 break; 1727 break;
1726 1728
1727 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: 1729 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB:
1728 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: 1730 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB:
1729 OpenURL(params_.src_url, 1731 OpenURL(params_.src_url, GetDocumentURL(params_),
1730 GetDocumentURL(params_), 1732 WindowOpenDisposition::NEW_BACKGROUND_TAB,
1731 NEW_BACKGROUND_TAB,
1732 ui::PAGE_TRANSITION_LINK); 1733 ui::PAGE_TRANSITION_LINK);
1733 break; 1734 break;
1734 1735
1735 case IDC_CONTENT_CONTEXT_PLAYPAUSE: 1736 case IDC_CONTENT_CONTEXT_PLAYPAUSE:
1736 ExecPlayPause(); 1737 ExecPlayPause();
1737 break; 1738 break;
1738 1739
1739 case IDC_CONTENT_CONTEXT_MUTE: 1740 case IDC_CONTENT_CONTEXT_MUTE:
1740 ExecMute(); 1741 ExecMute();
1741 break; 1742 break;
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 if (!web_contents) 2113 if (!web_contents)
2113 return false; 2114 return false;
2114 2115
2115 const web_modal::WebContentsModalDialogManager* manager = 2116 const web_modal::WebContentsModalDialogManager* manager =
2116 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); 2117 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
2117 return !manager || !manager->IsDialogActive(); 2118 return !manager || !manager->IsDialogActive();
2118 } 2119 }
2119 2120
2120 void RenderViewContextMenu::ExecOpenLinkNewTab() { 2121 void RenderViewContextMenu::ExecOpenLinkNewTab() {
2121 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_); 2122 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_);
2122 OpenURL(params_.link_url, 2123 OpenURL(params_.link_url, GetDocumentURL(params_),
2123 GetDocumentURL(params_), 2124 (!browser || browser->is_app())
2124 (!browser || browser->is_app()) ? NEW_FOREGROUND_TAB 2125 ? WindowOpenDisposition::NEW_FOREGROUND_TAB
2125 : NEW_BACKGROUND_TAB, 2126 : WindowOpenDisposition::NEW_BACKGROUND_TAB,
2126 ui::PAGE_TRANSITION_LINK); 2127 ui::PAGE_TRANSITION_LINK);
2127 } 2128 }
2128 2129
2129 void RenderViewContextMenu::ExecProtocolHandler(int event_flags, 2130 void RenderViewContextMenu::ExecProtocolHandler(int event_flags,
2130 int handler_index) { 2131 int handler_index) {
2131 ProtocolHandlerRegistry::ProtocolHandlerList handlers = 2132 ProtocolHandlerRegistry::ProtocolHandlerList handlers =
2132 GetHandlersForLinkUrl(); 2133 GetHandlersForLinkUrl();
2133 if (handlers.empty()) 2134 if (handlers.empty())
2134 return; 2135 return;
2135 2136
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 void RenderViewContextMenu::PluginActionAt( 2451 void RenderViewContextMenu::PluginActionAt(
2451 const gfx::Point& location, 2452 const gfx::Point& location,
2452 const WebPluginAction& action) { 2453 const WebPluginAction& action) {
2453 source_web_contents_->GetRenderViewHost()-> 2454 source_web_contents_->GetRenderViewHost()->
2454 ExecutePluginActionAtLocation(location, action); 2455 ExecutePluginActionAtLocation(location, action);
2455 } 2456 }
2456 2457
2457 Browser* RenderViewContextMenu::GetBrowser() const { 2458 Browser* RenderViewContextMenu::GetBrowser() const {
2458 return chrome::FindBrowserWithWebContents(embedder_web_contents_); 2459 return chrome::FindBrowserWithWebContents(embedder_web_contents_);
2459 } 2460 }
OLDNEW
« no previous file with comments | « chrome/browser/referrer_policy_browsertest.cc ('k') | chrome/browser/renderer_context_menu/spelling_bubble_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698