Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/external_policy_extension_provider.h" | 5 #include "chrome/browser/extensions/external_policy_extension_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 #include "chrome/browser/extensions/stateful_external_extension_provider.h" | 10 #include "chrome/browser/extensions/stateful_external_extension_provider.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 if (!Extension::IdIsValid(id)) { | 23 if (!Extension::IdIsValid(id)) { |
| 24 LOG(WARNING) << "Policy specifies invalid ID for external " | 24 LOG(WARNING) << "Policy specifies invalid ID for external " |
| 25 << "extension: " << id; | 25 << "extension: " << id; |
| 26 return false; | 26 return false; |
| 27 } | 27 } |
| 28 return true; | 28 return true; |
| 29 } | 29 } |
| 30 | 30 |
| 31 } | 31 } |
| 32 | 32 |
| 33 ExternalPolicyExtensionProvider::ExternalPolicyExtensionProvider() | 33 ExternalPolicyExtensionProvider::ExternalPolicyExtensionProvider( |
| 34 : StatefulExternalExtensionProvider(Extension::INVALID, | 34 const ListValue* forcelist) |
| 35 Extension::EXTERNAL_POLICY_DOWNLOAD) { | 35 : StatefulExternalExtensionProvider( |
|
jochen (gone - plz use gerrit)
2010/12/14 13:40:43
only indent 4 spaces
gfeher
2010/12/14 14:23:15
Done.
| |
| 36 Extension::INVALID, | |
| 37 Extension::EXTERNAL_POLICY_DOWNLOAD) { | |
| 38 SetPreferences(forcelist); | |
| 36 } | 39 } |
| 37 | 40 |
| 38 ExternalPolicyExtensionProvider::~ExternalPolicyExtensionProvider() { | 41 ExternalPolicyExtensionProvider::~ExternalPolicyExtensionProvider() { |
| 39 } | 42 } |
| 40 | 43 |
| 41 void ExternalPolicyExtensionProvider::SetPreferences( | 44 void ExternalPolicyExtensionProvider::SetPreferences( |
| 42 const ListValue* forcelist) { | 45 const ListValue* forcelist) { |
| 43 DictionaryValue* result = new DictionaryValue(); | 46 DictionaryValue* result = new DictionaryValue(); |
| 44 if (forcelist != NULL) { | 47 if (forcelist != NULL) { |
| 45 std::string extension_desc; | 48 std::string extension_desc; |
| 46 for (ListValue::const_iterator it = forcelist->begin(); | 49 for (ListValue::const_iterator it = forcelist->begin(); |
| 47 it != forcelist->end(); ++it) { | 50 it != forcelist->end(); ++it) { |
| 48 if (!(*it)->GetAsString(&extension_desc)) { | 51 if (!(*it)->GetAsString(&extension_desc)) { |
| 49 LOG(WARNING) << "Failed to read forcelist string."; | 52 LOG(WARNING) << "Failed to read forcelist string."; |
| 50 } else { | 53 } else { |
| 51 // Each string item of the list has the following form: | 54 // Each string item of the list has the following form: |
| 52 // extension_id_code;extension_update_url | 55 // extension_id_code;extension_update_url |
| 53 // The update URL might also contain semicolons. | 56 // The update URL might also contain semicolons. |
| 54 size_t pos = extension_desc.find(';'); | 57 size_t pos = extension_desc.find(';'); |
| 55 std::string id = extension_desc.substr(0, pos); | 58 std::string id = extension_desc.substr(0, pos); |
| 56 std::string update_url = extension_desc.substr(pos+1); | 59 std::string update_url = extension_desc.substr(pos+1); |
| 57 if (CheckExtension(id, update_url)) { | 60 if (CheckExtension(id, update_url)) { |
| 58 result->SetString(id + ".external_update_url", update_url); | 61 result->SetString(id + ".external_update_url", update_url); |
| 59 } | 62 } |
| 60 } | 63 } |
| 61 } | 64 } |
| 62 } | 65 } |
| 63 prefs_.reset(result); | 66 set_prefs(result); |
| 64 } | 67 } |
| OLD | NEW |