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

Side by Side Diff: chrome/browser/ui/browser_commands.cc

Issue 702603004: Renamed DISABLE_BASIC_PRINTING and ENABLE_FULL_PRINTING. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wed Nov 5 02:31:54 PST 2014 Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "chrome/browser/ui/browser_commands.h" 5 #include "chrome/browser/ui/browser_commands.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" 89 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
90 #include "chrome/browser/web_applications/web_app.h" 90 #include "chrome/browser/web_applications/web_app.h"
91 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 91 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
92 #include "extensions/browser/extension_registry.h" 92 #include "extensions/browser/extension_registry.h"
93 #include "extensions/browser/extension_system.h" 93 #include "extensions/browser/extension_system.h"
94 #include "extensions/common/extension.h" 94 #include "extensions/common/extension.h"
95 #include "extensions/common/extension_set.h" 95 #include "extensions/common/extension_set.h"
96 #endif 96 #endif
97 97
98 #if defined(ENABLE_PRINTING) 98 #if defined(ENABLE_PRINTING)
99 #if defined(ENABLE_FULL_PRINTING) 99 #if defined(ENABLE_PRINT_PREVIEW)
100 #include "chrome/browser/printing/print_preview_dialog_controller.h" 100 #include "chrome/browser/printing/print_preview_dialog_controller.h"
101 #include "chrome/browser/printing/print_view_manager.h" 101 #include "chrome/browser/printing/print_view_manager.h"
102 #else 102 #else
103 #include "chrome/browser/printing/print_view_manager_basic.h" 103 #include "chrome/browser/printing/print_view_manager_basic.h"
104 #endif // defined(ENABLE_FULL_PRINTING) 104 #endif // defined(ENABLE_PRINT_PREVIEW)
105 #endif // defined(ENABLE_PRINTING) 105 #endif // defined(ENABLE_PRINTING)
106 106
107 namespace { 107 namespace {
108 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; 108 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3";
109 } 109 }
110 110
111 using base::UserMetricsAction; 111 using base::UserMetricsAction;
112 using content::NavigationController; 112 using content::NavigationController;
113 using content::NavigationEntry; 113 using content::NavigationEntry;
114 using content::OpenURLParams; 114 using content::OpenURLParams;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 return false; 262 return false;
263 263
264 // TODO(gbillock): This is currently called in production by the CanPrint 264 // TODO(gbillock): This is currently called in production by the CanPrint
265 // method, and may be too restrictive if we allow print preview to overlap. 265 // method, and may be too restrictive if we allow print preview to overlap.
266 // Re-assess how to queue print preview after we know more about popup 266 // Re-assess how to queue print preview after we know more about popup
267 // management policy. 267 // management policy.
268 return browser->popup_manager()->IsWebModalDialogActive(web_contents); 268 return browser->popup_manager()->IsWebModalDialogActive(web_contents);
269 } 269 }
270 270
271 bool PrintPreviewShowing(const Browser* browser) { 271 bool PrintPreviewShowing(const Browser* browser) {
272 #if defined(ENABLE_FULL_PRINTING) 272 #if defined(ENABLE_PRINT_PREVIEW)
273 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); 273 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents();
274 printing::PrintPreviewDialogController* controller = 274 printing::PrintPreviewDialogController* controller =
275 printing::PrintPreviewDialogController::GetInstance(); 275 printing::PrintPreviewDialogController::GetInstance();
276 return controller && (controller->GetPrintPreviewForContents(contents) || 276 return controller && (controller->GetPrintPreviewForContents(contents) ||
277 controller->is_creating_print_preview_dialog()); 277 controller->is_creating_print_preview_dialog());
278 #else 278 #else
279 return false; 279 return false;
280 #endif 280 #endif
281 } 281 }
282 282
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 const SSLStatus& ssl) { 852 const SSLStatus& ssl) {
853 browser->window()->ShowWebsiteSettings( 853 browser->window()->ShowWebsiteSettings(
854 Profile::FromBrowserContext(web_contents->GetBrowserContext()), 854 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
855 web_contents, url, ssl); 855 web_contents, url, ssl);
856 } 856 }
857 857
858 void Print(Browser* browser) { 858 void Print(Browser* browser) {
859 #if defined(ENABLE_PRINTING) 859 #if defined(ENABLE_PRINTING)
860 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); 860 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents();
861 861
862 #if defined(ENABLE_FULL_PRINTING) 862 #if defined(ENABLE_PRINT_PREVIEW)
863 printing::PrintViewManager* print_view_manager = 863 printing::PrintViewManager* print_view_manager =
864 printing::PrintViewManager::FromWebContents(contents); 864 printing::PrintViewManager::FromWebContents(contents);
865 if (!browser->profile()->GetPrefs()->GetBoolean( 865 if (!browser->profile()->GetPrefs()->GetBoolean(
866 prefs::kPrintPreviewDisabled)) { 866 prefs::kPrintPreviewDisabled)) {
867 print_view_manager->PrintPreviewNow(false); 867 print_view_manager->PrintPreviewNow(false);
868 return; 868 return;
869 } 869 }
870 #else // ENABLE_FULL_PRINTING 870 #else // ENABLE_PRINT_PREVIEW
871 printing::PrintViewManagerBasic* print_view_manager = 871 printing::PrintViewManagerBasic* print_view_manager =
872 printing::PrintViewManagerBasic::FromWebContents(contents); 872 printing::PrintViewManagerBasic::FromWebContents(contents);
873 #endif // ENABLE_FULL_PRINTING 873 #endif // ENABLE_PRINT_PREVIEW
874 874
875 #if !defined(DISABLE_BASIC_PRINTING) 875 #if defined(ENABLE_BASIC_PRINTING)
876 print_view_manager->PrintNow(); 876 print_view_manager->PrintNow();
877 #endif // DISABLE_BASIC_PRINTING 877 #endif // ENABLE_BASIC_PRINTING
878 878
879 #endif // defined(ENABLE_PRINTING) 879 #endif // defined(ENABLE_PRINTING)
880 } 880 }
881 881
882 bool CanPrint(Browser* browser) { 882 bool CanPrint(Browser* browser) {
883 // Do not print when printing is disabled via pref or policy. 883 // Do not print when printing is disabled via pref or policy.
884 // Do not print when a constrained window is showing. It's confusing. 884 // Do not print when a constrained window is showing. It's confusing.
885 // TODO(gbillock): Need to re-assess the call to 885 // TODO(gbillock): Need to re-assess the call to
886 // IsShowingWebContentsModalDialog after a popup management policy is 886 // IsShowingWebContentsModalDialog after a popup management policy is
887 // refined -- we will probably want to just queue the print request, not 887 // refined -- we will probably want to just queue the print request, not
888 // block it. 888 // block it.
889 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && 889 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
890 !(IsShowingWebContentsModalDialog(browser) || 890 !(IsShowingWebContentsModalDialog(browser) ||
891 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); 891 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT);
892 } 892 }
893 893
894 #if !defined(DISABLE_BASIC_PRINTING) 894 #if defined(ENABLE_BASIC_PRINTING)
895 void BasicPrint(Browser* browser) { 895 void BasicPrint(Browser* browser) {
896 #if defined(ENABLE_FULL_PRINTING) 896 #if defined(ENABLE_PRINT_PREVIEW)
897 printing::PrintViewManager* print_view_manager = 897 printing::PrintViewManager* print_view_manager =
898 printing::PrintViewManager::FromWebContents( 898 printing::PrintViewManager::FromWebContents(
899 browser->tab_strip_model()->GetActiveWebContents()); 899 browser->tab_strip_model()->GetActiveWebContents());
900 print_view_manager->BasicPrint(); 900 print_view_manager->BasicPrint();
901 #endif 901 #endif
902 } 902 }
903 903
904 bool CanBasicPrint(Browser* browser) { 904 bool CanBasicPrint(Browser* browser) {
905 // If printing is not disabled via pref or policy, it is always possible to 905 // If printing is not disabled via pref or policy, it is always possible to
906 // advanced print when the print preview is visible. The exception to this 906 // advanced print when the print preview is visible. The exception to this
907 // is under Win8 ash, since showing the advanced print dialog will open it 907 // is under Win8 ash, since showing the advanced print dialog will open it
908 // modally on the Desktop and hang the browser. 908 // modally on the Desktop and hang the browser.
909 #if defined(OS_WIN) 909 #if defined(OS_WIN)
910 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) 910 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
911 return false; 911 return false;
912 #endif 912 #endif
913 913
914 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && 914 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
915 (PrintPreviewShowing(browser) || CanPrint(browser)); 915 (PrintPreviewShowing(browser) || CanPrint(browser));
916 } 916 }
917 #endif // !DISABLE_BASIC_PRINTING 917 #endif // ENABLE_BASIC_PRINTING
918 918
919 void EmailPageLocation(Browser* browser) { 919 void EmailPageLocation(Browser* browser) {
920 content::RecordAction(UserMetricsAction("EmailPageLocation")); 920 content::RecordAction(UserMetricsAction("EmailPageLocation"));
921 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); 921 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents();
922 DCHECK(wc); 922 DCHECK(wc);
923 923
924 std::string title = net::EscapeQueryParamValue( 924 std::string title = net::EscapeQueryParamValue(
925 base::UTF16ToUTF8(wc->GetTitle()), false); 925 base::UTF16ToUTF8(wc->GetTitle()), false);
926 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); 926 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false);
927 std::string mailto = std::string("mailto:?subject=Fwd:%20") + 927 std::string mailto = std::string("mailto:?subject=Fwd:%20") +
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 browser->host_desktop_type())); 1288 browser->host_desktop_type()));
1289 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1289 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1290 1290
1291 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1291 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1292 contents->GetRenderViewHost()->SyncRendererPrefs(); 1292 contents->GetRenderViewHost()->SyncRendererPrefs();
1293 app_browser->window()->Show(); 1293 app_browser->window()->Show();
1294 } 1294 }
1295 #endif // defined(ENABLE_EXTENSIONS) 1295 #endif // defined(ENABLE_EXTENSIONS)
1296 1296
1297 } // namespace chrome 1297 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698