| 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 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 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) != |
| 1022 IncognitoModePrefs::FORCED; |
| 1019 | 1023 |
| 1020 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: | 1024 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: |
| 1021 return params_.unfiltered_link_url.is_valid(); | 1025 return params_.unfiltered_link_url.is_valid(); |
| 1022 | 1026 |
| 1023 case IDC_CONTENT_CONTEXT_SAVELINKAS: { | 1027 case IDC_CONTENT_CONTEXT_SAVELINKAS: { |
| 1024 PrefService* local_state = g_browser_process->local_state(); | 1028 PrefService* local_state = g_browser_process->local_state(); |
| 1025 DCHECK(local_state); | 1029 DCHECK(local_state); |
| 1026 // Test if file-selection dialogs are forbidden by policy. | 1030 // Test if file-selection dialogs are forbidden by policy. |
| 1027 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1031 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 1028 return false; | 1032 return false; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 return !!(params_.edit_flags & WebContextMenuData::CanPaste); | 1136 return !!(params_.edit_flags & WebContextMenuData::CanPaste); |
| 1133 | 1137 |
| 1134 case IDC_CONTENT_CONTEXT_DELETE: | 1138 case IDC_CONTENT_CONTEXT_DELETE: |
| 1135 return !!(params_.edit_flags & WebContextMenuData::CanDelete); | 1139 return !!(params_.edit_flags & WebContextMenuData::CanDelete); |
| 1136 | 1140 |
| 1137 case IDC_CONTENT_CONTEXT_SELECTALL: | 1141 case IDC_CONTENT_CONTEXT_SELECTALL: |
| 1138 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); | 1142 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); |
| 1139 | 1143 |
| 1140 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: | 1144 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: |
| 1141 return !profile_->IsOffTheRecord() && params_.link_url.is_valid() && | 1145 return !profile_->IsOffTheRecord() && params_.link_url.is_valid() && |
| 1142 profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled); | 1146 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) != |
| 1147 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 |