| 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 "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_sync_service.h" | 9 #include "chrome/browser/extensions/extension_sync_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // by sync, for syncable component extensions. | 56 // by sync, for syncable component extensions. |
| 57 // See http://crbug.com/112290 and associated CLs for the sordid history. | 57 // See http://crbug.com/112290 and associated CLs for the sordid history. |
| 58 DCHECK(sync_helper::IsSyncable(extension)); | 58 DCHECK(sync_helper::IsSyncable(extension)); |
| 59 | 59 |
| 60 // If we are here, make sure the we aren't trying to change the value. | 60 // If we are here, make sure the we aren't trying to change the value. |
| 61 DCHECK_EQ(enabled, IsIncognitoEnabled(extension_id, service->profile())); | 61 DCHECK_EQ(enabled, IsIncognitoEnabled(extension_id, service->profile())); |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 ExtensionPrefs* extension_prefs = service->extension_prefs(); | 66 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(service->profile()); |
| 67 // Broadcast unloaded and loaded events to update browser state. Only bother | 67 // Broadcast unloaded and loaded events to update browser state. Only bother |
| 68 // if the value changed and the extension is actually enabled, since there is | 68 // if the value changed and the extension is actually enabled, since there is |
| 69 // no UI otherwise. | 69 // no UI otherwise. |
| 70 bool old_enabled = extension_prefs->IsIncognitoEnabled(extension_id); | 70 bool old_enabled = extension_prefs->IsIncognitoEnabled(extension_id); |
| 71 if (enabled == old_enabled) | 71 if (enabled == old_enabled) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 extension_prefs->SetIsIncognitoEnabled(extension_id, enabled); | 74 extension_prefs->SetIsIncognitoEnabled(extension_id, enabled); |
| 75 | 75 |
| 76 bool extension_is_enabled = service->extensions()->Contains(extension_id); | 76 bool extension_is_enabled = service->extensions()->Contains(extension_id); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 bool allow) { | 122 bool allow) { |
| 123 ExtensionService* service = | 123 ExtensionService* service = |
| 124 ExtensionSystem::Get(context)->extension_service(); | 124 ExtensionSystem::Get(context)->extension_service(); |
| 125 CHECK(service); | 125 CHECK(service); |
| 126 | 126 |
| 127 // Reload to update browser state. Only bother if the value changed and the | 127 // Reload to update browser state. Only bother if the value changed and the |
| 128 // extension is actually enabled, since there is no UI otherwise. | 128 // extension is actually enabled, since there is no UI otherwise. |
| 129 if (allow == AllowFileAccess(extension_id, context)) | 129 if (allow == AllowFileAccess(extension_id, context)) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 service->extension_prefs()->SetAllowFileAccess(extension_id, allow); | 132 ExtensionPrefs::Get(context)->SetAllowFileAccess(extension_id, allow); |
| 133 | 133 |
| 134 bool extension_is_enabled = service->extensions()->Contains(extension_id); | 134 bool extension_is_enabled = service->extensions()->Contains(extension_id); |
| 135 if (extension_is_enabled) | 135 if (extension_is_enabled) |
| 136 service->ReloadExtension(extension_id); | 136 service->ReloadExtension(extension_id); |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool IsAppLaunchable(const std::string& extension_id, | 139 bool IsAppLaunchable(const std::string& extension_id, |
| 140 content::BrowserContext* context) { | 140 content::BrowserContext* context) { |
| 141 return !(ExtensionPrefs::Get(context)->GetDisableReasons(extension_id) & | 141 return !(ExtensionPrefs::Get(context)->GetDisableReasons(extension_id) & |
| 142 Extension::DISABLE_UNSUPPORTED_REQUIREMENT); | 142 Extension::DISABLE_UNSUPPORTED_REQUIREMENT); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 168 | 168 |
| 169 bool IsExtensionInstalledPermanently(const std::string& extension_id, | 169 bool IsExtensionInstalledPermanently(const std::string& extension_id, |
| 170 content::BrowserContext* context) { | 170 content::BrowserContext* context) { |
| 171 const Extension* extension = ExtensionRegistry::Get(context)-> | 171 const Extension* extension = ExtensionRegistry::Get(context)-> |
| 172 GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); | 172 GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); |
| 173 return extension && !extension->is_ephemeral(); | 173 return extension && !extension->is_ephemeral(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace util | 176 } // namespace util |
| 177 } // namespace extensions | 177 } // namespace extensions |
| OLD | NEW |