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

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

Issue 2219173002: Re-land "Disable Print in the context menu when a modal dialog is shown" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create the GetBrowser() helper method Created 4 years, 4 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
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory .h" 49 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory .h"
50 #include "chrome/browser/renderer_context_menu/open_with_menu_factory.h" 50 #include "chrome/browser/renderer_context_menu/open_with_menu_factory.h"
51 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" 51 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h"
52 #include "chrome/browser/search/search.h" 52 #include "chrome/browser/search/search.h"
53 #include "chrome/browser/search_engines/template_url_service_factory.h" 53 #include "chrome/browser/search_engines/template_url_service_factory.h"
54 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" 54 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
55 #include "chrome/browser/spellchecker/spellcheck_service.h" 55 #include "chrome/browser/spellchecker/spellcheck_service.h"
56 #include "chrome/browser/tab_contents/retargeting_details.h" 56 #include "chrome/browser/tab_contents/retargeting_details.h"
57 #include "chrome/browser/translate/chrome_translate_client.h" 57 #include "chrome/browser/translate/chrome_translate_client.h"
58 #include "chrome/browser/translate/translate_service.h" 58 #include "chrome/browser/translate/translate_service.h"
59 #include "chrome/browser/ui/browser.h"
60 #include "chrome/browser/ui/browser_commands.h" 59 #include "chrome/browser/ui/browser_commands.h"
61 #include "chrome/browser/ui/browser_finder.h" 60 #include "chrome/browser/ui/browser_finder.h"
62 #include "chrome/browser/ui/browser_navigator_params.h" 61 #include "chrome/browser/ui/browser_navigator_params.h"
63 #include "chrome/browser/ui/chrome_pages.h" 62 #include "chrome/browser/ui/chrome_pages.h"
64 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 63 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
65 #include "chrome/browser/ui/tabs/tab_strip_model.h" 64 #include "chrome/browser/ui/tabs/tab_strip_model.h"
66 #include "chrome/common/chrome_constants.h" 65 #include "chrome/common/chrome_constants.h"
67 #include "chrome/common/chrome_switches.h" 66 #include "chrome/common/chrome_switches.h"
68 #include "chrome/common/content_restriction.h" 67 #include "chrome/common/content_restriction.h"
69 #include "chrome/common/pref_names.h" 68 #include "chrome/common/pref_names.h"
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 1578
1580 case IDC_CONTENT_CONTEXT_SELECTALL: 1579 case IDC_CONTENT_CONTEXT_SELECTALL:
1581 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); 1580 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll);
1582 1581
1583 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: 1582 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD:
1584 return !browser_context_->IsOffTheRecord() && 1583 return !browser_context_->IsOffTheRecord() &&
1585 params_.link_url.is_valid() && 1584 params_.link_url.is_valid() &&
1586 incognito_avail != IncognitoModePrefs::DISABLED; 1585 incognito_avail != IncognitoModePrefs::DISABLED;
1587 1586
1588 case IDC_PRINT: 1587 case IDC_PRINT:
1589 return prefs->GetBoolean(prefs::kPrintingEnabled) && 1588 return IsPrintPreviewEnabled();
1590 (params_.media_type == WebContextMenuData::MediaTypeNone ||
1591 params_.media_flags & WebContextMenuData::MediaCanPrint);
1592 1589
1593 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR: 1590 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR:
1594 case IDC_CONTENT_CONTEXT_GOTOURL: 1591 case IDC_CONTENT_CONTEXT_GOTOURL:
1595 case IDC_SPELLPANEL_TOGGLE: 1592 case IDC_SPELLPANEL_TOGGLE:
1596 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: 1593 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS:
1597 return true; 1594 return true;
1598 case IDC_CHECK_SPELLING_WHILE_TYPING: 1595 case IDC_CHECK_SPELLING_WHILE_TYPING:
1599 return prefs->GetBoolean(prefs::kEnableContinuousSpellcheck); 1596 return prefs->GetBoolean(prefs::kEnableContinuousSpellcheck);
1600 1597
1601 #if !defined(OS_MACOSX) && defined(OS_POSIX) 1598 #if !defined(OS_MACOSX) && defined(OS_POSIX)
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 2077
2081 bool RenderViewContextMenu::IsPasteAndMatchStyleEnabled() const { 2078 bool RenderViewContextMenu::IsPasteAndMatchStyleEnabled() const {
2082 if (!(params_.edit_flags & WebContextMenuData::CanPaste)) 2079 if (!(params_.edit_flags & WebContextMenuData::CanPaste))
2083 return false; 2080 return false;
2084 2081
2085 return ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( 2082 return ui::Clipboard::GetForCurrentThread()->IsFormatAvailable(
2086 ui::Clipboard::GetPlainTextFormatType(), 2083 ui::Clipboard::GetPlainTextFormatType(),
2087 ui::CLIPBOARD_TYPE_COPY_PASTE); 2084 ui::CLIPBOARD_TYPE_COPY_PASTE);
2088 } 2085 }
2089 2086
2087 bool RenderViewContextMenu::IsPrintPreviewEnabled() const {
2088 if (params_.media_type != WebContextMenuData::MediaTypeNone &&
2089 !(params_.media_flags & WebContextMenuData::MediaCanPrint)) {
2090 return false;
2091 }
2092
2093 Browser* browser = GetBrowser();
2094 return browser && chrome::CanPrint(browser);
2095 }
2096
2090 bool RenderViewContextMenu::IsRouteMediaEnabled() const { 2097 bool RenderViewContextMenu::IsRouteMediaEnabled() const {
2091 if (!media_router::MediaRouterEnabled(browser_context_)) 2098 if (!media_router::MediaRouterEnabled(browser_context_))
2092 return false; 2099 return false;
2093 2100
2094 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_); 2101 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_);
2095 if (!browser) 2102 if (!browser)
2096 return false; 2103 return false;
2097 2104
2098 // Disable the command if there is an active modal dialog. 2105 // Disable the command if there is an active modal dialog.
2099 // We don't use |source_web_contents_| here because it could be the 2106 // We don't use |source_web_contents_| here because it could be the
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 source_web_contents_->GetRenderViewHost()-> 2449 source_web_contents_->GetRenderViewHost()->
2443 ExecuteMediaPlayerActionAtLocation(location, action); 2450 ExecuteMediaPlayerActionAtLocation(location, action);
2444 } 2451 }
2445 2452
2446 void RenderViewContextMenu::PluginActionAt( 2453 void RenderViewContextMenu::PluginActionAt(
2447 const gfx::Point& location, 2454 const gfx::Point& location,
2448 const WebPluginAction& action) { 2455 const WebPluginAction& action) {
2449 source_web_contents_->GetRenderViewHost()-> 2456 source_web_contents_->GetRenderViewHost()->
2450 ExecutePluginActionAtLocation(location, action); 2457 ExecutePluginActionAtLocation(location, action);
2451 } 2458 }
2459
2460 Browser* RenderViewContextMenu::GetBrowser() const {
2461 return chrome::FindBrowserWithWebContents(embedder_web_contents_);
2462 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698