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

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

Issue 10808006: Move printing.* prefs from local state to profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased just in case as the CL is a few days old now plus I got my branches all mixed up a bit. Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/browser_ui_prefs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_editor.h" 10 #include "chrome/browser/bookmarks/bookmark_editor.h"
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 } 647 }
648 648
649 void ShowChromeToMobileBubble(Browser* browser) { 649 void ShowChromeToMobileBubble(Browser* browser) {
650 // Only show the bubble if the window is active, otherwise we may get into 650 // Only show the bubble if the window is active, otherwise we may get into
651 // weird situations where the bubble is deleted as soon as it is shown. 651 // weird situations where the bubble is deleted as soon as it is shown.
652 if (browser->window()->IsActive()) 652 if (browser->window()->IsActive())
653 browser->window()->ShowChromeToMobileBubble(); 653 browser->window()->ShowChromeToMobileBubble();
654 } 654 }
655 655
656 void Print(Browser* browser) { 656 void Print(Browser* browser) {
657 if (g_browser_process->local_state()->GetBoolean( 657 if (browser->profile()->GetPrefs()->GetBoolean(
658 prefs::kPrintPreviewDisabled)) { 658 prefs::kPrintPreviewDisabled)) {
659 GetActiveTabContents(browser)->print_view_manager()->PrintNow(); 659 GetActiveTabContents(browser)->print_view_manager()->PrintNow();
660 } else { 660 } else {
661 GetActiveTabContents(browser)->print_view_manager()-> 661 GetActiveTabContents(browser)->print_view_manager()->
662 PrintPreviewNow(); 662 PrintPreviewNow();
663 } 663 }
664 } 664 }
665 665
666 bool CanPrint(const Browser* browser) { 666 bool CanPrint(const Browser* browser) {
667 // LocalState can be NULL in tests. 667 // Do not print when printing is disabled via pref or policy.
668 if (g_browser_process->local_state() &&
669 !g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled)) {
670 return false;
671 }
672
673 // Do not print when a constrained window is showing. It's confusing. 668 // Do not print when a constrained window is showing. It's confusing.
674 // Do not print if instant extended API is enabled and mode is NTP. 669 // Do not print if instant extended API is enabled and mode is NTP.
675 return !(HasConstrainedWindow(browser) || 670 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
671 !(HasConstrainedWindow(browser) ||
676 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT || 672 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT ||
677 IsNTPModeForInstantExtendedAPI(browser)); 673 IsNTPModeForInstantExtendedAPI(browser));
678 } 674 }
679 675
680 void AdvancedPrint(Browser* browser) { 676 void AdvancedPrint(Browser* browser) {
681 GetActiveTabContents(browser)->print_view_manager()-> 677 GetActiveTabContents(browser)->print_view_manager()->
682 AdvancedPrintNow(); 678 AdvancedPrintNow();
683 } 679 }
684 680
685 bool CanAdvancedPrint(const Browser* browser) { 681 bool CanAdvancedPrint(const Browser* browser) {
686 // LocalState can be NULL in tests. 682 // If printing is not disabled via pref or policy, it is always possible to
687 if (g_browser_process->local_state() && 683 // advanced print when the print preview is visible.
688 !g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled)) { 684 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
689 return false; 685 (PrintPreviewShowing(browser) || CanPrint(browser));
690 }
691
692 // It is always possible to advanced print when print preview is visible.
693 return PrintPreviewShowing(browser) || CanPrint(browser);
694 } 686 }
695 687
696 void PrintToDestination(Browser* browser) { 688 void PrintToDestination(Browser* browser) {
697 GetActiveTabContents(browser)->print_view_manager()->PrintToDestination(); 689 GetActiveTabContents(browser)->print_view_manager()->PrintToDestination();
698 } 690 }
699 691
700 void EmailPageLocation(Browser* browser) { 692 void EmailPageLocation(Browser* browser) {
701 content::RecordAction(UserMetricsAction("EmailPageLocation")); 693 content::RecordAction(UserMetricsAction("EmailPageLocation"));
702 WebContents* wc = GetActiveWebContents(browser); 694 WebContents* wc = GetActiveWebContents(browser);
703 DCHECK(wc); 695 DCHECK(wc);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 if (!tab_contents) 976 if (!tab_contents)
985 tab_contents = new TabContents(contents); 977 tab_contents = new TabContents(contents);
986 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 978 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
987 979
988 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 980 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
989 contents->GetRenderViewHost()->SyncRendererPrefs(); 981 contents->GetRenderViewHost()->SyncRendererPrefs();
990 app_browser->window()->Show(); 982 app_browser->window()->Show();
991 } 983 }
992 984
993 } // namespace chrome 985 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/browser_ui_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698