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

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: 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
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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 646 }
647 647
648 void ShowChromeToMobileBubble(Browser* browser) { 648 void ShowChromeToMobileBubble(Browser* browser) {
649 // Only show the bubble if the window is active, otherwise we may get into 649 // Only show the bubble if the window is active, otherwise we may get into
650 // weird situations where the bubble is deleted as soon as it is shown. 650 // weird situations where the bubble is deleted as soon as it is shown.
651 if (browser->window()->IsActive()) 651 if (browser->window()->IsActive())
652 browser->window()->ShowChromeToMobileBubble(); 652 browser->window()->ShowChromeToMobileBubble();
653 } 653 }
654 654
655 void Print(Browser* browser) { 655 void Print(Browser* browser) {
656 if (g_browser_process->local_state()->GetBoolean( 656 if (browser->profile()->GetPrefs()->GetBoolean(
657 prefs::kPrintPreviewDisabled)) { 657 prefs::kPrintPreviewDisabled)) {
658 GetActiveTabContents(browser)->print_view_manager()->PrintNow(); 658 GetActiveTabContents(browser)->print_view_manager()->PrintNow();
659 } else { 659 } else {
660 GetActiveTabContents(browser)->print_view_manager()-> 660 GetActiveTabContents(browser)->print_view_manager()->
661 PrintPreviewNow(); 661 PrintPreviewNow();
662 } 662 }
663 } 663 }
664 664
665 bool CanPrint(const Browser* browser) { 665 bool CanPrint(const Browser* browser) {
666 // LocalState can be NULL in tests. 666 // Do not print when printing is disabled via pref or policy.
667 if (g_browser_process->local_state() &&
668 !g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled)) {
669 return false;
670 }
671
672 // Do not print when a constrained window is showing. It's confusing. 667 // Do not print when a constrained window is showing. It's confusing.
673 // Do not print if instant extended API is enabled and mode is NTP. 668 // Do not print if instant extended API is enabled and mode is NTP.
674 return !(HasConstrainedWindow(browser) || 669 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
670 !(HasConstrainedWindow(browser) ||
675 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT || 671 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT ||
676 IsNTPModeForInstantExtendedAPI(browser)); 672 IsNTPModeForInstantExtendedAPI(browser));
677 } 673 }
678 674
679 void AdvancedPrint(Browser* browser) { 675 void AdvancedPrint(Browser* browser) {
680 GetActiveTabContents(browser)->print_view_manager()-> 676 GetActiveTabContents(browser)->print_view_manager()->
681 AdvancedPrintNow(); 677 AdvancedPrintNow();
682 } 678 }
683 679
684 bool CanAdvancedPrint(const Browser* browser) { 680 bool CanAdvancedPrint(const Browser* browser) {
685 // LocalState can be NULL in tests. 681 // If printing is not disabled via pref or policy, it is always possible to
686 if (g_browser_process->local_state() && 682 // advanced print when the print preview is visible.
687 !g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled)) { 683 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
688 return false; 684 (PrintPreviewShowing(browser) || CanPrint(browser));
689 }
690
691 // It is always possible to advanced print when print preview is visible.
692 return PrintPreviewShowing(browser) || CanPrint(browser);
693 } 685 }
694 686
695 void PrintToDestination(Browser* browser) { 687 void PrintToDestination(Browser* browser) {
696 GetActiveTabContents(browser)->print_view_manager()->PrintToDestination(); 688 GetActiveTabContents(browser)->print_view_manager()->PrintToDestination();
697 } 689 }
698 690
699 void EmailPageLocation(Browser* browser) { 691 void EmailPageLocation(Browser* browser) {
700 content::RecordAction(UserMetricsAction("EmailPageLocation")); 692 content::RecordAction(UserMetricsAction("EmailPageLocation"));
701 WebContents* wc = GetActiveWebContents(browser); 693 WebContents* wc = GetActiveWebContents(browser);
702 DCHECK(wc); 694 DCHECK(wc);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 if (!tab_contents) 975 if (!tab_contents)
984 tab_contents = new TabContents(contents); 976 tab_contents = new TabContents(contents);
985 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 977 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
986 978
987 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 979 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
988 contents->GetRenderViewHost()->SyncRendererPrefs(); 980 contents->GetRenderViewHost()->SyncRendererPrefs();
989 app_browser->window()->Show(); 981 app_browser->window()->Show();
990 } 982 }
991 983
992 } // namespace chrome 984 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698