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 |
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)); | |
Aaron Boodman
2012/02/08 18:23:28
Can't this just be:
DCHECK(extension->IsSyncable(
csharp
2012/02/08 20:02:26
Done.
| |
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 // All apps will appear on the NTP and are ordered by their ordinals so we | |
2060 // must ensure they have valid ordinals. | |
2061 if (extension->is_app()) { | |
Aaron Boodman
2012/02/08 18:23:28
But you just said this isn't true. Will it be bad
csharp
2012/02/08 20:02:26
Changing to only do if the extension Should displa
| |
2062 ExtensionSorting* extension_sorting = extension_prefs_->extension_sorting(); | |
2063 | |
2064 StringOrdinal page_ordinal = | |
2065 extension_sorting->GetPageOrdinal(extension->id()); | |
2066 if (!page_ordinal.IsValid()) { | |
2067 page_ordinal = extension->id() == extension_misc::kWebStoreAppId ? | |
akalin
2012/02/08 18:27:43
add a comment explaining the special cases for the
csharp
2012/02/08 20:02:26
Done.
| |
2068 extension_sorting->CreateFirstAppPageOrdinal() : | |
2069 extension_sorting->GetNaturalAppPageOrdinal(); | |
2070 extension_sorting->SetPageOrdinal(extension->id(), page_ordinal); | |
2071 } | |
2072 | |
2073 StringOrdinal app_launch_ordinal = | |
2074 extension_sorting->GetAppLaunchOrdinal(extension->id()); | |
2075 if (!app_launch_ordinal.IsValid()) { | |
2076 app_launch_ordinal = extension->id() == extension_misc::kWebStoreAppId ? | |
2077 extension_sorting->CreateFirstAppLaunchOrdinal(page_ordinal) : | |
2078 extension_sorting->CreateNextAppLaunchOrdinal(page_ordinal); | |
2079 extension_sorting->SetAppLaunchOrdinal(extension->id(), | |
2080 app_launch_ordinal); | |
2081 } | |
2082 } | |
2083 | |
2053 extensions_.Insert(scoped_extension); | 2084 extensions_.Insert(scoped_extension); |
2054 SyncExtensionChangeIfNeeded(*extension); | 2085 SyncExtensionChangeIfNeeded(*extension); |
2055 NotifyExtensionLoaded(extension); | 2086 NotifyExtensionLoaded(extension); |
2056 } | 2087 } |
2057 | 2088 |
2058 void ExtensionService::InitializePermissions(const Extension* extension) { | 2089 void ExtensionService::InitializePermissions(const Extension* extension) { |
2059 // If the extension has used the optional permissions API, it will have a | 2090 // 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, | 2091 // custom set of active permissions defined in the extension prefs. Here, |
2061 // we update the extension's active permissions based on the prefs. | 2092 // we update the extension's active permissions based on the prefs. |
2062 scoped_refptr<ExtensionPermissionSet> active_permissions = | 2093 scoped_refptr<ExtensionPermissionSet> active_permissions = |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2692 // | 2723 // |
2693 // To coexist with certain unit tests that don't have an IO thread message | 2724 // To coexist with certain unit tests that don't have an IO thread message |
2694 // loop available at ExtensionService shutdown, we lazy-initialize this | 2725 // loop available at ExtensionService shutdown, we lazy-initialize this |
2695 // object so that those cases neither create nor destroy a SocketController. | 2726 // object so that those cases neither create nor destroy a SocketController. |
2696 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2727 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
2697 if (!socket_controller_) { | 2728 if (!socket_controller_) { |
2698 socket_controller_ = new extensions::SocketController(); | 2729 socket_controller_ = new extensions::SocketController(); |
2699 } | 2730 } |
2700 return socket_controller_; | 2731 return socket_controller_; |
2701 } | 2732 } |
OLD | NEW |