OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1566 return true; | 1566 return true; |
1567 | 1567 |
1568 // Check the prefs. | 1568 // Check the prefs. |
1569 return extension_prefs_->IsIncognitoEnabled(extension_id); | 1569 return extension_prefs_->IsIncognitoEnabled(extension_id); |
1570 } | 1570 } |
1571 | 1571 |
1572 void ExtensionService::SetIsIncognitoEnabled( | 1572 void ExtensionService::SetIsIncognitoEnabled( |
1573 const std::string& extension_id, bool enabled) { | 1573 const std::string& extension_id, bool enabled) { |
1574 const Extension* extension = GetInstalledExtension(extension_id); | 1574 const Extension* extension = GetInstalledExtension(extension_id); |
1575 if (extension && extension->location() == Extension::COMPONENT) { | 1575 if (extension && extension->location() == Extension::COMPONENT) { |
1576 // This shouldn't be called for component extensions. | 1576 // This shouldn't be called for component extensions unless they are |
1577 NOTREACHED(); | 1577 // syncable. |
1578 DCHECK(extension->IsSyncable()); | |
1579 | |
1580 // If we are here, make sure the we aren't trying to change the value. | |
1581 DCHECK_EQ(enabled, IsIncognitoEnabled(extension_id)); | |
1582 | |
1578 return; | 1583 return; |
1579 } | 1584 } |
1580 | 1585 |
1581 // Broadcast unloaded and loaded events to update browser state. Only bother | 1586 // Broadcast unloaded and loaded events to update browser state. Only bother |
1582 // if the value changed and the extension is actually enabled, since there is | 1587 // if the value changed and the extension is actually enabled, since there is |
1583 // no UI otherwise. | 1588 // no UI otherwise. |
1584 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); | 1589 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); |
1585 if (enabled == old_enabled) | 1590 if (enabled == old_enabled) |
1586 return; | 1591 return; |
1587 | 1592 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2043 // disabled extension for other reasons other than that an update was | 2048 // disabled extension for other reasons other than that an update was |
2044 // disabled, e.g. as in ExtensionManagementTest.InstallRequiresConfirm. | 2049 // disabled, e.g. as in ExtensionManagementTest.InstallRequiresConfirm. |
2045 content::NotificationService::current()->Notify( | 2050 content::NotificationService::current()->Notify( |
2046 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 2051 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
2047 content::Source<Profile>(profile_), | 2052 content::Source<Profile>(profile_), |
2048 content::Details<const Extension>(extension)); | 2053 content::Details<const Extension>(extension)); |
2049 SyncExtensionChangeIfNeeded(*extension); | 2054 SyncExtensionChangeIfNeeded(*extension); |
2050 return; | 2055 return; |
2051 } | 2056 } |
2052 | 2057 |
2058 // All apps that are displayed in the launcher are ordered by their ordinals | |
2059 // so we must ensure they have valid ordinals. | |
2060 if (extension->ShouldDisplayInLauncher()) { | |
Aaron Boodman
2012/02/09 19:17:37
Nit: Braces are not required for one-line ifs. In
csharp
2012/02/09 19:53:17
Done.
| |
2061 extension_prefs_->extension_sorting()->EnsureValidOrdinals(extension->id()); | |
2062 } | |
2063 | |
2053 extensions_.Insert(scoped_extension); | 2064 extensions_.Insert(scoped_extension); |
2054 SyncExtensionChangeIfNeeded(*extension); | 2065 SyncExtensionChangeIfNeeded(*extension); |
2055 NotifyExtensionLoaded(extension); | 2066 NotifyExtensionLoaded(extension); |
2056 } | 2067 } |
2057 | 2068 |
2058 void ExtensionService::InitializePermissions(const Extension* extension) { | 2069 void ExtensionService::InitializePermissions(const Extension* extension) { |
2059 // If the extension has used the optional permissions API, it will have a | 2070 // If the extension has used the optional permissions API, it will have a |
2060 // custom set of active permissions defined in the extension prefs. Here, | 2071 // custom set of active permissions defined in the extension prefs. Here, |
2061 // we update the extension's active permissions based on the prefs. | 2072 // we update the extension's active permissions based on the prefs. |
2062 scoped_refptr<ExtensionPermissionSet> active_permissions = | 2073 scoped_refptr<ExtensionPermissionSet> active_permissions = |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2692 // | 2703 // |
2693 // To coexist with certain unit tests that don't have an IO thread message | 2704 // To coexist with certain unit tests that don't have an IO thread message |
2694 // loop available at ExtensionService shutdown, we lazy-initialize this | 2705 // loop available at ExtensionService shutdown, we lazy-initialize this |
2695 // object so that those cases neither create nor destroy a SocketController. | 2706 // object so that those cases neither create nor destroy a SocketController. |
2696 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2707 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
2697 if (!socket_controller_) { | 2708 if (!socket_controller_) { |
2698 socket_controller_ = new extensions::SocketController(); | 2709 socket_controller_ = new extensions::SocketController(); |
2699 } | 2710 } |
2700 return socket_controller_; | 2711 return socket_controller_; |
2701 } | 2712 } |
OLD | NEW |