| 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_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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 // In the future we may add APIs for extensions to disable items, but for | 957 // In the future we may add APIs for extensions to disable items, but for |
| 957 // now all items are implicitly enabled. | 958 // now all items are implicitly enabled. |
| 958 return true; | 959 return true; |
| 959 } | 960 } |
| 960 | 961 |
| 961 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && | 962 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && |
| 962 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { | 963 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { |
| 963 return true; | 964 return true; |
| 964 } | 965 } |
| 965 | 966 |
| 967 IncognitoModePrefs::Availability incognito_avail = |
| 968 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); |
| 966 switch (id) { | 969 switch (id) { |
| 967 case IDC_BACK: | 970 case IDC_BACK: |
| 968 return source_tab_contents_->controller().CanGoBack(); | 971 return source_tab_contents_->controller().CanGoBack(); |
| 969 | 972 |
| 970 case IDC_FORWARD: | 973 case IDC_FORWARD: |
| 971 return source_tab_contents_->controller().CanGoForward(); | 974 return source_tab_contents_->controller().CanGoForward(); |
| 972 | 975 |
| 973 case IDC_RELOAD: | 976 case IDC_RELOAD: |
| 974 return source_tab_contents_->delegate() && | 977 return source_tab_contents_->delegate() && |
| 975 source_tab_contents_->delegate()->CanReloadContents( | 978 source_tab_contents_->delegate()->CanReloadContents( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 // unknown language (in which case the page language is detected on | 1010 // unknown language (in which case the page language is detected on |
| 1008 // the server side). | 1011 // the server side). |
| 1009 (original_lang == chrome::kUnknownLanguageCode || | 1012 (original_lang == chrome::kUnknownLanguageCode || |
| 1010 TranslateManager::IsSupportedLanguage(original_lang)) && | 1013 TranslateManager::IsSupportedLanguage(original_lang)) && |
| 1011 !helper->language_state().IsPageTranslated() && | 1014 !helper->language_state().IsPageTranslated() && |
| 1012 !source_tab_contents_->interstitial_page() && | 1015 !source_tab_contents_->interstitial_page() && |
| 1013 TranslateManager::IsTranslatableURL(params_.page_url); | 1016 TranslateManager::IsTranslatableURL(params_.page_url); |
| 1014 } | 1017 } |
| 1015 | 1018 |
| 1016 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: | 1019 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: |
| 1020 return params_.link_url.is_valid(); |
| 1017 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: | 1021 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: |
| 1018 return params_.link_url.is_valid(); | 1022 return params_.link_url.is_valid() && |
| 1023 incognito_avail != IncognitoModePrefs::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 incognito_avail != IncognitoModePrefs::DISABLED; |
| 1143 | 1148 |
| 1144 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: | 1149 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: |
| 1145 return !params_.misspelled_word.empty(); | 1150 return !params_.misspelled_word.empty(); |
| 1146 | 1151 |
| 1147 case IDC_PRINT: | 1152 case IDC_PRINT: |
| 1148 if (g_browser_process->local_state() && | 1153 if (g_browser_process->local_state() && |
| 1149 !g_browser_process->local_state()->GetBoolean( | 1154 !g_browser_process->local_state()->GetBoolean( |
| 1150 prefs::kPrintingEnabled)) { | 1155 prefs::kPrintingEnabled)) { |
| 1151 return false; | 1156 return false; |
| 1152 } | 1157 } |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 g_browser_process->clipboard()); | 1828 g_browser_process->clipboard()); |
| 1824 } | 1829 } |
| 1825 | 1830 |
| 1826 void RenderViewContextMenu::MediaPlayerActionAt( | 1831 void RenderViewContextMenu::MediaPlayerActionAt( |
| 1827 const gfx::Point& location, | 1832 const gfx::Point& location, |
| 1828 const WebMediaPlayerAction& action) { | 1833 const WebMediaPlayerAction& action) { |
| 1829 RenderViewHost* rvh = source_tab_contents_->render_view_host(); | 1834 RenderViewHost* rvh = source_tab_contents_->render_view_host(); |
| 1830 rvh->Send(new ViewMsg_MediaPlayerActionAt( | 1835 rvh->Send(new ViewMsg_MediaPlayerActionAt( |
| 1831 rvh->routing_id(), location, action)); | 1836 rvh->routing_id(), location, action)); |
| 1832 } | 1837 } |
| OLD | NEW |