Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(909)

Side by Side Diff: extensions/browser/admin_policy.cc

Issue 107803004: Add base:: to string16 in extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove a using Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/browser/admin_policy.h ('k') | extensions/browser/admin_policy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/admin_policy.h" 5 #include "extensions/browser/admin_policy.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "extensions/common/extension.h" 8 #include "extensions/common/extension.h"
9 #include "extensions/common/manifest.h" 9 #include "extensions/common/manifest.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
11 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
12 12
13 namespace { 13 namespace {
14 14
15 bool ManagementPolicyImpl(const extensions::Extension* extension, 15 bool ManagementPolicyImpl(const extensions::Extension* extension,
16 string16* error, 16 base::string16* error,
17 bool modifiable_value) { 17 bool modifiable_value) {
18 bool modifiable = 18 bool modifiable =
19 extension->location() != extensions::Manifest::COMPONENT && 19 extension->location() != extensions::Manifest::COMPONENT &&
20 !extensions::Manifest::IsPolicyLocation(extension->location()); 20 !extensions::Manifest::IsPolicyLocation(extension->location());
21 // Some callers equate "no restriction" to true, others to false. 21 // Some callers equate "no restriction" to true, others to false.
22 if (modifiable) 22 if (modifiable)
23 return modifiable_value; 23 return modifiable_value;
24 24
25 if (error) { 25 if (error) {
26 *error = l10n_util::GetStringFUTF16( 26 *error = l10n_util::GetStringFUTF16(
27 IDS_EXTENSION_CANT_MODIFY_POLICY_REQUIRED, 27 IDS_EXTENSION_CANT_MODIFY_POLICY_REQUIRED,
28 UTF8ToUTF16(extension->name())); 28 UTF8ToUTF16(extension->name()));
29 } 29 }
30 return !modifiable_value; 30 return !modifiable_value;
31 } 31 }
32 32
33 bool ReturnLoadError(const extensions::Extension* extension, string16* error) { 33 bool ReturnLoadError(const extensions::Extension* extension,
34 base::string16* error) {
34 if (error) { 35 if (error) {
35 *error = l10n_util::GetStringFUTF16( 36 *error = l10n_util::GetStringFUTF16(
36 IDS_EXTENSION_CANT_INSTALL_POLICY_BLOCKED, 37 IDS_EXTENSION_CANT_INSTALL_POLICY_BLOCKED,
37 UTF8ToUTF16(extension->name()), 38 UTF8ToUTF16(extension->name()),
38 UTF8ToUTF16(extension->id())); 39 UTF8ToUTF16(extension->id()));
39 } 40 }
40 return false; 41 return false;
41 } 42 }
42 43
43 } // namespace 44 } // namespace
44 45
45 namespace extensions { 46 namespace extensions {
46 namespace admin_policy { 47 namespace admin_policy {
47 48
48 bool BlacklistedByDefault(const base::ListValue* blacklist) { 49 bool BlacklistedByDefault(const base::ListValue* blacklist) {
49 base::StringValue wildcard("*"); 50 base::StringValue wildcard("*");
50 return blacklist && blacklist->Find(wildcard) != blacklist->end(); 51 return blacklist && blacklist->Find(wildcard) != blacklist->end();
51 } 52 }
52 53
53 bool UserMayLoad(const base::ListValue* blacklist, 54 bool UserMayLoad(const base::ListValue* blacklist,
54 const base::ListValue* whitelist, 55 const base::ListValue* whitelist,
55 const base::DictionaryValue* forcelist, 56 const base::DictionaryValue* forcelist,
56 const base::ListValue* allowed_types, 57 const base::ListValue* allowed_types,
57 const Extension* extension, 58 const Extension* extension,
58 string16* error) { 59 base::string16* error) {
59 // Component extensions are always allowed. 60 // Component extensions are always allowed.
60 if (extension->location() == Manifest::COMPONENT) 61 if (extension->location() == Manifest::COMPONENT)
61 return true; 62 return true;
62 63
63 // Forced installed extensions cannot be overwritten manually. 64 // Forced installed extensions cannot be overwritten manually.
64 if (extension->location() != Manifest::EXTERNAL_POLICY && 65 if (extension->location() != Manifest::EXTERNAL_POLICY &&
65 extension->location() != Manifest::EXTERNAL_POLICY_DOWNLOAD && 66 extension->location() != Manifest::EXTERNAL_POLICY_DOWNLOAD &&
66 forcelist && forcelist->HasKey(extension->id())) { 67 forcelist && forcelist->HasKey(extension->id())) {
67 return ReturnLoadError(extension, error); 68 return ReturnLoadError(extension, error);
68 } 69 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return true; 103 return true;
103 104
104 // Then check the admin blacklist. 105 // Then check the admin blacklist.
105 if ((blacklist && blacklist->Find(id_value) != blacklist->end()) || 106 if ((blacklist && blacklist->Find(id_value) != blacklist->end()) ||
106 BlacklistedByDefault(blacklist)) 107 BlacklistedByDefault(blacklist))
107 return ReturnLoadError(extension, error); 108 return ReturnLoadError(extension, error);
108 109
109 return true; 110 return true;
110 } 111 }
111 112
112 bool UserMayModifySettings(const Extension* extension, string16* error) { 113 bool UserMayModifySettings(const Extension* extension, base::string16* error) {
113 return ManagementPolicyImpl(extension, error, true); 114 return ManagementPolicyImpl(extension, error, true);
114 } 115 }
115 116
116 bool MustRemainEnabled(const Extension* extension, string16* error) { 117 bool MustRemainEnabled(const Extension* extension, base::string16* error) {
117 return ManagementPolicyImpl(extension, error, false); 118 return ManagementPolicyImpl(extension, error, false);
118 } 119 }
119 120
120 } // namespace admin_policy 121 } // namespace admin_policy
121 } // namespace extensions 122 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/admin_policy.h ('k') | extensions/browser/admin_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698