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 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 } | 1384 } |
1385 | 1385 |
1386 void ExtensionPrefs::SetActionBoxOrder(const ExtensionIds& extension_ids) { | 1386 void ExtensionPrefs::SetActionBoxOrder(const ExtensionIds& extension_ids) { |
1387 SetExtensionPrefFromVector(kExtensionActionBox, extension_ids); | 1387 SetExtensionPrefFromVector(kExtensionActionBox, extension_ids); |
1388 } | 1388 } |
1389 | 1389 |
1390 void ExtensionPrefs::OnExtensionInstalled( | 1390 void ExtensionPrefs::OnExtensionInstalled( |
1391 const Extension* extension, | 1391 const Extension* extension, |
1392 Extension::State initial_state, | 1392 Extension::State initial_state, |
1393 bool from_webstore, | 1393 bool from_webstore, |
1394 const StringOrdinal& page_ordinal) { | 1394 const syncer::StringOrdinal& page_ordinal) { |
1395 const std::string& id = extension->id(); | 1395 const std::string& id = extension->id(); |
1396 CHECK(Extension::IdIsValid(id)); | 1396 CHECK(Extension::IdIsValid(id)); |
1397 ScopedExtensionPrefUpdate update(prefs_, id); | 1397 ScopedExtensionPrefUpdate update(prefs_, id); |
1398 DictionaryValue* extension_dict = update.Get(); | 1398 DictionaryValue* extension_dict = update.Get(); |
1399 const base::Time install_time = GetCurrentTime(); | 1399 const base::Time install_time = GetCurrentTime(); |
1400 extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state)); | 1400 extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state)); |
1401 extension_dict->Set(kPrefLocation, | 1401 extension_dict->Set(kPrefLocation, |
1402 Value::CreateIntegerValue(extension->location())); | 1402 Value::CreateIntegerValue(extension->location())); |
1403 extension_dict->Set(kPrefFromWebStore, | 1403 extension_dict->Set(kPrefFromWebStore, |
1404 Value::CreateBooleanValue(from_webstore)); | 1404 Value::CreateBooleanValue(from_webstore)); |
(...skipping 17 matching lines...) Expand all Loading... |
1422 // since it may change on disk. | 1422 // since it may change on disk. |
1423 if (extension->location() != Extension::LOAD) { | 1423 if (extension->location() != Extension::LOAD) { |
1424 extension_dict->Set(kPrefManifest, | 1424 extension_dict->Set(kPrefManifest, |
1425 extension->manifest()->value()->DeepCopy()); | 1425 extension->manifest()->value()->DeepCopy()); |
1426 } | 1426 } |
1427 | 1427 |
1428 // Clear state that may be registered from a previous install. | 1428 // Clear state that may be registered from a previous install. |
1429 extension_dict->Remove(kRegisteredEvents, NULL); | 1429 extension_dict->Remove(kRegisteredEvents, NULL); |
1430 | 1430 |
1431 if (extension->is_app()) { | 1431 if (extension->is_app()) { |
1432 StringOrdinal new_page_ordinal = page_ordinal.IsValid() ? | 1432 syncer::StringOrdinal new_page_ordinal = page_ordinal.IsValid() ? |
1433 page_ordinal : extension_sorting_->GetNaturalAppPageOrdinal(); | 1433 page_ordinal : extension_sorting_->GetNaturalAppPageOrdinal(); |
1434 if (!extension_sorting_->GetPageOrdinal(id).IsValid()) | 1434 if (!extension_sorting_->GetPageOrdinal(id).IsValid()) |
1435 extension_sorting_->SetPageOrdinal(id, new_page_ordinal); | 1435 extension_sorting_->SetPageOrdinal(id, new_page_ordinal); |
1436 if (!extension_sorting_->GetAppLaunchOrdinal(id).IsValid()) | 1436 if (!extension_sorting_->GetAppLaunchOrdinal(id).IsValid()) |
1437 extension_sorting_->SetAppLaunchOrdinal( | 1437 extension_sorting_->SetAppLaunchOrdinal( |
1438 id, extension_sorting_->CreateNextAppLaunchOrdinal(new_page_ordinal)); | 1438 id, extension_sorting_->CreateNextAppLaunchOrdinal(new_page_ordinal)); |
1439 } | 1439 } |
1440 | 1440 |
1441 extension_pref_value_map_->RegisterExtension( | 1441 extension_pref_value_map_->RegisterExtension( |
1442 id, install_time, initial_state == Extension::ENABLED); | 1442 id, install_time, initial_state == Extension::ENABLED); |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 const ExtensionIds& strings) { | 2151 const ExtensionIds& strings) { |
2152 ListPrefUpdate update(prefs_, pref); | 2152 ListPrefUpdate update(prefs_, pref); |
2153 ListValue* list_of_values = update.Get(); | 2153 ListValue* list_of_values = update.Get(); |
2154 list_of_values->Clear(); | 2154 list_of_values->Clear(); |
2155 for (ExtensionIds::const_iterator iter = strings.begin(); | 2155 for (ExtensionIds::const_iterator iter = strings.begin(); |
2156 iter != strings.end(); ++iter) | 2156 iter != strings.end(); ++iter) |
2157 list_of_values->Append(new StringValue(*iter)); | 2157 list_of_values->Append(new StringValue(*iter)); |
2158 } | 2158 } |
2159 | 2159 |
2160 } // namespace extensions | 2160 } // namespace extensions |
OLD | NEW |