OLD | NEW |
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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 // Do not print when a constrained window is showing. It's confusing. | 865 // Do not print when a constrained window is showing. It's confusing. |
866 // TODO(gbillock): Need to re-assess the call to | 866 // TODO(gbillock): Need to re-assess the call to |
867 // IsShowingWebContentsModalDialog after a popup management policy is | 867 // IsShowingWebContentsModalDialog after a popup management policy is |
868 // refined -- we will probably want to just queue the print request, not | 868 // refined -- we will probably want to just queue the print request, not |
869 // block it. | 869 // block it. |
870 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 870 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
871 !(IsShowingWebContentsModalDialog(browser) || | 871 !(IsShowingWebContentsModalDialog(browser) || |
872 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); | 872 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); |
873 } | 873 } |
874 | 874 |
| 875 #if !defined(OS_WIN) |
875 void AdvancedPrint(Browser* browser) { | 876 void AdvancedPrint(Browser* browser) { |
876 #if defined(ENABLE_FULL_PRINTING) | 877 #if defined(ENABLE_FULL_PRINTING) |
877 printing::PrintViewManager* print_view_manager = | 878 printing::PrintViewManager* print_view_manager = |
878 printing::PrintViewManager::FromWebContents( | 879 printing::PrintViewManager::FromWebContents( |
879 browser->tab_strip_model()->GetActiveWebContents()); | 880 browser->tab_strip_model()->GetActiveWebContents()); |
880 print_view_manager->AdvancedPrintNow(); | 881 print_view_manager->AdvancedPrintNow(); |
881 #endif | 882 #endif |
882 } | 883 } |
883 | 884 |
884 bool CanAdvancedPrint(Browser* browser) { | 885 bool CanAdvancedPrint(Browser* browser) { |
885 // If printing is not disabled via pref or policy, it is always possible to | |
886 // advanced print when the print preview is visible. The exception to this | |
887 // is under Win8 ash, since showing the advanced print dialog will open it | |
888 // modally on the Desktop and hang the browser. We can remove this check | |
889 // once we integrate with the system print charm. | |
890 #if defined(OS_WIN) | |
891 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) | |
892 return false; | |
893 #endif | |
894 | |
895 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 886 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
896 (PrintPreviewShowing(browser) || CanPrint(browser)); | 887 (PrintPreviewShowing(browser) || CanPrint(browser)); |
897 } | 888 } |
| 889 #endif // !OS_WIN |
898 | 890 |
899 void PrintToDestination(Browser* browser) { | 891 void PrintToDestination(Browser* browser) { |
900 #if defined(ENABLE_FULL_PRINTING) | 892 #if defined(ENABLE_FULL_PRINTING) |
901 printing::PrintViewManager* print_view_manager = | 893 printing::PrintViewManager* print_view_manager = |
902 printing::PrintViewManager::FromWebContents( | 894 printing::PrintViewManager::FromWebContents( |
903 browser->tab_strip_model()->GetActiveWebContents()); | 895 browser->tab_strip_model()->GetActiveWebContents()); |
904 print_view_manager->PrintToDestination(); | 896 print_view_manager->PrintToDestination(); |
905 #endif | 897 #endif |
906 } | 898 } |
907 | 899 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 browser->profile(), | 1269 browser->profile(), |
1278 browser->host_desktop_type())); | 1270 browser->host_desktop_type())); |
1279 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1271 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1280 | 1272 |
1281 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1273 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1282 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1274 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1283 app_browser->window()->Show(); | 1275 app_browser->window()->Show(); |
1284 } | 1276 } |
1285 | 1277 |
1286 } // namespace chrome | 1278 } // namespace chrome |
OLD | NEW |