| 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 #if defined(ENABLE_PRINTING) | 870 #if defined(ENABLE_PRINTING) |
| 871 printing::StartPrint( | 871 printing::StartPrint( |
| 872 browser->tab_strip_model()->GetActiveWebContents(), | 872 browser->tab_strip_model()->GetActiveWebContents(), |
| 873 browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled), | 873 browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled), |
| 874 false); | 874 false); |
| 875 #endif // defined(ENABLE_PRINTING) | 875 #endif // defined(ENABLE_PRINTING) |
| 876 } | 876 } |
| 877 | 877 |
| 878 bool CanPrint(Browser* browser) { | 878 bool CanPrint(Browser* browser) { |
| 879 // Do not print when printing is disabled via pref or policy. | 879 // Do not print when printing is disabled via pref or policy. |
| 880 // Do not print when a page has crashed. |
| 880 // Do not print when a constrained window is showing. It's confusing. | 881 // Do not print when a constrained window is showing. It's confusing. |
| 881 // TODO(gbillock): Need to re-assess the call to | 882 // TODO(gbillock): Need to re-assess the call to |
| 882 // IsShowingWebContentsModalDialog after a popup management policy is | 883 // IsShowingWebContentsModalDialog after a popup management policy is |
| 883 // refined -- we will probably want to just queue the print request, not | 884 // refined -- we will probably want to just queue the print request, not |
| 884 // block it. | 885 // block it. |
| 886 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); |
| 885 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 887 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
| 888 (current_tab && !current_tab->IsCrashed()) && |
| 886 !(IsShowingWebContentsModalDialog(browser) || | 889 !(IsShowingWebContentsModalDialog(browser) || |
| 887 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); | 890 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); |
| 888 } | 891 } |
| 889 | 892 |
| 890 #if defined(ENABLE_BASIC_PRINTING) | 893 #if defined(ENABLE_BASIC_PRINTING) |
| 891 void BasicPrint(Browser* browser) { | 894 void BasicPrint(Browser* browser) { |
| 892 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); | 895 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); |
| 893 } | 896 } |
| 894 | 897 |
| 895 bool CanBasicPrint(Browser* browser) { | 898 bool CanBasicPrint(Browser* browser) { |
| 896 // If printing is not disabled via pref or policy, it is always possible to | 899 // If printing is not disabled via pref or policy, it is always possible to |
| 897 // advanced print when the print preview is visible. | 900 // advanced print when the print preview is visible. |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); | 1286 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); |
| 1284 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1287 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1285 | 1288 |
| 1286 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1289 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1287 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1290 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1288 app_browser->window()->Show(); | 1291 app_browser->window()->Show(); |
| 1289 } | 1292 } |
| 1290 #endif // defined(ENABLE_EXTENSIONS) | 1293 #endif // defined(ENABLE_EXTENSIONS) |
| 1291 | 1294 |
| 1292 } // namespace chrome | 1295 } // namespace chrome |
| OLD | NEW |