OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/managed_mode/managed_user_service.h" | 5 #include "chrome/browser/managed_mode/managed_user_service.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // If the extension is already loaded, we allow it, otherwise we'd unload | 161 // If the extension is already loaded, we allow it, otherwise we'd unload |
162 // all existing extensions. | 162 // all existing extensions. |
163 ExtensionService* extension_service = | 163 ExtensionService* extension_service = |
164 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 164 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
165 | 165 |
166 // |extension_service| can be NULL in a unit test. | 166 // |extension_service| can be NULL in a unit test. |
167 if (extension_service && | 167 if (extension_service && |
168 extension_service->GetInstalledExtension(extension->id())) | 168 extension_service->GetInstalledExtension(extension->id())) |
169 return true; | 169 return true; |
170 | 170 |
| 171 if (extension) { |
| 172 bool was_installed_by_default = extension->was_installed_by_default(); |
| 173 #ifdef OS_CHROMEOS |
| 174 // On Chrome OS all external sources are controlled by us so it means that |
| 175 // they are "default". Method was_installed_by_default returns false because |
| 176 // extensions creation flags are ignored in case of default extensions with |
| 177 // update URL(the flags aren't passed to OnExternalExtensionUpdateUrlFound). |
| 178 // TODO(dpolukhin): remove this Chrome OS specific code as soon as creation |
| 179 // flags are not ignored. |
| 180 was_installed_by_default = |
| 181 extensions::Manifest::IsExternalLocation(extension->location()); |
| 182 #endif |
| 183 if (extension->location() == extensions::Manifest::COMPONENT || |
| 184 was_installed_by_default) { |
| 185 return true; |
| 186 } |
| 187 } |
| 188 |
171 if (error) | 189 if (error) |
172 *error = tmp_error; | 190 *error = tmp_error; |
173 return false; | 191 return false; |
174 } | 192 } |
175 | 193 |
176 bool ManagedUserService::UserMayModifySettings( | 194 bool ManagedUserService::UserMayModifySettings( |
177 const extensions::Extension* extension, | 195 const extensions::Extension* extension, |
178 string16* error) const { | 196 string16* error) const { |
179 return ExtensionManagementPolicyImpl(error); | 197 return ExtensionManagementPolicyImpl(error); |
180 } | 198 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); | 383 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); |
366 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); | 384 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); |
367 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 385 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
368 bool allow = false; | 386 bool allow = false; |
369 bool result = it.value().GetAsBoolean(&allow); | 387 bool result = it.value().GetAsBoolean(&allow); |
370 DCHECK(result); | 388 DCHECK(result); |
371 (*url_map)[GURL(it.key())] = allow; | 389 (*url_map)[GURL(it.key())] = allow; |
372 } | 390 } |
373 url_filter_context_.SetManualURLs(url_map.Pass()); | 391 url_filter_context_.SetManualURLs(url_map.Pass()); |
374 } | 392 } |
OLD | NEW |