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

Unified Diff: chrome/browser/policy/configuration_policy_handler.cc

Issue 10035043: Update RestoreOnStartupPolicyHandler to translate to the correct preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a few nits Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/configuration_policy_handler.cc
diff --git a/chrome/browser/policy/configuration_policy_handler.cc b/chrome/browser/policy/configuration_policy_handler.cc
index 418a3ee678a6495538903cce38d0d5191ea2a62e..295eaae643fef6ecda4bef2e96a3f9f53e85dde4 100644
--- a/chrome/browser/policy/configuration_policy_handler.cc
+++ b/chrome/browser/policy/configuration_policy_handler.cc
@@ -966,6 +966,59 @@ RestoreOnStartupPolicyHandler::RestoreOnStartupPolicyHandler()
RestoreOnStartupPolicyHandler::~RestoreOnStartupPolicyHandler() {
}
+void RestoreOnStartupPolicyHandler::ApplyPolicySettings(
+ const PolicyMap& policies,
+ PrefValueMap* prefs) {
+ const Value* restore_on_startup_value = policies.GetValue(policy_name());
+ int restore_on_startup = -1;
+ if (restore_on_startup_value)
+ restore_on_startup_value->GetAsInteger(&restore_on_startup);
+
+ if (restore_on_startup == SessionStartupPref::kPrefValueHomePage) {
+ ApplyPolicySettingsFromHomePage(policies, prefs);
+ } else {
+ SimplePolicyHandler::ApplyPolicySettings(policies, prefs);
Mattias Nissler (ping if slow) 2012/04/19 13:15:55 This would be just prefs->SetValue() if you don't
Tyler Breisacher (Chromium) 2012/04/19 19:07:56 Done.
+ }
+}
+
+void RestoreOnStartupPolicyHandler::ApplyPolicySettingsFromHomePage(
+ const PolicyMap& policies,
+ PrefValueMap* prefs) {
+
+ const base::Value* homepage_is_new_tab_page_value =
+ policies.GetValue(key::kHomepageIsNewTabPage);
+ if (!homepage_is_new_tab_page_value) {
+ // The policy is enforcing 'open the homepage on startup' but not
+ // enforcing what the homepage should be. Don't set any prefs.
Mattias Nissler (ping if slow) 2012/04/19 13:15:55 So the policy doesn't have the homepage_is_new_tab
Tyler Breisacher (Chromium) 2012/04/19 19:07:56 In Chrome 18, if a policy has RestoreOnStartup=0 a
Mattias Nissler (ping if slow) 2012/04/20 09:20:24 You're right.
+ return;
+ }
+
+ bool homepage_is_new_tab_page;
+ bool result = homepage_is_new_tab_page_value->GetAsBoolean(
+ &homepage_is_new_tab_page);
+ DCHECK(result);
Mattias Nissler (ping if slow) 2012/04/19 13:15:55 This DCHECK is inappropriate. The Value you get he
Tyler Breisacher (Chromium) 2012/04/19 19:07:56 Done. (Also did the same thing above for homepage_
+
+ if (homepage_is_new_tab_page) {
+ prefs->SetInteger(
+ prefs::kRestoreOnStartup,
+ SessionStartupPref::kPrefValueNewTab);
+ } else {
+ const base::Value* homepage_value =
+ policies.GetValue(key::kHomepageLocation);
+ if (!homepage_value) {
+ // The policy is enforcing 'open the homepage on startup' but not
+ // enforcing what the homepage should be. Don't set any prefs.
+ return;
+ }
+ ListValue* url_list = new ListValue();
+ url_list->Append(homepage_value->DeepCopy());
+ prefs->SetInteger(
+ prefs::kRestoreOnStartup,
+ SessionStartupPref::kPrefValueURLs);
+ prefs->SetValue(prefs::kURLsToRestoreOnStartup, url_list);
+ }
+}
+
bool RestoreOnStartupPolicyHandler::CheckPolicySettings(
const PolicyMap& policies,
PolicyErrorMap* errors) {
@@ -980,8 +1033,7 @@ bool RestoreOnStartupPolicyHandler::CheckPolicySettings(
if (restore_policy) {
int restore_value;
if (restore_policy->GetAsInteger(&restore_value) &&
- SessionStartupPref::PrefValueToType(restore_value) ==
- SessionStartupPref::LAST) {
+ restore_value == SessionStartupPref::kPrefValueLast) {
const base::Value* cookies_policy =
policies.GetValue(key::kCookiesSessionOnlyForUrls);

Powered by Google App Engine
This is Rietveld 408576698