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 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 } | 1394 } |
1395 | 1395 |
1396 void ExtensionPrefs::SetActionBoxOrder(const ExtensionIds& extension_ids) { | 1396 void ExtensionPrefs::SetActionBoxOrder(const ExtensionIds& extension_ids) { |
1397 SetExtensionPrefFromVector(kExtensionActionBox, extension_ids); | 1397 SetExtensionPrefFromVector(kExtensionActionBox, extension_ids); |
1398 } | 1398 } |
1399 | 1399 |
1400 void ExtensionPrefs::OnExtensionInstalled( | 1400 void ExtensionPrefs::OnExtensionInstalled( |
1401 const Extension* extension, | 1401 const Extension* extension, |
1402 Extension::State initial_state, | 1402 Extension::State initial_state, |
1403 bool from_webstore, | 1403 bool from_webstore, |
1404 const StringOrdinal& page_ordinal) { | 1404 const syncer::StringOrdinal& page_ordinal) { |
1405 const std::string& id = extension->id(); | 1405 const std::string& id = extension->id(); |
1406 CHECK(Extension::IdIsValid(id)); | 1406 CHECK(Extension::IdIsValid(id)); |
1407 ScopedExtensionPrefUpdate update(prefs_, id); | 1407 ScopedExtensionPrefUpdate update(prefs_, id); |
1408 DictionaryValue* extension_dict = update.Get(); | 1408 DictionaryValue* extension_dict = update.Get(); |
1409 const base::Time install_time = GetCurrentTime(); | 1409 const base::Time install_time = GetCurrentTime(); |
1410 extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state)); | 1410 extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state)); |
1411 extension_dict->Set(kPrefLocation, | 1411 extension_dict->Set(kPrefLocation, |
1412 Value::CreateIntegerValue(extension->location())); | 1412 Value::CreateIntegerValue(extension->location())); |
1413 extension_dict->Set(kPrefFromWebStore, | 1413 extension_dict->Set(kPrefFromWebStore, |
1414 Value::CreateBooleanValue(from_webstore)); | 1414 Value::CreateBooleanValue(from_webstore)); |
(...skipping 17 matching lines...) Expand all Loading... |
1432 // since it may change on disk. | 1432 // since it may change on disk. |
1433 if (extension->location() != Extension::LOAD) { | 1433 if (extension->location() != Extension::LOAD) { |
1434 extension_dict->Set(kPrefManifest, | 1434 extension_dict->Set(kPrefManifest, |
1435 extension->manifest()->value()->DeepCopy()); | 1435 extension->manifest()->value()->DeepCopy()); |
1436 } | 1436 } |
1437 | 1437 |
1438 // Clear state that may be registered from a previous install. | 1438 // Clear state that may be registered from a previous install. |
1439 extension_dict->Remove(kRegisteredEvents, NULL); | 1439 extension_dict->Remove(kRegisteredEvents, NULL); |
1440 | 1440 |
1441 if (extension->is_app()) { | 1441 if (extension->is_app()) { |
1442 StringOrdinal new_page_ordinal = page_ordinal.IsValid() ? | 1442 syncer::StringOrdinal new_page_ordinal = page_ordinal.IsValid() ? |
1443 page_ordinal : extension_sorting_->GetNaturalAppPageOrdinal(); | 1443 page_ordinal : extension_sorting_->GetNaturalAppPageOrdinal(); |
1444 if (!extension_sorting_->GetPageOrdinal(id).IsValid()) | 1444 if (!extension_sorting_->GetPageOrdinal(id).IsValid()) |
1445 extension_sorting_->SetPageOrdinal(id, new_page_ordinal); | 1445 extension_sorting_->SetPageOrdinal(id, new_page_ordinal); |
1446 if (!extension_sorting_->GetAppLaunchOrdinal(id).IsValid()) | 1446 if (!extension_sorting_->GetAppLaunchOrdinal(id).IsValid()) |
1447 extension_sorting_->SetAppLaunchOrdinal( | 1447 extension_sorting_->SetAppLaunchOrdinal( |
1448 id, extension_sorting_->CreateNextAppLaunchOrdinal(new_page_ordinal)); | 1448 id, extension_sorting_->CreateNextAppLaunchOrdinal(new_page_ordinal)); |
1449 } | 1449 } |
1450 | 1450 |
1451 extension_pref_value_map_->RegisterExtension( | 1451 extension_pref_value_map_->RegisterExtension( |
1452 id, install_time, initial_state == Extension::ENABLED); | 1452 id, install_time, initial_state == Extension::ENABLED); |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 const ExtensionIds& strings) { | 2161 const ExtensionIds& strings) { |
2162 ListPrefUpdate update(prefs_, pref); | 2162 ListPrefUpdate update(prefs_, pref); |
2163 ListValue* list_of_values = update.Get(); | 2163 ListValue* list_of_values = update.Get(); |
2164 list_of_values->Clear(); | 2164 list_of_values->Clear(); |
2165 for (ExtensionIds::const_iterator iter = strings.begin(); | 2165 for (ExtensionIds::const_iterator iter = strings.begin(); |
2166 iter != strings.end(); ++iter) | 2166 iter != strings.end(); ++iter) |
2167 list_of_values->Append(new StringValue(*iter)); | 2167 list_of_values->Append(new StringValue(*iter)); |
2168 } | 2168 } |
2169 | 2169 |
2170 } // namespace extensions | 2170 } // namespace extensions |
OLD | NEW |