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

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: Removed unnecessary comment. 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
« no previous file with comments | « chrome/browser/profiles/profile.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 // In the future we may add APIs for extensions to disable items, but for 971 // In the future we may add APIs for extensions to disable items, but for
971 // now all items are implicitly enabled. 972 // now all items are implicitly enabled.
972 return true; 973 return true;
973 } 974 }
974 975
975 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 976 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
976 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 977 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
977 return true; 978 return true;
978 } 979 }
979 980
981 IncognitoModePrefs::Availability incognito_avail =
982 IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
980 switch (id) { 983 switch (id) {
981 case IDC_BACK: 984 case IDC_BACK:
982 return source_tab_contents_->controller().CanGoBack(); 985 return source_tab_contents_->controller().CanGoBack();
983 986
984 case IDC_FORWARD: 987 case IDC_FORWARD:
985 return source_tab_contents_->controller().CanGoForward(); 988 return source_tab_contents_->controller().CanGoForward();
986 989
987 case IDC_RELOAD: 990 case IDC_RELOAD:
988 return source_tab_contents_->delegate() && 991 return source_tab_contents_->delegate() &&
989 source_tab_contents_->delegate()->CanReloadContents( 992 source_tab_contents_->delegate()->CanReloadContents(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 // unknown language (in which case the page language is detected on 1024 // unknown language (in which case the page language is detected on
1022 // the server side). 1025 // the server side).
1023 (original_lang == chrome::kUnknownLanguageCode || 1026 (original_lang == chrome::kUnknownLanguageCode ||
1024 TranslateManager::IsSupportedLanguage(original_lang)) && 1027 TranslateManager::IsSupportedLanguage(original_lang)) &&
1025 !helper->language_state().IsPageTranslated() && 1028 !helper->language_state().IsPageTranslated() &&
1026 !source_tab_contents_->interstitial_page() && 1029 !source_tab_contents_->interstitial_page() &&
1027 TranslateManager::IsTranslatableURL(params_.page_url); 1030 TranslateManager::IsTranslatableURL(params_.page_url);
1028 } 1031 }
1029 1032
1030 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: 1033 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB:
1034 return params_.link_url.is_valid();
1031 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: 1035 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW:
1032 return params_.link_url.is_valid(); 1036 return params_.link_url.is_valid() &&
1037 incognito_avail != IncognitoModePrefs::FORCED;
1033 1038
1034 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1039 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
1035 return params_.unfiltered_link_url.is_valid(); 1040 return params_.unfiltered_link_url.is_valid();
1036 1041
1037 case IDC_CONTENT_CONTEXT_SAVELINKAS: { 1042 case IDC_CONTENT_CONTEXT_SAVELINKAS: {
1038 PrefService* local_state = g_browser_process->local_state(); 1043 PrefService* local_state = g_browser_process->local_state();
1039 DCHECK(local_state); 1044 DCHECK(local_state);
1040 // Test if file-selection dialogs are forbidden by policy. 1045 // Test if file-selection dialogs are forbidden by policy.
1041 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) 1046 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs))
1042 return false; 1047 return false;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 return !!(params_.edit_flags & WebContextMenuData::CanPaste); 1151 return !!(params_.edit_flags & WebContextMenuData::CanPaste);
1147 1152
1148 case IDC_CONTENT_CONTEXT_DELETE: 1153 case IDC_CONTENT_CONTEXT_DELETE:
1149 return !!(params_.edit_flags & WebContextMenuData::CanDelete); 1154 return !!(params_.edit_flags & WebContextMenuData::CanDelete);
1150 1155
1151 case IDC_CONTENT_CONTEXT_SELECTALL: 1156 case IDC_CONTENT_CONTEXT_SELECTALL:
1152 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); 1157 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll);
1153 1158
1154 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: 1159 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD:
1155 return !profile_->IsOffTheRecord() && params_.link_url.is_valid() && 1160 return !profile_->IsOffTheRecord() && params_.link_url.is_valid() &&
1156 profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled); 1161 incognito_avail != IncognitoModePrefs::DISABLED;
1157 1162
1158 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: 1163 case IDC_SPELLCHECK_ADD_TO_DICTIONARY:
1159 return !params_.misspelled_word.empty(); 1164 return !params_.misspelled_word.empty();
1160 1165
1161 case IDC_PRINT: 1166 case IDC_PRINT:
1162 if (g_browser_process->local_state() && 1167 if (g_browser_process->local_state() &&
1163 !g_browser_process->local_state()->GetBoolean( 1168 !g_browser_process->local_state()->GetBoolean(
1164 prefs::kPrintingEnabled)) { 1169 prefs::kPrintingEnabled)) {
1165 return false; 1170 return false;
1166 } 1171 }
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 g_browser_process->clipboard()); 1832 g_browser_process->clipboard());
1828 } 1833 }
1829 1834
1830 void RenderViewContextMenu::MediaPlayerActionAt( 1835 void RenderViewContextMenu::MediaPlayerActionAt(
1831 const gfx::Point& location, 1836 const gfx::Point& location,
1832 const WebMediaPlayerAction& action) { 1837 const WebMediaPlayerAction& action) {
1833 RenderViewHost* rvh = source_tab_contents_->render_view_host(); 1838 RenderViewHost* rvh = source_tab_contents_->render_view_host();
1834 rvh->Send(new ViewMsg_MediaPlayerActionAt( 1839 rvh->Send(new ViewMsg_MediaPlayerActionAt(
1835 rvh->routing_id(), location, action)); 1840 rvh->routing_id(), location, action));
1836 } 1841 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698