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 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 global_error->ShowBubbleView(browser); | 1727 global_error->ShowBubbleView(browser); |
1728 } | 1728 } |
1729 } | 1729 } |
1730 | 1730 |
1731 void ExtensionService::HandleExtensionAlertAccept( | 1731 void ExtensionService::HandleExtensionAlertAccept( |
1732 const ExtensionGlobalError& global_error, Browser* browser) { | 1732 const ExtensionGlobalError& global_error, Browser* browser) { |
1733 const ExtensionIdSet *extension_ids = | 1733 const ExtensionIdSet *extension_ids = |
1734 global_error.get_external_extension_ids(); | 1734 global_error.get_external_extension_ids(); |
1735 for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); | 1735 for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); |
1736 iter != extension_ids->end(); ++iter) { | 1736 iter != extension_ids->end(); ++iter) { |
1737 extension_prefs_->AcknowledgeExternalExtension(*iter); | 1737 AcknowledgeExternalExtension(*iter); |
1738 } | 1738 } |
1739 extension_ids = global_error.get_blacklisted_extension_ids(); | 1739 extension_ids = global_error.get_blacklisted_extension_ids(); |
1740 for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); | 1740 for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); |
1741 iter != extension_ids->end(); ++iter) { | 1741 iter != extension_ids->end(); ++iter) { |
1742 extension_prefs_->AcknowledgeBlacklistedExtension(*iter); | 1742 extension_prefs_->AcknowledgeBlacklistedExtension(*iter); |
1743 } | 1743 } |
1744 extension_ids = global_error.get_orphaned_extension_ids(); | 1744 extension_ids = global_error.get_orphaned_extension_ids(); |
1745 for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); | 1745 for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); |
1746 iter != extension_ids->end(); ++iter) { | 1746 iter != extension_ids->end(); ++iter) { |
1747 extension_prefs_->AcknowledgeOrphanedExtension(*iter); | 1747 extension_prefs_->AcknowledgeOrphanedExtension(*iter); |
1748 } | 1748 } |
1749 } | 1749 } |
1750 | 1750 |
| 1751 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) { |
| 1752 extension_prefs_->AcknowledgeExternalExtension(id); |
| 1753 } |
| 1754 |
1751 void ExtensionService::HandleExtensionAlertDetails( | 1755 void ExtensionService::HandleExtensionAlertDetails( |
1752 const ExtensionGlobalError& global_error, Browser* browser) { | 1756 const ExtensionGlobalError& global_error, Browser* browser) { |
1753 if (browser) { | 1757 if (browser) { |
1754 browser->ShowExtensionsTab(); | 1758 browser->ShowExtensionsTab(); |
1755 } | 1759 } |
1756 } | 1760 } |
1757 | 1761 |
1758 void ExtensionService::UnloadExtension( | 1762 void ExtensionService::UnloadExtension( |
1759 const std::string& extension_id, | 1763 const std::string& extension_id, |
1760 extension_misc::UnloadedExtensionReason reason) { | 1764 extension_misc::UnloadedExtensionReason reason) { |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 const SkBitmap& ExtensionService::GetOmniboxPopupIcon( | 2237 const SkBitmap& ExtensionService::GetOmniboxPopupIcon( |
2234 const std::string& extension_id) { | 2238 const std::string& extension_id) { |
2235 return omnibox_popup_icon_manager_.GetIcon(extension_id); | 2239 return omnibox_popup_icon_manager_.GetIcon(extension_id); |
2236 } | 2240 } |
2237 | 2241 |
2238 void ExtensionService::OnExternalExtensionFileFound( | 2242 void ExtensionService::OnExternalExtensionFileFound( |
2239 const std::string& id, | 2243 const std::string& id, |
2240 const Version* version, | 2244 const Version* version, |
2241 const FilePath& path, | 2245 const FilePath& path, |
2242 Extension::Location location, | 2246 Extension::Location location, |
2243 int creation_flags) { | 2247 int creation_flags, |
| 2248 bool mark_acknowledged) { |
2244 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2249 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2245 CHECK(Extension::IdIsValid(id)); | 2250 CHECK(Extension::IdIsValid(id)); |
2246 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2251 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
2247 return; | 2252 return; |
2248 | 2253 |
2249 DCHECK(version); | 2254 DCHECK(version); |
2250 | 2255 |
2251 // Before even bothering to unpack, check and see if we already have this | 2256 // Before even bothering to unpack, check and see if we already have this |
2252 // version. This is important because these extensions are going to get | 2257 // version. This is important because these extensions are going to get |
2253 // installed on every startup. | 2258 // installed on every startup. |
(...skipping 16 matching lines...) Expand all Loading... |
2270 pending_extension_manager()->AddFromExternalFile(id, location); | 2275 pending_extension_manager()->AddFromExternalFile(id, location); |
2271 | 2276 |
2272 // no client (silent install) | 2277 // no client (silent install) |
2273 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, NULL)); | 2278 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, NULL)); |
2274 installer->set_install_source(location); | 2279 installer->set_install_source(location); |
2275 installer->set_expected_id(id); | 2280 installer->set_expected_id(id); |
2276 installer->set_expected_version(*version); | 2281 installer->set_expected_version(*version); |
2277 installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE); | 2282 installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE); |
2278 installer->set_creation_flags(creation_flags); | 2283 installer->set_creation_flags(creation_flags); |
2279 installer->InstallCrx(path); | 2284 installer->InstallCrx(path); |
| 2285 |
| 2286 // Depending on the source, a new external extension might not need a user |
| 2287 // notification on installation. For such extensions, mark them acknowledged |
| 2288 // now to suppress the notification. |
| 2289 if (mark_acknowledged) |
| 2290 AcknowledgeExternalExtension(id); |
2280 } | 2291 } |
2281 | 2292 |
2282 void ExtensionService::ReportExtensionLoadError( | 2293 void ExtensionService::ReportExtensionLoadError( |
2283 const FilePath& extension_path, | 2294 const FilePath& extension_path, |
2284 const std::string &error, | 2295 const std::string &error, |
2285 bool be_noisy) { | 2296 bool be_noisy) { |
2286 content::NotificationService::current()->Notify( | 2297 content::NotificationService::current()->Notify( |
2287 chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, | 2298 chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, |
2288 content::Source<Profile>(profile_), | 2299 content::Source<Profile>(profile_), |
2289 content::Details<const std::string>(&error)); | 2300 content::Details<const std::string>(&error)); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 | 2530 |
2520 ExtensionService::NaClModuleInfoList::iterator | 2531 ExtensionService::NaClModuleInfoList::iterator |
2521 ExtensionService::FindNaClModule(const GURL& url) { | 2532 ExtensionService::FindNaClModule(const GURL& url) { |
2522 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2533 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
2523 iter != nacl_module_list_.end(); ++iter) { | 2534 iter != nacl_module_list_.end(); ++iter) { |
2524 if (iter->url == url) | 2535 if (iter->url == url) |
2525 return iter; | 2536 return iter; |
2526 } | 2537 } |
2527 return nacl_module_list_.end(); | 2538 return nacl_module_list_.end(); |
2528 } | 2539 } |
OLD | NEW |