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

Side by Side Diff: chrome/browser/policy/configuration_policy_handler.cc

Issue 15199006: Retire ClearSiteDataOnExit policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 6 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/policy/configuration_policy_handler.h" 5 #include "chrome/browser/policy/configuration_policy_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 setting = CONTENT_SETTING_BLOCK; 1385 setting = CONTENT_SETTING_BLOCK;
1386 } 1386 }
1387 } 1387 }
1388 1388
1389 if (setting != CONTENT_SETTING_DEFAULT) { 1389 if (setting != CONTENT_SETTING_DEFAULT) {
1390 prefs->SetValue(prefs::kManagedDefaultJavaScriptSetting, 1390 prefs->SetValue(prefs::kManagedDefaultJavaScriptSetting,
1391 Value::CreateIntegerValue(setting)); 1391 Value::CreateIntegerValue(setting));
1392 } 1392 }
1393 } 1393 }
1394 1394
1395 // ClearSiteDataOnExitPolicyHandler implementation -----------------------------
1396
1397 ClearSiteDataOnExitPolicyHandler::ClearSiteDataOnExitPolicyHandler()
1398 : TypeCheckingPolicyHandler(key::kClearSiteDataOnExit,
1399 Value::TYPE_BOOLEAN) {
1400 }
1401
1402 ClearSiteDataOnExitPolicyHandler::~ClearSiteDataOnExitPolicyHandler() {
1403 }
1404
1405 bool ClearSiteDataOnExitPolicyHandler::CheckPolicySettings(
1406 const PolicyMap& policies,
1407 PolicyErrorMap* errors) {
1408 ContentSetting content_setting = CONTENT_SETTING_DEFAULT;
1409 if (ClearSiteDataEnabled(policies) &&
1410 GetContentSetting(policies, &content_setting) &&
1411 content_setting == CONTENT_SETTING_ALLOW) {
1412 errors->AddError(key::kDefaultCookiesSetting,
1413 IDS_POLICY_OVERRIDDEN,
1414 policy_name());
1415 }
1416
1417 return TypeCheckingPolicyHandler::CheckPolicySettings(policies, errors);
1418 }
1419
1420 void ClearSiteDataOnExitPolicyHandler::ApplyPolicySettings(
1421 const PolicyMap& policies,
1422 PrefValueMap* prefs) {
1423 if (ClearSiteDataEnabled(policies)) {
1424 ContentSetting content_setting = CONTENT_SETTING_DEFAULT;
1425 if (!GetContentSetting(policies, &content_setting) ||
1426 content_setting == CONTENT_SETTING_ALLOW) {
1427 prefs->SetValue(
1428 prefs::kManagedDefaultCookiesSetting,
1429 Value::CreateIntegerValue(CONTENT_SETTING_SESSION_ONLY));
1430 }
1431 }
1432 }
1433
1434 bool ClearSiteDataOnExitPolicyHandler::ClearSiteDataEnabled(
1435 const PolicyMap& policies) {
1436 const base::Value* value = NULL;
1437 PolicyErrorMap errors;
1438 bool clear_site_data = false;
1439
1440 return (CheckAndGetValue(policies, &errors, &value) &&
1441 value &&
1442 value->GetAsBoolean(&clear_site_data) &&
1443 clear_site_data);
1444 }
1445
1446 // static
1447 bool ClearSiteDataOnExitPolicyHandler::GetContentSetting(
1448 const PolicyMap& policies,
1449 ContentSetting* content_setting) {
1450 const base::Value* value = policies.GetValue(key::kDefaultCookiesSetting);
1451 int setting = CONTENT_SETTING_DEFAULT;
1452 if (value && value->GetAsInteger(&setting)) {
1453 *content_setting = static_cast<ContentSetting>(setting);
1454 return true;
1455 }
1456
1457 return false;
1458 }
1459
1460 // RestoreOnStartupPolicyHandler implementation -------------------------------- 1395 // RestoreOnStartupPolicyHandler implementation --------------------------------
1461 1396
1462 RestoreOnStartupPolicyHandler::RestoreOnStartupPolicyHandler() 1397 RestoreOnStartupPolicyHandler::RestoreOnStartupPolicyHandler()
1463 : TypeCheckingPolicyHandler(key::kRestoreOnStartup, 1398 : TypeCheckingPolicyHandler(key::kRestoreOnStartup,
1464 Value::TYPE_INTEGER) { 1399 Value::TYPE_INTEGER) {
1465 } 1400 }
1466 1401
1467 RestoreOnStartupPolicyHandler::~RestoreOnStartupPolicyHandler() { 1402 RestoreOnStartupPolicyHandler::~RestoreOnStartupPolicyHandler() {
1468 } 1403 }
1469 1404
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 errors->AddError(policy_name(), 1500 errors->AddError(policy_name(),
1566 IDS_POLICY_OUT_OF_RANGE_ERROR, 1501 IDS_POLICY_OUT_OF_RANGE_ERROR,
1567 base::IntToString(restore_value)); 1502 base::IntToString(restore_value));
1568 } 1503 }
1569 } 1504 }
1570 } 1505 }
1571 return true; 1506 return true;
1572 } 1507 }
1573 1508
1574 } // namespace policy 1509 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_handler.h ('k') | chrome/browser/policy/configuration_policy_handler_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698