summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser.cc
diff options
context:
space:
mode:
authorgfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 20:12:09 +0000
committergfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 20:12:09 +0000
commit2a7e7c15ee743901d9384a08fe6b751b6644f16a (patch)
treea863d5e65767047f3e38ab3d5cdb937e6bac13a9 /chrome/browser/browser.cc
parent3491148530fd60dbd8e92cf4ee2954f948cc72d7 (diff)
downloadchromium_src-2a7e7c15ee743901d9384a08fe6b751b6644f16a.zip
chromium_src-2a7e7c15ee743901d9384a08fe6b751b6644f16a.tar.gz
chromium_src-2a7e7c15ee743901d9384a08fe6b751b6644f16a.tar.bz2
Policy to disable printing
Make Chrome refuse to print if the preference kPrintingEnabled is set to false. In this case, the 'Print...' option in the wrench menu is disabled, and if printing is invoked from JavaScript, then Chrome reports that no printer is installed. Changes to this preference after startup are also respected. BUG=54380 TEST=manual Review URL: http://codereview.chromium.org/3357011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r--chrome/browser/browser.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index a504887..4e5128a 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -244,6 +244,15 @@ Browser::Browser(Type type, Profile* profile)
!profile->IsOffTheRecord()) {
match_preview_.reset(new MatchPreview(this));
}
+
+ PrefService *local_state = g_browser_process->local_state();
+ if (local_state) {
+ printing_enabled_.Init(prefs::kPrintingEnabled, local_state, this);
+ command_updater_.UpdateCommandEnabled(IDC_PRINT,
+ printing_enabled_.GetValue());
+ } else {
+ command_updater_.UpdateCommandEnabled(IDC_PRINT, true);
+ }
}
Browser::~Browser() {
@@ -3202,10 +3211,15 @@ void Browser::Observe(NotificationType type,
}
case NotificationType::PREF_CHANGED: {
- if (*(Details<std::string>(details).ptr()) == prefs::kUseVerticalTabs)
+ const std::string& pref_name = *Details<std::string>(details).ptr();
+ if (pref_name == prefs::kUseVerticalTabs) {
UseVerticalTabsChanged();
- else
+ } else if (pref_name == prefs::kPrintingEnabled) {
+ command_updater_.UpdateCommandEnabled(IDC_PRINT,
+ printing_enabled_.GetValue());
+ } else {
NOTREACHED();
+ }
break;
}
@@ -3289,7 +3303,6 @@ void Browser::InitCommandState() {
// Page-related commands
command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true);
- command_updater_.UpdateCommandEnabled(IDC_PRINT, true);
command_updater_.UpdateCommandEnabled(IDC_ENCODING_AUTO_DETECT, true);
command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF8, true);
command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF16LE, true);