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

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

Issue 7520023: Converted IncognitoForced boolean policy into IncognitoModeAvailability enum policy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix enum entry names & wrong include path. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 7
8 #include "chrome/browser/tab_contents/render_view_context_menu.h" 8 #include "chrome/browser/tab_contents/render_view_context_menu.h"
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/debugger/devtools_window.h" 22 #include "chrome/browser/debugger/devtools_window.h"
23 #include "chrome/browser/download/download_manager.h" 23 #include "chrome/browser/download/download_manager.h"
24 #include "chrome/browser/download/download_util.h" 24 #include "chrome/browser/download/download_util.h"
25 #include "chrome/browser/extensions/extension_event_router.h" 25 #include "chrome/browser/extensions/extension_event_router.h"
26 #include "chrome/browser/extensions/extension_service.h" 26 #include "chrome/browser/extensions/extension_service.h"
27 #include "chrome/browser/google/google_util.h" 27 #include "chrome/browser/google/google_util.h"
28 #include "chrome/browser/net/browser_url_util.h" 28 #include "chrome/browser/net/browser_url_util.h"
29 #include "chrome/browser/page_info_window.h" 29 #include "chrome/browser/page_info_window.h"
30 #include "chrome/browser/platform_util.h" 30 #include "chrome/browser/platform_util.h"
31 #include "chrome/browser/prefs/incognito_mode_prefs.h"
31 #include "chrome/browser/prefs/pref_member.h" 32 #include "chrome/browser/prefs/pref_member.h"
32 #include "chrome/browser/prefs/pref_service.h" 33 #include "chrome/browser/prefs/pref_service.h"
33 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/browser/profiles/profile_io_data.h" 35 #include "chrome/browser/profiles/profile_io_data.h"
35 #include "chrome/browser/search_engines/template_url.h" 36 #include "chrome/browser/search_engines/template_url.h"
36 #include "chrome/browser/search_engines/template_url_service.h" 37 #include "chrome/browser/search_engines/template_url_service.h"
37 #include "chrome/browser/search_engines/template_url_service_factory.h" 38 #include "chrome/browser/search_engines/template_url_service_factory.h"
38 #include "chrome/browser/spellchecker/spellcheck_host.h" 39 #include "chrome/browser/spellchecker/spellcheck_host.h"
39 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" 40 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
40 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" 41 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h"
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 // In the future we may add APIs for extensions to disable items, but for 956 // In the future we may add APIs for extensions to disable items, but for
956 // now all items are implicitly enabled. 957 // now all items are implicitly enabled.
957 return true; 958 return true;
958 } 959 }
959 960
960 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 961 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
961 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 962 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
962 return true; 963 return true;
963 } 964 }
964 965
966 IncognitoModePrefs::Availability incognito_avail =
967 IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
965 switch (id) { 968 switch (id) {
966 case IDC_BACK: 969 case IDC_BACK:
967 return source_tab_contents_->controller().CanGoBack(); 970 return source_tab_contents_->controller().CanGoBack();
968 971
969 case IDC_FORWARD: 972 case IDC_FORWARD:
970 return source_tab_contents_->controller().CanGoForward(); 973 return source_tab_contents_->controller().CanGoForward();
971 974
972 case IDC_RELOAD: 975 case IDC_RELOAD:
973 return source_tab_contents_->delegate() && 976 return source_tab_contents_->delegate() &&
974 source_tab_contents_->delegate()->CanReloadContents( 977 source_tab_contents_->delegate()->CanReloadContents(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 // unknown language (in which case the page language is detected on 1009 // unknown language (in which case the page language is detected on
1007 // the server side). 1010 // the server side).
1008 (original_lang == chrome::kUnknownLanguageCode || 1011 (original_lang == chrome::kUnknownLanguageCode ||
1009 TranslateManager::IsSupportedLanguage(original_lang)) && 1012 TranslateManager::IsSupportedLanguage(original_lang)) &&
1010 !helper->language_state().IsPageTranslated() && 1013 !helper->language_state().IsPageTranslated() &&
1011 !source_tab_contents_->interstitial_page() && 1014 !source_tab_contents_->interstitial_page() &&
1012 TranslateManager::IsTranslatableURL(params_.page_url); 1015 TranslateManager::IsTranslatableURL(params_.page_url);
1013 } 1016 }
1014 1017
1015 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: 1018 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB:
1019 return params_.link_url.is_valid();
1016 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: 1020 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW:
1017 return params_.link_url.is_valid(); 1021 return params_.link_url.is_valid() &&
1022 incognito_avail != IncognitoModePrefs::FORCED;
1018 1023
1019 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1024 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
1020 return params_.unfiltered_link_url.is_valid(); 1025 return params_.unfiltered_link_url.is_valid();
1021 1026
1022 case IDC_CONTENT_CONTEXT_SAVELINKAS: { 1027 case IDC_CONTENT_CONTEXT_SAVELINKAS: {
1023 PrefService* local_state = g_browser_process->local_state(); 1028 PrefService* local_state = g_browser_process->local_state();
1024 DCHECK(local_state); 1029 DCHECK(local_state);
1025 // Test if file-selection dialogs are forbidden by policy. 1030 // Test if file-selection dialogs are forbidden by policy.
1026 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) 1031 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs))
1027 return false; 1032 return false;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 return !!(params_.edit_flags & WebContextMenuData::CanPaste); 1136 return !!(params_.edit_flags & WebContextMenuData::CanPaste);
1132 1137
1133 case IDC_CONTENT_CONTEXT_DELETE: 1138 case IDC_CONTENT_CONTEXT_DELETE:
1134 return !!(params_.edit_flags & WebContextMenuData::CanDelete); 1139 return !!(params_.edit_flags & WebContextMenuData::CanDelete);
1135 1140
1136 case IDC_CONTENT_CONTEXT_SELECTALL: 1141 case IDC_CONTENT_CONTEXT_SELECTALL:
1137 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); 1142 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll);
1138 1143
1139 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: 1144 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD:
1140 return !profile_->IsOffTheRecord() && params_.link_url.is_valid() && 1145 return !profile_->IsOffTheRecord() && params_.link_url.is_valid() &&
1141 profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled); 1146 incognito_avail != IncognitoModePrefs::DISABLED;
1142 1147
1143 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: 1148 case IDC_SPELLCHECK_ADD_TO_DICTIONARY:
1144 return !params_.misspelled_word.empty(); 1149 return !params_.misspelled_word.empty();
1145 1150
1146 case IDC_PRINT: 1151 case IDC_PRINT:
1147 if (g_browser_process->local_state() && 1152 if (g_browser_process->local_state() &&
1148 !g_browser_process->local_state()->GetBoolean( 1153 !g_browser_process->local_state()->GetBoolean(
1149 prefs::kPrintingEnabled)) { 1154 prefs::kPrintingEnabled)) {
1150 return false; 1155 return false;
1151 } 1156 }
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 g_browser_process->clipboard()); 1829 g_browser_process->clipboard());
1825 } 1830 }
1826 1831
1827 void RenderViewContextMenu::MediaPlayerActionAt( 1832 void RenderViewContextMenu::MediaPlayerActionAt(
1828 const gfx::Point& location, 1833 const gfx::Point& location,
1829 const WebMediaPlayerAction& action) { 1834 const WebMediaPlayerAction& action) {
1830 RenderViewHost* rvh = source_tab_contents_->render_view_host(); 1835 RenderViewHost* rvh = source_tab_contents_->render_view_host();
1831 rvh->Send(new ViewMsg_MediaPlayerActionAt( 1836 rvh->Send(new ViewMsg_MediaPlayerActionAt(
1832 rvh->routing_id(), location, action)); 1837 rvh->routing_id(), location, action));
1833 } 1838 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698