Index: chrome/browser/ui/browser_commands.cc |
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc |
index 14c1957a533061531b962ea5297480f81542a552..c3ee94d93d81faca1679e3be092ffc031e9752a3 100644 |
--- a/chrome/browser/ui/browser_commands.cc |
+++ b/chrome/browser/ui/browser_commands.cc |
@@ -654,8 +654,8 @@ void ShowChromeToMobileBubble(Browser* browser) { |
} |
void Print(Browser* browser) { |
- if (g_browser_process->local_state()->GetBoolean( |
- prefs::kPrintPreviewDisabled)) { |
+ if (browser->profile()->GetPrefs()->GetBoolean( |
+ prefs::kPrintPreviewDisabled)) { |
GetActiveTabContents(browser)->print_view_manager()->PrintNow(); |
} else { |
GetActiveTabContents(browser)->print_view_manager()-> |
@@ -664,15 +664,11 @@ void Print(Browser* browser) { |
} |
bool CanPrint(const Browser* browser) { |
- // LocalState can be NULL in tests. |
- if (g_browser_process->local_state() && |
- !g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled)) { |
- return false; |
- } |
- |
+ // Do not print when printing is disabled via pref or policy. |
// Do not print when a constrained window is showing. It's confusing. |
// Do not print if instant extended API is enabled and mode is NTP. |
- return !(HasConstrainedWindow(browser) || |
+ return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
+ !(HasConstrainedWindow(browser) || |
GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT || |
IsNTPModeForInstantExtendedAPI(browser)); |
} |
@@ -683,14 +679,10 @@ void AdvancedPrint(Browser* browser) { |
} |
bool CanAdvancedPrint(const Browser* browser) { |
- // LocalState can be NULL in tests. |
- if (g_browser_process->local_state() && |
- !g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled)) { |
- return false; |
- } |
- |
- // It is always possible to advanced print when print preview is visible. |
- return PrintPreviewShowing(browser) || CanPrint(browser); |
+ // If printing is not disabled via pref or policy, it is always possible to |
+ // advanced print when the print preview is visible. |
+ return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
+ (PrintPreviewShowing(browser) || CanPrint(browser)); |
} |
void PrintToDestination(Browser* browser) { |