| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { | 195 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { |
| 196 } | 196 } |
| 197 | 197 |
| 198 void SimpleExtensionLoadPrompt::ShowPrompt() { | 198 void SimpleExtensionLoadPrompt::ShowPrompt() { |
| 199 install_ui_->ConfirmInstall(this, extension_); | 199 install_ui_->ConfirmInstall(this, extension_); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void SimpleExtensionLoadPrompt::InstallUIProceed() { | 202 void SimpleExtensionLoadPrompt::InstallUIProceed() { |
| 203 if (extension_service_.get()) | 203 if (extension_service_.get()) |
| 204 extension_service_->OnExtensionInstalled( | 204 extension_service_->OnExtensionInstalled( |
| 205 extension_, false, -1); // Not from web store. | 205 extension_, false, extension_misc::kUnsetIndex); // Not from web store. |
| 206 delete this; | 206 delete this; |
| 207 } | 207 } |
| 208 | 208 |
| 209 void SimpleExtensionLoadPrompt::InstallUIAbort(bool user_initiated) { | 209 void SimpleExtensionLoadPrompt::InstallUIAbort(bool user_initiated) { |
| 210 delete this; | 210 delete this; |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace | 213 } // namespace |
| 214 | 214 |
| 215 bool ExtensionService::ComponentExtensionInfo::Equals( | 215 bool ExtensionService::ComponentExtensionInfo::Equals( |
| (...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 // disabled. | 2288 // disabled. |
| 2289 NotificationService::current()->Notify( | 2289 NotificationService::current()->Notify( |
| 2290 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 2290 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 2291 Source<Profile>(profile_), | 2291 Source<Profile>(profile_), |
| 2292 Details<const Extension>(extension)); | 2292 Details<const Extension>(extension)); |
| 2293 SyncExtensionChangeIfNeeded(*extension); | 2293 SyncExtensionChangeIfNeeded(*extension); |
| 2294 return; | 2294 return; |
| 2295 } | 2295 } |
| 2296 | 2296 |
| 2297 // Unfortunately, we used to set app launcher indices for non-apps. If this | 2297 // Unfortunately, we used to set app launcher indices for non-apps. If this |
| 2298 // extension has an index (page or in-page), set it to -1. | 2298 // extension has an index (page or in-page), set it to kUnsetIndex. |
| 2299 if (!extension->is_app()) { | 2299 if (!extension->is_app()) { |
| 2300 if (extension_prefs_->GetAppLaunchIndex(extension->id()) != -1) | 2300 if (extension_prefs_->GetAppLaunchIndex( |
| 2301 extension_prefs_->SetAppLaunchIndex(extension->id(), -1); | 2301 extension->id()).compare(extension_misc::kUnsetIndex) != 0) |
| 2302 if (extension_prefs_->GetPageIndex(extension->id()) != -1) | 2302 extension_prefs_->SetAppLaunchIndex(extension->id(), |
| 2303 extension_prefs_->SetPageIndex(extension->id(), -1); | 2303 extension_misc::kUnsetIndex); |
| 2304 if (extension_prefs_->GetPageIndex( |
| 2305 extension->id()).compare(extension_misc::kUnsetIndex) != 0) |
| 2306 extension_prefs_->SetPageIndex(extension->id(), |
| 2307 extension_misc::kUnsetIndex); |
| 2304 } | 2308 } |
| 2305 | 2309 |
| 2306 extensions_.push_back(scoped_extension); | 2310 extensions_.push_back(scoped_extension); |
| 2307 SyncExtensionChangeIfNeeded(*extension); | 2311 SyncExtensionChangeIfNeeded(*extension); |
| 2308 NotifyExtensionLoaded(extension); | 2312 NotifyExtensionLoaded(extension); |
| 2309 } | 2313 } |
| 2310 | 2314 |
| 2311 void ExtensionService::InitializePermissions(const Extension* extension) { | 2315 void ExtensionService::InitializePermissions(const Extension* extension) { |
| 2312 // If the extension has used the optional permissions API, it will have a | 2316 // If the extension has used the optional permissions API, it will have a |
| 2313 // custom set of active permissions defined in the extension prefs. Here, | 2317 // custom set of active permissions defined in the extension prefs. Here, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2429 // first. | 2433 // first. |
| 2430 if (show_extensions_prompts_ && prompt_for_plugins && | 2434 if (show_extensions_prompts_ && prompt_for_plugins && |
| 2431 !extension->plugins().empty() && | 2435 !extension->plugins().empty() && |
| 2432 disabled_extension_paths_.find(extension->id()) == | 2436 disabled_extension_paths_.find(extension->id()) == |
| 2433 disabled_extension_paths_.end()) { | 2437 disabled_extension_paths_.end()) { |
| 2434 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( | 2438 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( |
| 2435 profile_, weak_ptr_factory_.GetWeakPtr(), extension); | 2439 profile_, weak_ptr_factory_.GetWeakPtr(), extension); |
| 2436 prompt->ShowPrompt(); | 2440 prompt->ShowPrompt(); |
| 2437 return; // continues in SimpleExtensionLoadPrompt::InstallUI* | 2441 return; // continues in SimpleExtensionLoadPrompt::InstallUI* |
| 2438 } | 2442 } |
| 2439 OnExtensionInstalled(extension, false, -1); // Not from web store. | 2443 |
| 2444 // Not from web store. |
| 2445 OnExtensionInstalled(extension, false, extension_misc::kUnsetIndex); |
| 2440 } | 2446 } |
| 2441 | 2447 |
| 2442 void ExtensionService::OnExtensionInstalled( | 2448 void ExtensionService::OnExtensionInstalled( |
| 2443 const Extension* extension, bool from_webstore, int page_index) { | 2449 const Extension* extension, bool from_webstore, std::string page_index) { |
| 2444 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2450 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2445 | 2451 |
| 2446 // Ensure extension is deleted unless we transfer ownership. | 2452 // Ensure extension is deleted unless we transfer ownership. |
| 2447 scoped_refptr<const Extension> scoped_extension(extension); | 2453 scoped_refptr<const Extension> scoped_extension(extension); |
| 2448 const std::string& id = extension->id(); | 2454 const std::string& id = extension->id(); |
| 2449 // Extensions installed by policy can't be disabled. So even if a previous | 2455 // Extensions installed by policy can't be disabled. So even if a previous |
| 2450 // installation disabled the extension, make sure it is now enabled. | 2456 // installation disabled the extension, make sure it is now enabled. |
| 2451 bool initial_enable = | 2457 bool initial_enable = |
| 2452 !extension_prefs_->IsExtensionDisabled(id) || | 2458 !extension_prefs_->IsExtensionDisabled(id) || |
| 2453 !Extension::UserMayDisable(extension->location()); | 2459 !Extension::UserMayDisable(extension->location()); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2900 | 2906 |
| 2901 ExtensionService::NaClModuleInfoList::iterator | 2907 ExtensionService::NaClModuleInfoList::iterator |
| 2902 ExtensionService::FindNaClModule(const GURL& url) { | 2908 ExtensionService::FindNaClModule(const GURL& url) { |
| 2903 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2909 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2904 iter != nacl_module_list_.end(); ++iter) { | 2910 iter != nacl_module_list_.end(); ++iter) { |
| 2905 if (iter->url == url) | 2911 if (iter->url == url) |
| 2906 return iter; | 2912 return iter; |
| 2907 } | 2913 } |
| 2908 return nacl_module_list_.end(); | 2914 return nacl_module_list_.end(); |
| 2909 } | 2915 } |
| OLD | NEW |