| 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,
|
|
|