Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/extensions/extension_prefs.h" | 5 #include "chrome/browser/extensions/extension_prefs.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/admin_policy.h" | 10 #include "chrome/browser/extensions/admin_policy.h" |
| (...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1311 const std::string& id) const { | 1311 const std::string& id) const { |
| 1312 return DoesExtensionHaveState(id, Extension::EXTERNAL_EXTENSION_UNINSTALLED); | 1312 return DoesExtensionHaveState(id, Extension::EXTERNAL_EXTENSION_UNINSTALLED); |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 bool ExtensionPrefs::IsExtensionDisabled( | 1315 bool ExtensionPrefs::IsExtensionDisabled( |
| 1316 const std::string& id) const { | 1316 const std::string& id) const { |
| 1317 return DoesExtensionHaveState(id, Extension::DISABLED); | 1317 return DoesExtensionHaveState(id, Extension::DISABLED); |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 ExtensionPrefs::ExtensionIdSet ExtensionPrefs::GetToolbarOrder() { | 1320 ExtensionPrefs::ExtensionIdSet ExtensionPrefs::GetToolbarOrder() { |
| 1321 bool action_box_enabled = extensions::switch_utils::IsActionBoxEnabled(); | 1321 bool extensions_in_action_box_enabled = |
| 1322 extensions::switch_utils::IsExtensionsInActionBoxEnabled(); | |
|
not at google - send to devlin
2012/08/14 04:09:53
add a method like GetToolbarKey or something, whic
yefimt
2012/08/14 20:59:07
Done.
| |
| 1322 return GetExtensionPrefAsVector( | 1323 return GetExtensionPrefAsVector( |
| 1323 action_box_enabled ? kExtensionActionBoxBar : kExtensionToolbar); | 1324 extensions_in_action_box_enabled ? |
| 1325 kExtensionActionBoxBar : kExtensionToolbar); | |
| 1324 } | 1326 } |
| 1325 | 1327 |
| 1326 void ExtensionPrefs::SetToolbarOrder(const ExtensionIdSet& extension_ids) { | 1328 void ExtensionPrefs::SetToolbarOrder(const ExtensionIdSet& extension_ids) { |
| 1327 SetExtensionPrefFromVector(extensions::switch_utils::IsActionBoxEnabled() ? | 1329 bool extensions_in_action_box_enabled = |
| 1330 extensions::switch_utils::IsExtensionsInActionBoxEnabled(); | |
| 1331 SetExtensionPrefFromVector(extensions_in_action_box_enabled ? | |
| 1328 kExtensionActionBoxBar : kExtensionToolbar, extension_ids); | 1332 kExtensionActionBoxBar : kExtensionToolbar, extension_ids); |
| 1329 } | 1333 } |
| 1330 | 1334 |
| 1331 ExtensionPrefs::ExtensionIdSet ExtensionPrefs::GetActionBoxOrder() { | 1335 ExtensionPrefs::ExtensionIdSet ExtensionPrefs::GetActionBoxOrder() { |
| 1332 return GetExtensionPrefAsVector(kExtensionActionBox); | 1336 return GetExtensionPrefAsVector(kExtensionActionBox); |
| 1333 } | 1337 } |
| 1334 | 1338 |
| 1335 void ExtensionPrefs::SetActionBoxOrder(const ExtensionIdSet& extension_ids) { | 1339 void ExtensionPrefs::SetActionBoxOrder(const ExtensionIdSet& extension_ids) { |
| 1336 SetExtensionPrefFromVector(kExtensionActionBox, extension_ids); | 1340 SetExtensionPrefFromVector(kExtensionActionBox, extension_ids); |
| 1337 } | 1341 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1414 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, | 1418 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, |
| 1415 Extension::State state) { | 1419 Extension::State state) { |
| 1416 UpdateExtensionPref(extension_id, kPrefState, | 1420 UpdateExtensionPref(extension_id, kPrefState, |
| 1417 Value::CreateIntegerValue(state)); | 1421 Value::CreateIntegerValue(state)); |
| 1418 bool enabled = (state == Extension::ENABLED); | 1422 bool enabled = (state == Extension::ENABLED); |
| 1419 extension_pref_value_map_->SetExtensionState(extension_id, enabled); | 1423 extension_pref_value_map_->SetExtensionState(extension_id, enabled); |
| 1420 content_settings_store_->SetExtensionState(extension_id, enabled); | 1424 content_settings_store_->SetExtensionState(extension_id, enabled); |
| 1421 } | 1425 } |
| 1422 | 1426 |
| 1423 bool ExtensionPrefs::GetBrowserActionVisibility(const Extension* extension) { | 1427 bool ExtensionPrefs::GetBrowserActionVisibility(const Extension* extension) { |
| 1424 bool action_box_enabled = switch_utils::IsActionBoxEnabled(); | 1428 bool extensions_in_action_box_enabled = |
| 1425 bool default_value = !action_box_enabled; | 1429 switch_utils::IsExtensionsInActionBoxEnabled(); |
| 1430 bool default_value = !(extensions_in_action_box_enabled); | |
|
not at google - send to devlin
2012/08/14 04:09:53
parens unnecessary?
yefimt
2012/08/14 20:59:07
Done.
| |
| 1426 | 1431 |
| 1427 const DictionaryValue* extension_prefs = GetExtensionPref(extension->id()); | 1432 const DictionaryValue* extension_prefs = GetExtensionPref(extension->id()); |
| 1428 if (!extension_prefs) | 1433 if (!extension_prefs) |
| 1429 return default_value; | 1434 return default_value; |
| 1430 | 1435 |
| 1431 bool visible = false; | 1436 bool visible = false; |
| 1432 const char* browser_action_pref = action_box_enabled ? kBrowserActionPinned : | 1437 const char* browser_action_pref = |
| 1433 kBrowserActionVisible; | 1438 extensions_in_action_box_enabled ? |
| 1439 kBrowserActionPinned : kBrowserActionVisible; | |
|
not at google - send to devlin
2012/08/14 04:09:53
likewise, add GetToolbarVisibilityKey() perhaps, w
yefimt
2012/08/14 20:59:07
Done.
| |
| 1434 bool pref_exists = extension_prefs->GetBoolean(browser_action_pref, &visible); | 1440 bool pref_exists = extension_prefs->GetBoolean(browser_action_pref, &visible); |
| 1435 if (!pref_exists) | 1441 if (!pref_exists) |
| 1436 return default_value; | 1442 return default_value; |
| 1437 | 1443 |
| 1438 return visible; | 1444 return visible; |
| 1439 } | 1445 } |
| 1440 | 1446 |
| 1441 void ExtensionPrefs::SetBrowserActionVisibility(const Extension* extension, | 1447 void ExtensionPrefs::SetBrowserActionVisibility(const Extension* extension, |
| 1442 bool visible) { | 1448 bool visible) { |
| 1443 if (GetBrowserActionVisibility(extension) == visible) | 1449 if (GetBrowserActionVisibility(extension) == visible) |
| 1444 return; | 1450 return; |
| 1445 | 1451 |
| 1446 bool action_box_enabled = switch_utils::IsActionBoxEnabled(); | 1452 bool extensions_in_action_box_enabled = |
| 1447 const char* browser_action_pref = action_box_enabled ? kBrowserActionPinned : | 1453 switch_utils::IsExtensionsInActionBoxEnabled(); |
| 1448 kBrowserActionVisible; | 1454 const char* browser_action_pref = extensions_in_action_box_enabled ? |
| 1455 kBrowserActionPinned : kBrowserActionVisible; | |
| 1449 UpdateExtensionPref(extension->id(), browser_action_pref, | 1456 UpdateExtensionPref(extension->id(), browser_action_pref, |
| 1450 Value::CreateBooleanValue(visible)); | 1457 Value::CreateBooleanValue(visible)); |
| 1451 content::NotificationService::current()->Notify( | 1458 content::NotificationService::current()->Notify( |
| 1452 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 1459 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
| 1453 content::Source<ExtensionPrefs>(this), | 1460 content::Source<ExtensionPrefs>(this), |
| 1454 content::Details<const Extension>(extension)); | 1461 content::Details<const Extension>(extension)); |
| 1455 } | 1462 } |
| 1456 | 1463 |
| 1457 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { | 1464 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { |
| 1458 const DictionaryValue* extension = GetExtensionPref(extension_id); | 1465 const DictionaryValue* extension = GetExtensionPref(extension_id); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2098 const ExtensionIdSet& strings) { | 2105 const ExtensionIdSet& strings) { |
| 2099 ListPrefUpdate update(prefs_, pref); | 2106 ListPrefUpdate update(prefs_, pref); |
| 2100 ListValue* list_of_values = update.Get(); | 2107 ListValue* list_of_values = update.Get(); |
| 2101 list_of_values->Clear(); | 2108 list_of_values->Clear(); |
| 2102 for (ExtensionIdSet::const_iterator iter = strings.begin(); | 2109 for (ExtensionIdSet::const_iterator iter = strings.begin(); |
| 2103 iter != strings.end(); ++iter) | 2110 iter != strings.end(); ++iter) |
| 2104 list_of_values->Append(new StringValue(*iter)); | 2111 list_of_values->Append(new StringValue(*iter)); |
| 2105 } | 2112 } |
| 2106 | 2113 |
| 2107 } // namespace extensions | 2114 } // namespace extensions |
| OLD | NEW |