Chromium Code Reviews| 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 other than the |
|
Aaron Boodman
2012/02/08 00:37:53
Sorry, why does this happen - sync?
csharp
2012/02/08 15:46:16
Yup.
| |
| 1577 NOTREACHED(); | 1577 // web store (which is considered an app, and may try to set this value). |
| 1578 DCHECK_EQ(extension_id, std::string(extension_misc::kWebStoreAppId)); | |
| 1579 | |
| 1580 // If we are here with the CWS, make sure the we aren't trying to | |
| 1581 // change it. | |
| 1582 DCHECK_EQ(enabled, IsIncognitoEnabled(extension_id)); | |
| 1583 | |
| 1578 return; | 1584 return; |
| 1579 } | 1585 } |
| 1580 | 1586 |
| 1581 // Broadcast unloaded and loaded events to update browser state. Only bother | 1587 // 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 | 1588 // if the value changed and the extension is actually enabled, since there is |
| 1583 // no UI otherwise. | 1589 // no UI otherwise. |
| 1584 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); | 1590 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); |
| 1585 if (enabled == old_enabled) | 1591 if (enabled == old_enabled) |
| 1586 return; | 1592 return; |
| 1587 | 1593 |
| (...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 | 2049 // disabled extension for other reasons other than that an update was |
| 2044 // disabled, e.g. as in ExtensionManagementTest.InstallRequiresConfirm. | 2050 // disabled, e.g. as in ExtensionManagementTest.InstallRequiresConfirm. |
| 2045 content::NotificationService::current()->Notify( | 2051 content::NotificationService::current()->Notify( |
| 2046 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 2052 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 2047 content::Source<Profile>(profile_), | 2053 content::Source<Profile>(profile_), |
| 2048 content::Details<const Extension>(extension)); | 2054 content::Details<const Extension>(extension)); |
| 2049 SyncExtensionChangeIfNeeded(*extension); | 2055 SyncExtensionChangeIfNeeded(*extension); |
| 2050 return; | 2056 return; |
| 2051 } | 2057 } |
| 2052 | 2058 |
| 2059 // Make sure that CWS has valid ordinals on initialization. | |
| 2060 if (extension->id() == extension_misc::kWebStoreAppId) { | |
|
akalin
2012/02/07 22:54:13
Why does this only apply to this particular app?
Aaron Boodman
2012/02/08 00:37:53
Can we just initialize all ordinals if they haven'
csharp
2012/02/08 15:46:16
Good points. I'll initialize all uninitialized ord
| |
| 2061 ExtensionSorting* extension_sorting = extension_prefs_->extension_sorting(); | |
| 2062 | |
| 2063 StringOrdinal page_ordinal = | |
| 2064 extension_sorting->GetPageOrdinal(extension->id()); | |
| 2065 if (!page_ordinal.IsValid()) { | |
| 2066 page_ordinal = extension_sorting->CreateFirstAppPageOrdinal(); | |
| 2067 extension_sorting->SetPageOrdinal(extension->id(), page_ordinal); | |
| 2068 } | |
| 2069 | |
| 2070 StringOrdinal app_launch_ordinal = | |
| 2071 extension_sorting->GetAppLaunchOrdinal(extension->id()); | |
| 2072 if (!app_launch_ordinal.IsValid()) { | |
| 2073 app_launch_ordinal = | |
| 2074 extension_sorting->CreateFirstAppLaunchOrdinal(page_ordinal); | |
| 2075 extension_sorting->SetAppLaunchOrdinal(extension->id(), | |
| 2076 app_launch_ordinal); | |
| 2077 } | |
| 2078 } | |
| 2079 | |
| 2053 extensions_.Insert(scoped_extension); | 2080 extensions_.Insert(scoped_extension); |
| 2054 SyncExtensionChangeIfNeeded(*extension); | 2081 SyncExtensionChangeIfNeeded(*extension); |
| 2055 NotifyExtensionLoaded(extension); | 2082 NotifyExtensionLoaded(extension); |
| 2056 } | 2083 } |
| 2057 | 2084 |
| 2058 void ExtensionService::InitializePermissions(const Extension* extension) { | 2085 void ExtensionService::InitializePermissions(const Extension* extension) { |
| 2059 // If the extension has used the optional permissions API, it will have a | 2086 // 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, | 2087 // custom set of active permissions defined in the extension prefs. Here, |
| 2061 // we update the extension's active permissions based on the prefs. | 2088 // we update the extension's active permissions based on the prefs. |
| 2062 scoped_refptr<ExtensionPermissionSet> active_permissions = | 2089 scoped_refptr<ExtensionPermissionSet> active_permissions = |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2692 // | 2719 // |
| 2693 // To coexist with certain unit tests that don't have an IO thread message | 2720 // To coexist with certain unit tests that don't have an IO thread message |
| 2694 // loop available at ExtensionService shutdown, we lazy-initialize this | 2721 // loop available at ExtensionService shutdown, we lazy-initialize this |
| 2695 // object so that those cases neither create nor destroy a SocketController. | 2722 // object so that those cases neither create nor destroy a SocketController. |
| 2696 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2723 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 2697 if (!socket_controller_) { | 2724 if (!socket_controller_) { |
| 2698 socket_controller_ = new extensions::SocketController(); | 2725 socket_controller_ = new extensions::SocketController(); |
| 2699 } | 2726 } |
| 2700 return socket_controller_; | 2727 return socket_controller_; |
| 2701 } | 2728 } |
| OLD | NEW |