Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { | 192 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { |
| 193 } | 193 } |
| 194 | 194 |
| 195 void SimpleExtensionLoadPrompt::ShowPrompt() { | 195 void SimpleExtensionLoadPrompt::ShowPrompt() { |
| 196 install_ui_->ConfirmInstall(this, extension_); | 196 install_ui_->ConfirmInstall(this, extension_); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void SimpleExtensionLoadPrompt::InstallUIProceed() { | 199 void SimpleExtensionLoadPrompt::InstallUIProceed() { |
| 200 if (extension_service_.get()) | 200 if (extension_service_.get()) |
| 201 extension_service_->OnExtensionInstalled( | 201 extension_service_->OnExtensionInstalled( |
| 202 extension_, false, 0); // Not from web store. | 202 extension_, false, -1); // Not from web store. |
| 203 delete this; | 203 delete this; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SimpleExtensionLoadPrompt::InstallUIAbort(bool user_initiated) { | 206 void SimpleExtensionLoadPrompt::InstallUIAbort(bool user_initiated) { |
| 207 delete this; | 207 delete this; |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace | 210 } // namespace |
| 211 | 211 |
| 212 bool ExtensionService::ComponentExtensionInfo::Equals( | 212 bool ExtensionService::ComponentExtensionInfo::Equals( |
| (...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2223 // with a disabled extension for other reasons other than that an update was | 2223 // with a disabled extension for other reasons other than that an update was |
| 2224 // disabled. | 2224 // disabled. |
| 2225 NotificationService::current()->Notify( | 2225 NotificationService::current()->Notify( |
| 2226 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 2226 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 2227 Source<Profile>(profile_), | 2227 Source<Profile>(profile_), |
| 2228 Details<const Extension>(extension)); | 2228 Details<const Extension>(extension)); |
| 2229 SyncExtensionChangeIfNeeded(*extension); | 2229 SyncExtensionChangeIfNeeded(*extension); |
| 2230 return; | 2230 return; |
| 2231 } | 2231 } |
| 2232 | 2232 |
| 2233 // Unfortunately, we used to set app launcher indices for non-apps. If this | |
| 2234 // extension has an index (page or in-page), set it to -1. | |
|
Matt Perry
2011/08/25 17:59:35
out of curiosity, why do we care whether a non-app
Evan Stade
2011/08/25 18:50:49
because we need to be able to count the number of
Matt Perry
2011/08/25 18:52:03
I see. Makes sense. Thanks for the explanation.
| |
| 2235 if (!extension->is_app()) { | |
| 2236 if (extension_prefs_->GetAppLaunchIndex(extension->id()) != -1) | |
| 2237 extension_prefs_->SetAppLaunchIndex(extension->id(), -1); | |
| 2238 if (extension_prefs_->GetPageIndex(extension->id()) != -1) | |
| 2239 extension_prefs_->SetPageIndex(extension->id(), -1); | |
| 2240 } | |
| 2241 | |
| 2233 extensions_.push_back(scoped_extension); | 2242 extensions_.push_back(scoped_extension); |
| 2234 SyncExtensionChangeIfNeeded(*extension); | 2243 SyncExtensionChangeIfNeeded(*extension); |
| 2235 NotifyExtensionLoaded(extension); | 2244 NotifyExtensionLoaded(extension); |
| 2236 } | 2245 } |
| 2237 | 2246 |
| 2238 void ExtensionService::InitializePermissions(const Extension* extension) { | 2247 void ExtensionService::InitializePermissions(const Extension* extension) { |
| 2239 // If the extension has used the optional permissions API, it will have a | 2248 // If the extension has used the optional permissions API, it will have a |
| 2240 // custom set of active permissions defined in the extension prefs. Here, | 2249 // custom set of active permissions defined in the extension prefs. Here, |
| 2241 // we update the extension's active permissions based on the prefs. | 2250 // we update the extension's active permissions based on the prefs. |
| 2242 scoped_refptr<ExtensionPermissionSet> active_permissions = | 2251 scoped_refptr<ExtensionPermissionSet> active_permissions = |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2356 // first. | 2365 // first. |
| 2357 if (show_extensions_prompts_ && prompt_for_plugins && | 2366 if (show_extensions_prompts_ && prompt_for_plugins && |
| 2358 !extension->plugins().empty() && | 2367 !extension->plugins().empty() && |
| 2359 disabled_extension_paths_.find(extension->id()) == | 2368 disabled_extension_paths_.find(extension->id()) == |
| 2360 disabled_extension_paths_.end()) { | 2369 disabled_extension_paths_.end()) { |
| 2361 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( | 2370 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( |
| 2362 profile_, weak_ptr_factory_.GetWeakPtr(), extension); | 2371 profile_, weak_ptr_factory_.GetWeakPtr(), extension); |
| 2363 prompt->ShowPrompt(); | 2372 prompt->ShowPrompt(); |
| 2364 return; // continues in SimpleExtensionLoadPrompt::InstallUI* | 2373 return; // continues in SimpleExtensionLoadPrompt::InstallUI* |
| 2365 } | 2374 } |
| 2366 OnExtensionInstalled(extension, false, 0); // Not from web store. | 2375 OnExtensionInstalled(extension, false, -1); // Not from web store. |
| 2367 } | 2376 } |
| 2368 | 2377 |
| 2369 void ExtensionService::OnExtensionInstalled( | 2378 void ExtensionService::OnExtensionInstalled( |
| 2370 const Extension* extension, bool from_webstore, int page_index) { | 2379 const Extension* extension, bool from_webstore, int page_index) { |
| 2371 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2380 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2372 | 2381 |
| 2373 // Ensure extension is deleted unless we transfer ownership. | 2382 // Ensure extension is deleted unless we transfer ownership. |
| 2374 scoped_refptr<const Extension> scoped_extension(extension); | 2383 scoped_refptr<const Extension> scoped_extension(extension); |
| 2375 const std::string& id = extension->id(); | 2384 const std::string& id = extension->id(); |
| 2376 // Extensions installed by policy can't be disabled. So even if a previous | 2385 // Extensions installed by policy can't be disabled. So even if a previous |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2812 | 2821 |
| 2813 ExtensionService::NaClModuleInfoList::iterator | 2822 ExtensionService::NaClModuleInfoList::iterator |
| 2814 ExtensionService::FindNaClModule(const GURL& url) { | 2823 ExtensionService::FindNaClModule(const GURL& url) { |
| 2815 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2824 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2816 iter != nacl_module_list_.end(); ++iter) { | 2825 iter != nacl_module_list_.end(); ++iter) { |
| 2817 if (iter->url == url) | 2826 if (iter->url == url) |
| 2818 return iter; | 2827 return iter; |
| 2819 } | 2828 } |
| 2820 return nacl_module_list_.end(); | 2829 return nacl_module_list_.end(); |
| 2821 } | 2830 } |
| OLD | NEW |