OLD | NEW |
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 "chrome/browser/extensions/extension_util.h" | 5 #include "chrome/browser/extensions/extension_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 } // namespace | 115 } // namespace |
116 | 116 |
117 bool IsIncognitoEnabled(const std::string& extension_id, | 117 bool IsIncognitoEnabled(const std::string& extension_id, |
118 content::BrowserContext* context) { | 118 content::BrowserContext* context) { |
119 const Extension* extension = ExtensionRegistry::Get(context)-> | 119 const Extension* extension = ExtensionRegistry::Get(context)-> |
120 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); | 120 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
121 if (extension) { | 121 if (extension) { |
122 if (!extension->can_be_incognito_enabled()) | 122 if (!util::CanBeIncognitoEnabled(extension)) |
123 return false; | 123 return false; |
124 // If this is an existing component extension we always allow it to | 124 // If this is an existing component extension we always allow it to |
125 // work in incognito mode. | 125 // work in incognito mode. |
126 if (extension->location() == Manifest::COMPONENT) | 126 if (extension->location() == Manifest::COMPONENT) |
127 return true; | 127 return true; |
128 if (IsWhitelistedForIncognito(extension)) | 128 if (IsWhitelistedForIncognito(extension)) |
129 return true; | 129 return true; |
130 } | 130 } |
131 return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id); | 131 return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id); |
132 } | 132 } |
133 | 133 |
134 void SetIsIncognitoEnabled(const std::string& extension_id, | 134 void SetIsIncognitoEnabled(const std::string& extension_id, |
135 content::BrowserContext* context, | 135 content::BrowserContext* context, |
136 bool enabled) { | 136 bool enabled) { |
137 ExtensionRegistry* registry = ExtensionRegistry::Get(context); | 137 ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
138 const Extension* extension = | 138 const Extension* extension = |
139 registry->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); | 139 registry->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); |
140 | 140 |
141 if (extension) { | 141 if (extension) { |
142 if (!extension->can_be_incognito_enabled()) | 142 if (!util::CanBeIncognitoEnabled(extension)) |
143 return; | 143 return; |
144 | 144 |
145 // TODO(treib,kalman): Should this be Manifest::IsComponentLocation(..)? | 145 // TODO(treib,kalman): Should this be Manifest::IsComponentLocation(..)? |
146 // (which also checks for EXTERNAL_COMPONENT). | 146 // (which also checks for EXTERNAL_COMPONENT). |
147 if (extension->location() == Manifest::COMPONENT) { | 147 if (extension->location() == Manifest::COMPONENT) { |
148 // This shouldn't be called for component extensions unless it is called | 148 // This shouldn't be called for component extensions unless it is called |
149 // by sync, for syncable component extensions. | 149 // by sync, for syncable component extensions. |
150 // See http://crbug.com/112290 and associated CLs for the sordid history. | 150 // See http://crbug.com/112290 and associated CLs for the sordid history. |
151 DCHECK(sync_helper::IsSyncableComponentExtension(extension)); | 151 DCHECK(sync_helper::IsSyncableComponentExtension(extension)); |
152 | 152 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 375 } |
376 | 376 |
377 bool NeedCustodianApprovalForPermissionIncrease() { | 377 bool NeedCustodianApprovalForPermissionIncrease() { |
378 const std::string group_name = base::FieldTrialList::FindFullName( | 378 const std::string group_name = base::FieldTrialList::FindFullName( |
379 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); | 379 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); |
380 return group_name == "NeedCustodianApproval"; | 380 return group_name == "NeedCustodianApproval"; |
381 } | 381 } |
382 | 382 |
383 } // namespace util | 383 } // namespace util |
384 } // namespace extensions | 384 } // namespace extensions |
OLD | NEW |