Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4106)

Unified Diff: chrome/browser/extensions/crx_installer.cc

Issue 3353015: Implement gallery install API (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: erik comments Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/crx_installer.h ('k') | chrome/browser/extensions/extension_apitest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/crx_installer.cc
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index ad4a4cc1bf95dc6893c6a5723b387a0c534e422a..91610599f22ae27b19c5dcb6dcf0885d18351ff7 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -9,6 +9,7 @@
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
+#include "base/singleton.h"
#include "base/task.h"
#include "base/utf_string_conversions.h"
#include "base/version.h"
@@ -31,11 +32,42 @@
#include "third_party/skia/include/core/SkBitmap.h"
namespace {
- // Helper function to delete files. This is used to avoid ugly casts which
- // would be necessary with PostMessage since file_util::Delete is overloaded.
- static void DeleteFileHelper(const FilePath& path, bool recursive) {
- file_util::Delete(path, recursive);
+
+// Helper function to delete files. This is used to avoid ugly casts which
+// would be necessary with PostMessage since file_util::Delete is overloaded.
+static void DeleteFileHelper(const FilePath& path, bool recursive) {
+ file_util::Delete(path, recursive);
+}
+
+struct WhitelistedInstallData {
+ WhitelistedInstallData() {}
+ std::list<std::string> ids;
+};
+
+}
+
+// static
+void CrxInstaller::SetWhitelistedInstallId(const std::string& id) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ Singleton<WhitelistedInstallData>::get()->ids.push_back(id);
+}
+
+// static
+bool CrxInstaller::ClearWhitelistedInstallId(const std::string& id) {
+ std::list<std::string>& ids = Singleton<WhitelistedInstallData>::get()->ids;
+ std::list<std::string>::iterator iter = ids.begin();
+ for (; iter != ids.end(); ++iter) {
+ if (*iter == id) {
+ break;
+ }
}
+
+ if (iter != ids.end()) {
+ ids.erase(iter);
+ return true;
+ }
+
+ return false;
}
CrxInstaller::CrxInstaller(const FilePath& install_directory,
@@ -49,7 +81,8 @@ CrxInstaller::CrxInstaller(const FilePath& install_directory,
create_app_shortcut_(false),
frontend_(frontend),
client_(client),
- apps_require_extension_mime_type_(false) {
+ apps_require_extension_mime_type_(false),
+ allow_silent_install_(false) {
extensions_enabled_ = frontend_->extensions_enabled();
}
@@ -221,7 +254,9 @@ void CrxInstaller::ConfirmInstall() {
current_version_ =
frontend_->extension_prefs()->GetVersionString(extension_->id());
- if (client_) {
+ if (client_ &&
+ (!allow_silent_install_ ||
+ !ClearWhitelistedInstallId(extension_->id()))) {
AddRef(); // Balanced in Proceed() and Abort().
client_->ConfirmInstall(this, extension_.get());
} else {
« no previous file with comments | « chrome/browser/extensions/crx_installer.h ('k') | chrome/browser/extensions/extension_apitest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698