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

Unified Diff: chrome/browser/drive/drive_app_registry.cc

Issue 133123004: Implement DriveAppRegistry::UninstallApp() and GetAppList(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix after revert Created 6 years, 11 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/drive/drive_app_registry.h ('k') | chrome/browser/drive/drive_app_registry_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/drive_app_registry.cc
diff --git a/chrome/browser/drive/drive_app_registry.cc b/chrome/browser/drive/drive_app_registry.cc
index 2c8661e7db96c6f29a2e926604b8179455331ec7..aed8ab14c0abcf553c21523cd3bb317b132f8cbd 100644
--- a/chrome/browser/drive/drive_app_registry.cc
+++ b/chrome/browser/drive/drive_app_registry.cc
@@ -8,6 +8,7 @@
#include <set>
#include <utility>
+#include "base/callback.h"
#include "base/files/file_path.h"
#include "chrome/browser/drive/drive_service_interface.h"
#include "content/public/browser/browser_thread.h"
@@ -35,6 +36,16 @@ void FindAppsForSelector(const std::string& selector,
matched_apps->push_back(it->second);
}
+void RemoveAppFromSelector(const std::string& app_id,
+ std::multimap<std::string, std::string>* map) {
+ typedef std::multimap<std::string, std::string>::iterator iterator;
+ for (iterator it = map->begin(); it != map->end(); ) {
+ iterator now = it++;
+ if (now->second == app_id)
+ map->erase(now);
+ }
+}
+
} // namespace
namespace drive {
@@ -95,6 +106,16 @@ void DriveAppRegistry::GetAppsForFile(
}
}
+void DriveAppRegistry::GetAppList(std::vector<DriveAppInfo>* apps) const {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ apps->clear();
+ for (std::map<std::string, DriveAppInfo>::const_iterator
+ it = all_apps_.begin(); it != all_apps_.end(); ++it) {
+ apps->push_back(it->second);
+ }
+}
+
void DriveAppRegistry::Update() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -160,6 +181,37 @@ void DriveAppRegistry::UpdateFromAppList(const google_apis::AppList& app_list) {
}
}
+void DriveAppRegistry::UninstallApp(const std::string& app_id,
+ const UninstallCallback& callback) {
+ DCHECK(!callback.is_null());
+
+ drive_service_->UninstallApp(app_id,
+ base::Bind(&DriveAppRegistry::OnAppUninstalled,
+ weak_ptr_factory_.GetWeakPtr(),
+ app_id,
+ callback));
+}
+
+void DriveAppRegistry::OnAppUninstalled(const std::string& app_id,
+ const UninstallCallback& callback,
+ google_apis::GDataErrorCode error) {
+ if (error == google_apis::HTTP_SUCCESS) {
+ all_apps_.erase(app_id);
+ RemoveAppFromSelector(app_id, &mimetype_map_);
+ RemoveAppFromSelector(app_id, &extension_map_);
+ }
+ callback.Run(error);
+}
+
+// static
+bool DriveAppRegistry::IsAppUninstallSupported() {
+#ifdef USE_OFFICIAL_GOOGLE_API_KEYS
+ return true;
+#else
+ return false;
+#endif
+}
+
namespace util {
GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons,
« no previous file with comments | « chrome/browser/drive/drive_app_registry.h ('k') | chrome/browser/drive/drive_app_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698