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

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

Issue 1838043002: Disabled "Print" option in wrench menu for a crashed page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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 != nullptr && !current_tab->IsCrashed()) &&
Peter Kasting 2016/03/29 02:55:13 Nit: "!= nullptr" usually gets omitted
Tom (Use chromium acct) 2016/03/31 17:13:44 Done.
886 !(IsShowingWebContentsModalDialog(browser) || 889 !(IsShowingWebContentsModalDialog(browser) ||
887 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); 890 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT);
Peter Kasting 2016/03/29 02:55:13 Nit: While here: Seems like this line should be in
Tom (Use chromium acct) 2016/03/31 17:13:44 Done.
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698