diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.mm | 31 | ||||
-rw-r--r-- | chrome/browser/configuration_policy_pref_store.cc | 10 | ||||
-rw-r--r-- | chrome/browser/configuration_policy_pref_store.h | 13 | ||||
-rw-r--r-- | chrome/browser/configuration_policy_pref_store_unittest.cc | 141 | ||||
-rw-r--r-- | chrome/browser/configuration_policy_provider.cc | 16 | ||||
-rwxr-xr-x | chrome/browser/configuration_policy_provider_win_unittest.cc | 92 | ||||
-rw-r--r-- | chrome/browser/configuration_policy_store.h | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/options/advanced_contents_gtk.cc | 15 | ||||
-rw-r--r-- | chrome/browser/views/options/advanced_contents_view.cc | 11 |
9 files changed, 266 insertions, 68 deletions
diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 4eb6090..254dd2c 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -1451,6 +1451,11 @@ const int kDisabledIndex = 1; alternateErrorPages_.SetValue(value ? true : false); } +// Returns whether the alternate error page checkbox should be enabled. +- (BOOL)isAlternateErrorPagesEnabled { + return !alternateErrorPages_.IsManaged(); +} + // Returns whether the suggest checkbox should be checked based on the // preference. - (BOOL)useSuggest { @@ -1469,6 +1474,11 @@ const int kDisabledIndex = 1; useSuggest_.SetValue(value ? true : false); } +// Returns whether the suggest checkbox should be enabled. +- (BOOL)isSuggestEnabled { + return !useSuggest_.IsManaged(); +} + // Returns whether the DNS prefetch checkbox should be checked based on the // preference. - (BOOL)dnsPrefetch { @@ -1488,6 +1498,11 @@ const int kDisabledIndex = 1; chrome_browser_net::EnableDnsPrefetch(value ? true : false); } +// Returns whether the DNS prefetch checkbox should be enabled. +- (BOOL)isDnsPrefetchEnabled { + return !dnsPrefetch_.IsManaged(); +} + // Returns whether the safe browsing checkbox should be checked based on the // preference. - (BOOL)safeBrowsing { @@ -1511,14 +1526,19 @@ const int kDisabledIndex = 1; safeBrowsingService, &SafeBrowsingService::OnEnable, enabled)); } -// Returns whether the suggest checkbox should be checked based on the +// Returns whether the safe browsing checkbox should be enabled. +- (BOOL)isSafeBrowsingEnabled { + return !safeBrowsing_.IsManaged(); +} + +// Returns whether the metrics recording checkbox should be checked based on the // preference. - (BOOL)metricsRecording { return metricsRecording_.GetValue() ? YES : NO; } -// Sets the backend pref for whether or not the suggest checkbox should be -// displayed based on |value|. +// Sets the backend pref for whether or not the metrics recording checkbox +// should be displayed based on |value|. - (void)setMetricsRecording:(BOOL)value { if (value) [self recordUserAction:UserMetricsAction( @@ -1554,6 +1574,11 @@ const int kDisabledIndex = 1; metricsRecording_.SetValue(enabled); } +// Returns whether the metrics recording checkbox should be enabled. +- (BOOL)isMetricsRecordingEnabled { + return !metricsRecording_.IsManaged(); +} + - (NSURL*)defaultDownloadLocation { NSString* pathString = base::SysWideToNSString(defaultDownloadLocation_.GetValue()); diff --git a/chrome/browser/configuration_policy_pref_store.cc b/chrome/browser/configuration_policy_pref_store.cc index 9a3a6e5..c591e20 100644 --- a/chrome/browser/configuration_policy_pref_store.cc +++ b/chrome/browser/configuration_policy_pref_store.cc @@ -14,6 +14,16 @@ ConfigurationPolicyPrefStore::simple_policy_map_[] = { { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage }, { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage, prefs::kHomePageIsNewTabPage }, + { Value::TYPE_BOOLEAN, kPolicyAlternateErrorPagesEnabled, + prefs::kAlternateErrorPagesEnabled }, + { Value::TYPE_BOOLEAN, kPolicySearchSuggestEnabled, + prefs::kSearchSuggestEnabled }, + { Value::TYPE_BOOLEAN, kPolicyDnsPrefetchingEnabled, + prefs::kDnsPrefetchingEnabled }, + { Value::TYPE_BOOLEAN, kPolicySafeBrowsingEnabled, + prefs::kSafeBrowsingEnabled }, + { Value::TYPE_BOOLEAN, kPolicyMetricsReportingEnabled, + prefs::kMetricsReportingEnabled }, { Value::TYPE_INTEGER, kPolicyCookiesMode, prefs::kCookieBehavior } }; diff --git a/chrome/browser/configuration_policy_pref_store.h b/chrome/browser/configuration_policy_pref_store.h index ae7d8fa..48692a3 100644 --- a/chrome/browser/configuration_policy_pref_store.h +++ b/chrome/browser/configuration_policy_pref_store.h @@ -30,18 +30,7 @@ class ConfigurationPolicyPrefStore : public PrefStore, private: // For unit tests. - FRIEND_TEST_ALL_PREFIXES(ConfigurationPolicyPrefStoreTest, - TestSettingHomePageDefault); - FRIEND_TEST_ALL_PREFIXES(ConfigurationPolicyPrefStoreTest, - TestSettingHomePageOverride); - FRIEND_TEST_ALL_PREFIXES(ConfigurationPolicyPrefStoreTest, - TestSettingHomepageIsNewTabPageDefault); - FRIEND_TEST_ALL_PREFIXES(ConfigurationPolicyPrefStoreTest, - TestSettingHomepageIsNewTabPage); - FRIEND_TEST_ALL_PREFIXES(ConfigurationPolicyPrefStoreTest, - TestSettingCookiesEnabledDefault); - FRIEND_TEST_ALL_PREFIXES(ConfigurationPolicyPrefStoreTest, - TestSettingCookiesEnabledOverride); + friend class ConfigurationPolicyPrefStoreTest; // Policies that map to a single preference are handled // by an automated converter. Each one of these policies diff --git a/chrome/browser/configuration_policy_pref_store_unittest.cc b/chrome/browser/configuration_policy_pref_store_unittest.cc index 2074857..98fe48a 100644 --- a/chrome/browser/configuration_policy_pref_store_unittest.cc +++ b/chrome/browser/configuration_policy_pref_store_unittest.cc @@ -7,59 +7,156 @@ #include "chrome/browser/configuration_policy_pref_store.h" #include "chrome/common/pref_names.h" -TEST(ConfigurationPolicyPrefStoreTest, TestSettingHomePageDefault) { +class ConfigurationPolicyPrefStoreTest : public testing::Test { + public: + // The following three methods test a policy which controls a string + // preference. + // Checks that by default, it's an empty string. + void TestStringPolicyGetDefault(const wchar_t* pref_name); + // Checks that values can be set. + void TestStringPolicySetValue(const wchar_t* pref_name, + ConfigurationPolicyStore::PolicyType type); + // A wrapper that calls the above two methods. + void TestStringPolicy(const wchar_t* pref_name, + ConfigurationPolicyStore::PolicyType type); + + // The following three methods test a policy which controls a boolean + // preference. + // Checks that there's no deafult. + void TestBooleanPolicyGetDefault(const wchar_t* pref_name); + // Checks that values can be set. + void TestBooleanPolicySetValue(const wchar_t* pref_name, + ConfigurationPolicyStore::PolicyType type); + // A wrapper that calls the above two methods. + void TestBooleanPolicy(const wchar_t* pref_name, + ConfigurationPolicyStore::PolicyType type); + + // The following three methods test a policy which controls an integer + // preference. + // Checks that by default, it's 0. + void TestIntegerPolicyGetDefault(const wchar_t* pref_name); + // Checks that values can be set. + void TestIntegerPolicySetValue(const wchar_t* pref_name, + ConfigurationPolicyStore::PolicyType type); + // A wrapper that calls the above two methods. + void TestIntegerPolicy(const wchar_t* pref_name, + ConfigurationPolicyStore::PolicyType type); +}; + +void ConfigurationPolicyPrefStoreTest::TestStringPolicyGetDefault( + const wchar_t* pref_name) { ConfigurationPolicyPrefStore store(0); std::wstring result; - store.prefs()->GetString(prefs::kHomePage, &result); + store.prefs()->GetString(pref_name, &result); EXPECT_EQ(result, L""); } -TEST(ConfigurationPolicyPrefStoreTest, TestSettingHomePageOverride) { +void ConfigurationPolicyPrefStoreTest::TestStringPolicySetValue( + const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { ConfigurationPolicyPrefStore store(0); - store.Apply(ConfigurationPolicyPrefStore::kPolicyHomePage, - Value::CreateStringValue("http://chromium.org")); + store.Apply(type, Value::CreateStringValue("http://chromium.org")); std::wstring result; - store.prefs()->GetString(prefs::kHomePage, &result); + store.prefs()->GetString(pref_name, &result); EXPECT_EQ(result, L"http://chromium.org"); } -TEST(ConfigurationPolicyPrefStoreTest, TestSettingHomepageIsNewTabPageDefault) { +void ConfigurationPolicyPrefStoreTest::TestStringPolicy( + const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + TestStringPolicyGetDefault(pref_name); + TestStringPolicySetValue(pref_name, type); +} + +void ConfigurationPolicyPrefStoreTest::TestBooleanPolicyGetDefault( + const wchar_t* pref_name) { ConfigurationPolicyPrefStore store(0); bool result = false; - store.prefs()->GetBoolean(prefs::kHomePageIsNewTabPage, &result); + store.prefs()->GetBoolean(pref_name, &result); EXPECT_FALSE(result); result = true; - store.prefs()->GetBoolean(prefs::kHomePageIsNewTabPage, &result); + store.prefs()->GetBoolean(pref_name, &result); EXPECT_TRUE(result); } -TEST(ConfigurationPolicyPrefStoreTest, TestSettingHomepageIsNewTabPage) { +void ConfigurationPolicyPrefStoreTest::TestBooleanPolicySetValue( + const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { ConfigurationPolicyPrefStore store(0); - store.Apply(ConfigurationPolicyPrefStore::kPolicyHomepageIsNewTabPage, - Value::CreateBooleanValue(false)); + store.Apply(type, Value::CreateBooleanValue(false)); bool result = true; - store.prefs()->GetBoolean(prefs::kHomePageIsNewTabPage, &result); + store.prefs()->GetBoolean(pref_name, &result); EXPECT_FALSE(result); - store.Apply(ConfigurationPolicyPrefStore::kPolicyHomepageIsNewTabPage, - Value::CreateBooleanValue(true)); - store.prefs()->GetBoolean(prefs::kHomePageIsNewTabPage, &result); + store.Apply(type, Value::CreateBooleanValue(true)); + result = false; + store.prefs()->GetBoolean(pref_name, &result); EXPECT_TRUE(result); } -TEST(ConfigurationPolicyPrefStoreTest, TestSettingCookiesEnabledDefault) { +void ConfigurationPolicyPrefStoreTest::TestBooleanPolicy( + const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + TestBooleanPolicyGetDefault(pref_name); + TestBooleanPolicySetValue(pref_name, type); +} + +void ConfigurationPolicyPrefStoreTest::TestIntegerPolicyGetDefault( + const wchar_t* pref_name) { ConfigurationPolicyPrefStore store(0); int result = 0; - store.prefs()->GetInteger(prefs::kCookieBehavior, &result); + store.prefs()->GetInteger(pref_name, &result); EXPECT_EQ(result, 0); } -TEST(ConfigurationPolicyPrefStoreTest, TestSettingCookiesEnabledOverride) { +void ConfigurationPolicyPrefStoreTest::TestIntegerPolicySetValue( + const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { ConfigurationPolicyPrefStore store(0); - store.Apply(ConfigurationPolicyPrefStore::kPolicyCookiesMode, - Value::CreateIntegerValue(2)); + store.Apply(type, Value::CreateIntegerValue(2)); int result = 0; - store.prefs()->GetInteger(prefs::kCookieBehavior, &result); + store.prefs()->GetInteger(pref_name, &result); EXPECT_EQ(result, 2); } +void ConfigurationPolicyPrefStoreTest::TestIntegerPolicy( + const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + TestIntegerPolicyGetDefault(pref_name); + TestIntegerPolicySetValue(pref_name, type); +} + +TEST_F(ConfigurationPolicyPrefStoreTest, TestSettingHomePageDefault) { + TestStringPolicy(prefs::kHomePage, + ConfigurationPolicyPrefStore::kPolicyHomePage); +} + +TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyHomepageIsNewTabPage) { + TestBooleanPolicy(prefs::kHomePageIsNewTabPage, + ConfigurationPolicyPrefStore::kPolicyHomepageIsNewTabPage); +} + +TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyAlternateErrorPagesEnabled) { + TestBooleanPolicy(prefs::kAlternateErrorPagesEnabled, + ConfigurationPolicyStore::kPolicyAlternateErrorPagesEnabled); +} + +TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicySearchSuggestEnabled) { + TestBooleanPolicy(prefs::kSearchSuggestEnabled, + ConfigurationPolicyStore::kPolicySearchSuggestEnabled); +} + +TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyDnsPrefetchingEnabled) { + TestBooleanPolicy(prefs::kDnsPrefetchingEnabled, + ConfigurationPolicyStore::kPolicyDnsPrefetchingEnabled); +} + +TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicySafeBrowsingEnabled) { + TestBooleanPolicy(prefs::kSafeBrowsingEnabled, + ConfigurationPolicyStore::kPolicySafeBrowsingEnabled); +} + +TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyMetricsReportingEnabled) { + TestBooleanPolicy(prefs::kMetricsReportingEnabled, + ConfigurationPolicyStore::kPolicyMetricsReportingEnabled); +} + +TEST_F(ConfigurationPolicyPrefStoreTest, TestSettingCookiesEnabledDefault) { + TestIntegerPolicy(prefs::kCookieBehavior, + ConfigurationPolicyPrefStore::kPolicyCookiesMode); +} + diff --git a/chrome/browser/configuration_policy_provider.cc b/chrome/browser/configuration_policy_provider.cc index ec49ec7..3cb9721 100644 --- a/chrome/browser/configuration_policy_provider.cc +++ b/chrome/browser/configuration_policy_provider.cc @@ -19,11 +19,21 @@ struct InternalPolicyValueMapEntry { const InternalPolicyValueMapEntry kPolicyValueMap[] = { { ConfigurationPolicyStore::kPolicyHomePage, - Value::TYPE_STRING, "Homepage" }, + Value::TYPE_STRING, "Homepage" }, { ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage, - Value::TYPE_BOOLEAN, "HomepageIsNewTabPage" }, + Value::TYPE_BOOLEAN, "HomepageIsNewTabPage" }, + { ConfigurationPolicyStore::kPolicyAlternateErrorPagesEnabled, + Value::TYPE_BOOLEAN, "AlternateErrorPagesEnabled" }, + { ConfigurationPolicyStore::kPolicySearchSuggestEnabled, + Value::TYPE_BOOLEAN, "SearchSuggestEnabled" }, + { ConfigurationPolicyStore::kPolicyDnsPrefetchingEnabled, + Value::TYPE_BOOLEAN, "DnsPrefetchingEnabled" }, + { ConfigurationPolicyStore::kPolicySafeBrowsingEnabled, + Value::TYPE_BOOLEAN, "SafeBrowsingEnabled" }, + { ConfigurationPolicyStore::kPolicyMetricsReportingEnabled, + Value::TYPE_BOOLEAN, "MetricsReportingEnabled" }, { ConfigurationPolicyStore::kPolicyCookiesMode, - Value::TYPE_INTEGER, "CookiesMode" } + Value::TYPE_INTEGER, "CookiesMode" } }; } // namespace diff --git a/chrome/browser/configuration_policy_provider_win_unittest.cc b/chrome/browser/configuration_policy_provider_win_unittest.cc index b4fc671..1451ede 100755 --- a/chrome/browser/configuration_policy_provider_win_unittest.cc +++ b/chrome/browser/configuration_policy_provider_win_unittest.cc @@ -35,7 +35,8 @@ class TestConfigurationPolicyProviderWin void SetHomepageRegistryValue(HKEY hive, const wchar_t* value); void SetHomepageRegistryValueWrongType(HKEY hive); - void SetHomepageIsNewTabPage(HKEY hive, bool value); + void SetBooleanPolicy(ConfigurationPolicyStore::PolicyType type, + HKEY hive, bool value); void SetCookiesMode(HKEY hive, uint32 value); typedef std::vector<PolicyValueMapEntry> PolicyValueMap; @@ -80,15 +81,13 @@ void TestConfigurationPolicyProviderWin::SetHomepageRegistryValueWrongType( 5)); } -void TestConfigurationPolicyProviderWin::SetHomepageIsNewTabPage( +void TestConfigurationPolicyProviderWin::SetBooleanPolicy( + ConfigurationPolicyStore::PolicyType type, HKEY hive, bool value) { - RegKey key(hive, - ConfigurationPolicyProviderWin::kPolicyRegistrySubKey, + RegKey key(hive, ConfigurationPolicyProviderWin::kPolicyRegistrySubKey, KEY_ALL_ACCESS); - EXPECT_TRUE(key.WriteValue(NameForPolicy( - ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage).c_str(), - value)); + EXPECT_TRUE(key.WriteValue(NameForPolicy(type).c_str(), value)); } void TestConfigurationPolicyProviderWin::SetCookiesMode( @@ -123,6 +122,10 @@ class ConfigurationPolicyProviderWinTest : public testing::Test { // Deletes the registry key created during the tests. void DeleteRegistrySandbox(); + void TestBooleanPolicyDefault(ConfigurationPolicyStore::PolicyType type); + void TestBooleanPolicyHKLM(ConfigurationPolicyStore::PolicyType type); + void TestBooleanPolicy(ConfigurationPolicyStore::PolicyType type); + private: // Keys are created for the lifetime of a test to contain // the sandboxed HKCU and HKLM hives, respectively. @@ -178,6 +181,40 @@ void ConfigurationPolicyProviderWinTest::DeleteRegistrySandbox() { RegKey key(HKEY_CURRENT_USER, kUnitTestRegistrySubKey, KEY_ALL_ACCESS); key.DeleteKey(L""); } + +void ConfigurationPolicyProviderWinTest::TestBooleanPolicyDefault( + ConfigurationPolicyStore::PolicyType type) { + MockConfigurationPolicyStore store; + TestConfigurationPolicyProviderWin provider; + provider.Provide(&store); + + const MockConfigurationPolicyStore::PolicyMap& map(store.policy_map()); + MockConfigurationPolicyStore::PolicyMap::const_iterator i = + map.find(type); + EXPECT_TRUE(i == map.end()); +} + +void ConfigurationPolicyProviderWinTest::TestBooleanPolicyHKLM( + ConfigurationPolicyStore::PolicyType type) { + MockConfigurationPolicyStore store; + TestConfigurationPolicyProviderWin provider; + provider.SetBooleanPolicy(type, HKEY_LOCAL_MACHINE, true); + provider.Provide(&store); + + const MockConfigurationPolicyStore::PolicyMap& map(store.policy_map()); + MockConfigurationPolicyStore::PolicyMap::const_iterator i = map.find(type); + EXPECT_TRUE(i != map.end()); + bool value = false; + i->second->GetAsBoolean(&value); + EXPECT_EQ(true, value); +} + +void ConfigurationPolicyProviderWinTest::TestBooleanPolicy( + ConfigurationPolicyStore::PolicyType type) { + TestBooleanPolicyDefault(type); + TestBooleanPolicyHKLM(type); +} + TEST_F(ConfigurationPolicyProviderWinTest, TestHomePagePolicyDefault) { MockConfigurationPolicyStore store; TestConfigurationPolicyProviderWin provider; @@ -257,33 +294,34 @@ TEST_F(ConfigurationPolicyProviderWinTest, TestHomePagePolicyHKLMOverHKCU) { } TEST_F(ConfigurationPolicyProviderWinTest, - TestHomepageIsNewTabPagePolicyDefault) { - MockConfigurationPolicyStore store; - TestConfigurationPolicyProviderWin provider; + TestHomepageIsNewTabPagePolicy) { + TestBooleanPolicy(ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage); +} - provider.Provide(&store); +TEST_F(ConfigurationPolicyProviderWinTest, + TestPolicyAlternateErrorPagesEnabled) { + TestBooleanPolicy( + ConfigurationPolicyStore::kPolicyAlternateErrorPagesEnabled); +} - const MockConfigurationPolicyStore::PolicyMap& map(store.policy_map()); - MockConfigurationPolicyStore::PolicyMap::const_iterator i = - map.find(ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage); - EXPECT_TRUE(i == map.end()); +TEST_F(ConfigurationPolicyProviderWinTest, + TestPolicySearchSuggestEnabled) { + TestBooleanPolicy(ConfigurationPolicyStore::kPolicySearchSuggestEnabled); } TEST_F(ConfigurationPolicyProviderWinTest, - TestHomepageIsNewTabPagePolicyHKLM) { - MockConfigurationPolicyStore store; - TestConfigurationPolicyProviderWin provider; - provider.SetHomepageIsNewTabPage(HKEY_LOCAL_MACHINE, true); + TestPolicyDnsPrefetchingEnabled) { + TestBooleanPolicy(ConfigurationPolicyStore::kPolicyDnsPrefetchingEnabled); +} - provider.Provide(&store); +TEST_F(ConfigurationPolicyProviderWinTest, + TestPolicySafeBrowsingEnabled) { + TestBooleanPolicy(ConfigurationPolicyStore::kPolicySafeBrowsingEnabled); +} - const MockConfigurationPolicyStore::PolicyMap& map(store.policy_map()); - MockConfigurationPolicyStore::PolicyMap::const_iterator i = - map.find(ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage); - EXPECT_TRUE(i != map.end()); - bool value = false; - i->second->GetAsBoolean(&value); - EXPECT_EQ(true, value); +TEST_F(ConfigurationPolicyProviderWinTest, + TestPolicyMetricsReportingEnabled) { + TestBooleanPolicy(ConfigurationPolicyStore::kPolicyMetricsReportingEnabled); } TEST_F(ConfigurationPolicyProviderWinTest, diff --git a/chrome/browser/configuration_policy_store.h b/chrome/browser/configuration_policy_store.h index 638fb2c..6b6461e 100644 --- a/chrome/browser/configuration_policy_store.h +++ b/chrome/browser/configuration_policy_store.h @@ -17,6 +17,11 @@ class ConfigurationPolicyStore { enum PolicyType { kPolicyHomePage, kPolicyHomepageIsNewTabPage, + kPolicyAlternateErrorPagesEnabled, + kPolicySearchSuggestEnabled, + kPolicyDnsPrefetchingEnabled, + kPolicySafeBrowsingEnabled, + kPolicyMetricsReportingEnabled, kPolicyCookiesMode }; diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index 5ed339d..2c6d639 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -740,6 +740,19 @@ PrivacySection::PrivacySection(Profile* profile) enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, g_browser_process->local_state(), this); + gtk_widget_set_sensitive(enable_link_doctor_checkbox_, + !alternate_error_pages_.IsManaged()); + gtk_widget_set_sensitive(enable_suggest_checkbox_, + !use_suggest_.IsManaged()); + gtk_widget_set_sensitive(enable_dns_prefetching_checkbox_, + !dns_prefetch_enabled_.IsManaged()); + gtk_widget_set_sensitive(enable_safe_browsing_checkbox_, + !safe_browsing_.IsManaged()); +#if defined(GOOGLE_CHROME_BUILD) + gtk_widget_set_sensitive(reporting_enabled_checkbox_, + !enable_metrics_recording_.IsManaged()); +#endif + NotifyPrefChanged(NULL); } @@ -879,7 +892,7 @@ void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) { #if defined(GOOGLE_CHROME_BUILD) if (!pref_name || *pref_name == prefs::kMetricsReportingEnabled) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(reporting_enabled_checkbox_), - enable_metrics_recording_.GetValue()); + enable_metrics_recording_.GetValue()); ResolveMetricsReportingEnabled(); } #endif diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index 6745011..b8b88cb 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -650,6 +650,17 @@ void PrivacySection::InitControlLayout() { safe_browsing_.Init(prefs::kSafeBrowsingEnabled, profile()->GetPrefs(), this); enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, g_browser_process->local_state(), this); + + + enable_link_doctor_checkbox_->SetEnabled(!alternate_error_pages_.IsManaged()); + enable_suggest_checkbox_->SetEnabled(!use_suggest_.IsManaged()); + enable_dns_prefetching_checkbox_->SetEnabled( + !dns_prefetch_enabled_.IsManaged()); + enable_safe_browsing_checkbox_->SetEnabled(!safe_browsing_.IsManaged()); +#if defined(GOOGLE_CHROME_BUILD) + reporting_enabled_checkbox_->SetEnabled( + !enable_metrics_recording_.IsManaged()); +#endif } void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) { |