OLD | NEW |
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 Loading... |
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_availability_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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 // unknown language (in which case the page language is detected on | 1008 // unknown language (in which case the page language is detected on |
1008 // the server side). | 1009 // the server side). |
1009 (original_lang == chrome::kUnknownLanguageCode || | 1010 (original_lang == chrome::kUnknownLanguageCode || |
1010 TranslateManager::IsSupportedLanguage(original_lang)) && | 1011 TranslateManager::IsSupportedLanguage(original_lang)) && |
1011 !helper->language_state().IsPageTranslated() && | 1012 !helper->language_state().IsPageTranslated() && |
1012 !source_tab_contents_->interstitial_page() && | 1013 !source_tab_contents_->interstitial_page() && |
1013 TranslateManager::IsTranslatableURL(params_.page_url); | 1014 TranslateManager::IsTranslatableURL(params_.page_url); |
1014 } | 1015 } |
1015 | 1016 |
1016 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: | 1017 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: |
| 1018 return params_.link_url.is_valid(); |
1017 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: | 1019 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: |
1018 return params_.link_url.is_valid(); | 1020 return params_.link_url.is_valid() && |
| 1021 profile_->GetPrefs()->GetInteger( |
| 1022 prefs::kIncognitoModeAvailability) != |
| 1023 IncognitoModeAvailabilityPrefs::FORCED; |
1019 | 1024 |
1020 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: | 1025 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: |
1021 return params_.unfiltered_link_url.is_valid(); | 1026 return params_.unfiltered_link_url.is_valid(); |
1022 | 1027 |
1023 case IDC_CONTENT_CONTEXT_SAVELINKAS: { | 1028 case IDC_CONTENT_CONTEXT_SAVELINKAS: { |
1024 PrefService* local_state = g_browser_process->local_state(); | 1029 PrefService* local_state = g_browser_process->local_state(); |
1025 DCHECK(local_state); | 1030 DCHECK(local_state); |
1026 // Test if file-selection dialogs are forbidden by policy. | 1031 // Test if file-selection dialogs are forbidden by policy. |
1027 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1032 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
1028 return false; | 1033 return false; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 return !!(params_.edit_flags & WebContextMenuData::CanPaste); | 1137 return !!(params_.edit_flags & WebContextMenuData::CanPaste); |
1133 | 1138 |
1134 case IDC_CONTENT_CONTEXT_DELETE: | 1139 case IDC_CONTENT_CONTEXT_DELETE: |
1135 return !!(params_.edit_flags & WebContextMenuData::CanDelete); | 1140 return !!(params_.edit_flags & WebContextMenuData::CanDelete); |
1136 | 1141 |
1137 case IDC_CONTENT_CONTEXT_SELECTALL: | 1142 case IDC_CONTENT_CONTEXT_SELECTALL: |
1138 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); | 1143 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); |
1139 | 1144 |
1140 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: | 1145 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: |
1141 return !profile_->IsOffTheRecord() && params_.link_url.is_valid() && | 1146 return !profile_->IsOffTheRecord() && params_.link_url.is_valid() && |
1142 profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled); | 1147 profile_->GetPrefs()->GetInteger( |
| 1148 prefs::kIncognitoModeAvailability) != |
| 1149 IncognitoModeAvailabilityPrefs::DISABLED; |
1143 | 1150 |
1144 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: | 1151 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: |
1145 return !params_.misspelled_word.empty(); | 1152 return !params_.misspelled_word.empty(); |
1146 | 1153 |
1147 case IDC_PRINT: | 1154 case IDC_PRINT: |
1148 if (g_browser_process->local_state() && | 1155 if (g_browser_process->local_state() && |
1149 !g_browser_process->local_state()->GetBoolean( | 1156 !g_browser_process->local_state()->GetBoolean( |
1150 prefs::kPrintingEnabled)) { | 1157 prefs::kPrintingEnabled)) { |
1151 return false; | 1158 return false; |
1152 } | 1159 } |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 g_browser_process->clipboard()); | 1830 g_browser_process->clipboard()); |
1824 } | 1831 } |
1825 | 1832 |
1826 void RenderViewContextMenu::MediaPlayerActionAt( | 1833 void RenderViewContextMenu::MediaPlayerActionAt( |
1827 const gfx::Point& location, | 1834 const gfx::Point& location, |
1828 const WebMediaPlayerAction& action) { | 1835 const WebMediaPlayerAction& action) { |
1829 RenderViewHost* rvh = source_tab_contents_->render_view_host(); | 1836 RenderViewHost* rvh = source_tab_contents_->render_view_host(); |
1830 rvh->Send(new ViewMsg_MediaPlayerActionAt( | 1837 rvh->Send(new ViewMsg_MediaPlayerActionAt( |
1831 rvh->routing_id(), location, action)); | 1838 rvh->routing_id(), location, action)); |
1832 } | 1839 } |
OLD | NEW |