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

Unified Diff: chrome/browser/drive/fake_drive_service.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/fake_drive_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/fake_drive_service.cc
diff --git a/chrome/browser/drive/fake_drive_service.cc b/chrome/browser/drive/fake_drive_service.cc
index 4829145ee10a6e8b6f521691294f5bab6ab92204..c7638950ba39c0c2139af539eb8c7cd9dc1bc2fe 100644
--- a/chrome/browser/drive/fake_drive_service.cc
+++ b/chrome/browser/drive/fake_drive_service.cc
@@ -267,7 +267,12 @@ bool FakeDriveService::LoadAccountMetadataForWapi(
bool FakeDriveService::LoadAppListForDriveApi(
const std::string& relative_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- app_info_value_ = test_util::LoadJSONFile(relative_path);
+
+ // Load JSON data, which must be a dictionary.
+ scoped_ptr<base::Value> value = test_util::LoadJSONFile(relative_path);
+ CHECK_EQ(base::Value::TYPE_DICTIONARY, value->GetType());
+ app_info_value_.reset(
+ static_cast<base::DictionaryValue*>(value.release()));
return app_info_value_;
}
@@ -1261,6 +1266,29 @@ CancelCallback FakeDriveService::UninstallApp(
const google_apis::EntryActionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
+
+ // Find app_id from app_info_value_ and delete.
+ google_apis::GDataErrorCode error = google_apis::HTTP_NOT_FOUND;
+ if (offline_) {
+ error = google_apis::GDATA_NO_CONNECTION;
+ } else {
+ base::ListValue* items = NULL;
+ if (app_info_value_->GetList("items", &items)) {
+ for (size_t i = 0; i < items->GetSize(); ++i) {
+ base::DictionaryValue* item = NULL;
+ std::string id;
+ if (items->GetDictionary(i, &item) && item->GetString("id", &id) &&
+ id == app_id) {
+ if (items->Remove(i, NULL))
+ error = google_apis::HTTP_SUCCESS;
+ break;
+ }
+ }
+ }
+ }
+
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(callback, error));
return CancelCallback();
}
« no previous file with comments | « chrome/browser/drive/fake_drive_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698