OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 // TODO(erikkay) this should probably be deferred to a future point | 135 // TODO(erikkay) this should probably be deferred to a future point |
136 // rather than running immediately at startup. | 136 // rather than running immediately at startup. |
137 CheckForExternalUpdates(); | 137 CheckForExternalUpdates(); |
138 | 138 |
139 // TODO(erikkay) this should probably be deferred as well. | 139 // TODO(erikkay) this should probably be deferred as well. |
140 GarbageCollectExtensions(); | 140 GarbageCollectExtensions(); |
141 } | 141 } |
142 | 142 |
143 std::vector<ExtensionAction*> ExtensionsService::GetPageActions() const { | 143 std::vector<ExtensionAction*> ExtensionsService::GetPageActions() const { |
144 return GetExtensionActions(ExtensionAction::PAGE_ACTION, true); | 144 std::vector<ExtensionAction*> result; |
145 } | |
146 | 145 |
147 std::vector<ExtensionAction*> ExtensionsService::GetBrowserActions( | 146 // TODO(finnur): Sort the icons in some meaningful way. |
148 bool include_popups) const { | 147 for (ExtensionList::const_iterator iter = extensions_.begin(); |
149 return GetExtensionActions(ExtensionAction::BROWSER_ACTION, include_popups); | 148 iter != extensions_.end(); ++iter) { |
| 149 if ((*iter)->page_action()) |
| 150 result.push_back((*iter)->page_action()); |
| 151 } |
| 152 |
| 153 return result; |
150 } | 154 } |
151 | 155 |
152 void ExtensionsService::InstallExtension(const FilePath& extension_path) { | 156 void ExtensionsService::InstallExtension(const FilePath& extension_path) { |
153 CrxInstaller::Start(extension_path, install_directory_, Extension::INTERNAL, | 157 CrxInstaller::Start(extension_path, install_directory_, Extension::INTERNAL, |
154 "", // no expected id | 158 "", // no expected id |
155 false, // don't delete crx when complete | 159 false, // don't delete crx when complete |
156 true, // allow privilege increase | 160 true, // allow privilege increase |
157 backend_loop_, | 161 backend_loop_, |
158 this, | 162 this, |
159 NULL); // no client (silent install) | 163 NULL); // no client (silent install) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 profile_->GetRequestContext()); | 360 profile_->GetRequestContext()); |
357 if (context) { | 361 if (context) { |
358 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 362 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
359 NewRunnableMethod(context, | 363 NewRunnableMethod(context, |
360 &ChromeURLRequestContext::OnUnloadedExtension, | 364 &ChromeURLRequestContext::OnUnloadedExtension, |
361 extension->id())); | 365 extension->id())); |
362 } | 366 } |
363 } | 367 } |
364 } | 368 } |
365 | 369 |
366 std::vector<ExtensionAction*> ExtensionsService::GetExtensionActions( | |
367 ExtensionAction::ExtensionActionType action_type, | |
368 bool include_popups) const { | |
369 std::vector<ExtensionAction*> result; | |
370 | |
371 // TODO(finnur): Sort the icons in some meaningful way. | |
372 for (ExtensionList::const_iterator iter = extensions_.begin(); | |
373 iter != extensions_.end(); ++iter) { | |
374 if (action_type == ExtensionAction::PAGE_ACTION) { | |
375 ExtensionAction* page_action = (*iter)->page_action(); | |
376 if (page_action && (include_popups || !page_action->is_popup())) { | |
377 result.push_back(page_action); | |
378 } | |
379 } else { | |
380 ExtensionAction* browser_action = (*iter)->browser_action(); | |
381 if (browser_action && (include_popups || !browser_action->is_popup())) | |
382 result.push_back(browser_action); | |
383 } | |
384 } | |
385 | |
386 return result; | |
387 } | |
388 | |
389 void ExtensionsService::UpdateExtensionBlacklist( | 370 void ExtensionsService::UpdateExtensionBlacklist( |
390 const std::vector<std::string>& blacklist) { | 371 const std::vector<std::string>& blacklist) { |
391 // Use this set to indicate if an extension in the blacklist has been used. | 372 // Use this set to indicate if an extension in the blacklist has been used. |
392 std::set<std::string> blacklist_set; | 373 std::set<std::string> blacklist_set; |
393 for (unsigned int i = 0; i < blacklist.size(); ++i) { | 374 for (unsigned int i = 0; i < blacklist.size(); ++i) { |
394 if (Extension::IdIsValid(blacklist[i])) { | 375 if (Extension::IdIsValid(blacklist[i])) { |
395 blacklist_set.insert(blacklist[i]); | 376 blacklist_set.insert(blacklist[i]); |
396 } | 377 } |
397 } | 378 } |
398 extension_prefs_->UpdateBlacklist(blacklist_set); | 379 extension_prefs_->UpdateBlacklist(blacklist_set); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 linked_ptr<ExternalExtensionProvider>(test_provider); | 822 linked_ptr<ExternalExtensionProvider>(test_provider); |
842 } | 823 } |
843 | 824 |
844 void ExtensionsServiceBackend::OnExternalExtensionFound( | 825 void ExtensionsServiceBackend::OnExternalExtensionFound( |
845 const std::string& id, const Version* version, const FilePath& path, | 826 const std::string& id, const Version* version, const FilePath& path, |
846 Extension::Location location) { | 827 Extension::Location location) { |
847 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, | 828 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, |
848 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), | 829 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), |
849 path, location)); | 830 path, location)); |
850 } | 831 } |
OLD | NEW |