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

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

Issue 8879046: Print preview: Disable the right context menu items in print preview. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years 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 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/tab_contents/render_view_context_menu.h" 9 #include "chrome/browser/tab_contents/render_view_context_menu.h"
10 10
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 #ifdef FILE_MANAGER_EXTENSION 193 #ifdef FILE_MANAGER_EXTENSION
194 if (page_url.SchemeIs("chrome-extension") && 194 if (page_url.SchemeIs("chrome-extension") &&
195 page_url.DomainIs(kFileBrowserDomain)) 195 page_url.DomainIs(kFileBrowserDomain))
196 return false; 196 return false;
197 #endif 197 #endif
198 198
199 return true; 199 return true;
200 } 200 }
201 201
202 bool IsPrintPreviewTab(TabContents* tab) {
203 printing::PrintPreviewTabController* controller =
204 printing::PrintPreviewTabController::GetInstance();
205 if (!controller)
206 return false;
207 TabContentsWrapper* wrapper =
208 TabContentsWrapper::GetCurrentWrapperForContents(tab);
209 return !controller->GetPrintPreviewForTab(wrapper);
210 }
211
202 } // namespace 212 } // namespace
203 213
204 // static 214 // static
205 const size_t RenderViewContextMenu::kMaxExtensionItemTitleLength = 75; 215 const size_t RenderViewContextMenu::kMaxExtensionItemTitleLength = 75;
206 // static 216 // static
207 const size_t RenderViewContextMenu::kMaxSelectionTextLength = 50; 217 const size_t RenderViewContextMenu::kMaxSelectionTextLength = 50;
208 218
209 // static 219 // static
210 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { 220 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) {
211 return url.SchemeIs(chrome::kChromeDevToolsScheme) && 221 return url.SchemeIs(chrome::kChromeDevToolsScheme) &&
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 } 973 }
964 974
965 // Menu delegate functions ----------------------------------------------------- 975 // Menu delegate functions -----------------------------------------------------
966 976
967 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { 977 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
968 // If this command is is added by one of our observers, we dispatch it to the 978 // If this command is is added by one of our observers, we dispatch it to the
969 // observer. 979 // observer.
970 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); 980 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_);
971 RenderViewContextMenuObserver* observer; 981 RenderViewContextMenuObserver* observer;
972 while ((observer = it.GetNext()) != NULL) { 982 while ((observer = it.GetNext()) != NULL) {
973 if (observer->IsCommandIdSupported(id)) 983 if (observer->IsCommandIdSupported(id))
vandebo (ex-Chrome) 2011/12/09 17:40:19 Could print preview just be a RenderViewContextMen
Lei Zhang 2011/12/10 01:37:23 Sure, we can do that. See patch set 2.
974 return observer->IsCommandIdEnabled(id); 984 return observer->IsCommandIdEnabled(id);
975 } 985 }
976 986
977 if (id == IDC_PRINT && 987 if (id == IDC_PRINT &&
978 (source_tab_contents_->content_restrictions() & 988 (source_tab_contents_->content_restrictions() &
979 content::CONTENT_RESTRICTION_PRINT)) { 989 content::CONTENT_RESTRICTION_PRINT)) {
980 return false; 990 return false;
981 } 991 }
982 992
983 if (id == IDC_SAVE_PAGE && 993 if (id == IDC_SAVE_PAGE &&
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 case IDC_FORWARD: 1030 case IDC_FORWARD:
1021 return source_tab_contents_->controller().CanGoForward(); 1031 return source_tab_contents_->controller().CanGoForward();
1022 1032
1023 case IDC_RELOAD: 1033 case IDC_RELOAD:
1024 return source_tab_contents_->delegate() && 1034 return source_tab_contents_->delegate() &&
1025 source_tab_contents_->delegate()->CanReloadContents( 1035 source_tab_contents_->delegate()->CanReloadContents(
1026 source_tab_contents_); 1036 source_tab_contents_);
1027 1037
1028 case IDC_VIEW_SOURCE: 1038 case IDC_VIEW_SOURCE:
1029 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: 1039 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE:
1040 if (IsPrintPreviewTab(source_tab_contents_))
1041 return false;
1030 return source_tab_contents_->controller().CanViewSource(); 1042 return source_tab_contents_->controller().CanViewSource();
1031 1043
1032 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: 1044 case IDC_CONTENT_CONTEXT_INSPECTELEMENT:
1033 return IsDevCommandEnabled(id); 1045 return IsDevCommandEnabled(id);
1034 1046
1035 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: 1047 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO:
1048 if (IsPrintPreviewTab(source_tab_contents_))
1049 return false;
1036 return source_tab_contents_->controller().GetActiveEntry() != NULL; 1050 return source_tab_contents_->controller().GetActiveEntry() != NULL;
1037 1051
1038 case IDC_CONTENT_CONTEXT_TRANSLATE: { 1052 case IDC_CONTENT_CONTEXT_TRANSLATE: {
1039 TabContentsWrapper* tab_contents_wrapper = 1053 TabContentsWrapper* tab_contents_wrapper =
1040 TabContentsWrapper::GetCurrentWrapperForContents( 1054 TabContentsWrapper::GetCurrentWrapperForContents(
1041 source_tab_contents_); 1055 source_tab_contents_);
1042 if (!tab_contents_wrapper) 1056 if (!tab_contents_wrapper)
1043 return false; 1057 return false;
1044 TranslateTabHelper* helper = tab_contents_wrapper->translate_tab_helper(); 1058 TranslateTabHelper* helper = tab_contents_wrapper->translate_tab_helper();
1045 std::string original_lang = 1059 std::string original_lang =
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 case IDC_PRINT: 1210 case IDC_PRINT:
1197 if (g_browser_process->local_state() && 1211 if (g_browser_process->local_state() &&
1198 !g_browser_process->local_state()->GetBoolean( 1212 !g_browser_process->local_state()->GetBoolean(
1199 prefs::kPrintingEnabled)) { 1213 prefs::kPrintingEnabled)) {
1200 return false; 1214 return false;
1201 } 1215 }
1202 return params_.media_type == WebContextMenuData::MediaTypeNone || 1216 return params_.media_type == WebContextMenuData::MediaTypeNone ||
1203 params_.media_flags & WebContextMenuData::MediaCanPrint; 1217 params_.media_flags & WebContextMenuData::MediaCanPrint;
1204 1218
1205 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR: 1219 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR:
1220 return !IsPrintPreviewTab(source_tab_contents_);
1221
1206 case IDC_CONTENT_CONTEXT_GOTOURL: 1222 case IDC_CONTENT_CONTEXT_GOTOURL:
1207 case IDC_SPELLPANEL_TOGGLE: 1223 case IDC_SPELLPANEL_TOGGLE:
1208 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: 1224 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS:
1209 case IDC_CONTENT_CONTEXT_VIEWFRAMEINFO: 1225 case IDC_CONTENT_CONTEXT_VIEWFRAMEINFO:
1210 return true; 1226 return true;
1211 1227
1212 case IDC_CHECK_SPELLING_OF_THIS_FIELD: 1228 case IDC_CHECK_SPELLING_OF_THIS_FIELD:
1213 return profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck); 1229 return profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck);
1214 1230
1215 #if defined(OS_MACOSX) 1231 #if defined(OS_MACOSX)
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1844 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1829 g_browser_process->clipboard()); 1845 g_browser_process->clipboard());
1830 } 1846 }
1831 1847
1832 void RenderViewContextMenu::MediaPlayerActionAt( 1848 void RenderViewContextMenu::MediaPlayerActionAt(
1833 const gfx::Point& location, 1849 const gfx::Point& location,
1834 const WebMediaPlayerAction& action) { 1850 const WebMediaPlayerAction& action) {
1835 source_tab_contents_->render_view_host()-> 1851 source_tab_contents_->render_view_host()->
1836 ExecuteMediaPlayerActionAtLocation(location, action); 1852 ExecuteMediaPlayerActionAtLocation(location, action);
1837 } 1853 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698