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 <string> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/values.h" | 10 #include "base/values.h" |
9 #include "chrome/common/pref_names.h" | |
10 #include "chrome/browser/browser_thread.h" | 11 #include "chrome/browser/browser_thread.h" |
11 #include "chrome/browser/extensions/stateful_external_extension_provider.h" | 12 #include "chrome/browser/extensions/stateful_external_extension_provider.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 // Check an extension ID and an URL to be syntactically correct. | 17 // Check an extension ID and an URL to be syntactically correct. |
17 bool CheckExtension(std::string id, std::string update_url) { | 18 bool CheckExtension(std::string id, std::string update_url) { |
18 GURL url(update_url); | 19 GURL url(update_url); |
19 if (!url.is_valid()) { | 20 if (!url.is_valid()) { |
20 LOG(WARNING) << "Policy specifies invalid update URL for external " | 21 LOG(WARNING) << "Policy specifies invalid update URL for external " |
21 << "extension: " << update_url; | 22 << "extension: " << update_url; |
22 return false; | 23 return false; |
23 } | 24 } |
24 if (!Extension::IdIsValid(id)) { | 25 if (!Extension::IdIsValid(id)) { |
25 LOG(WARNING) << "Policy specifies invalid ID for external " | 26 LOG(WARNING) << "Policy specifies invalid ID for external " |
26 << "extension: " << id; | 27 << "extension: " << id; |
27 return false; | 28 return false; |
28 } | 29 } |
29 return true; | 30 return true; |
30 } | 31 } |
31 | 32 |
32 } | 33 } // namespace |
33 | 34 |
34 ExternalPolicyExtensionProvider::ExternalPolicyExtensionProvider( | 35 ExternalPolicyExtensionProvider::ExternalPolicyExtensionProvider( |
35 const ListValue* forcelist) | 36 const ListValue* forcelist) |
36 : StatefulExternalExtensionProvider( | 37 : StatefulExternalExtensionProvider( |
37 Extension::INVALID, | 38 Extension::INVALID, |
38 Extension::EXTERNAL_POLICY_DOWNLOAD) { | 39 Extension::EXTERNAL_POLICY_DOWNLOAD) { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
40 ProcessPreferences(forcelist); | 41 ProcessPreferences(forcelist); |
41 } | 42 } |
42 | 43 |
(...skipping 24 matching lines...) Expand all Loading... |
67 std::string id = extension_desc.substr(0, pos); | 68 std::string id = extension_desc.substr(0, pos); |
68 std::string update_url = extension_desc.substr(pos+1); | 69 std::string update_url = extension_desc.substr(pos+1); |
69 if (CheckExtension(id, update_url)) { | 70 if (CheckExtension(id, update_url)) { |
70 result->SetString(id + ".external_update_url", update_url); | 71 result->SetString(id + ".external_update_url", update_url); |
71 } | 72 } |
72 } | 73 } |
73 } | 74 } |
74 } | 75 } |
75 set_prefs(result); | 76 set_prefs(result); |
76 } | 77 } |
OLD | NEW |