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

Side by Side Diff: chrome/browser/google_apis/fake_drive_service.cc

Issue 13896006: filemanager: Add a browsertest for the sidebar item "Shared with Me". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a merge failure and restore a test case. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/google_apis/fake_drive_service.h" 5 #include "chrome/browser/google_apis/fake_drive_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 GDATA_NO_CONNECTION, 758 GDATA_NO_CONNECTION,
759 base::Passed(&null))); 759 base::Passed(&null)));
760 return; 760 return;
761 } 761 }
762 762
763 const char kContentType[] = "application/atom+xml;type=feed"; 763 const char kContentType[] = "application/atom+xml;type=feed";
764 const base::DictionaryValue* new_entry = AddNewEntry(kContentType, 764 const base::DictionaryValue* new_entry = AddNewEntry(kContentType,
765 0, // content_length 765 0, // content_length
766 parent_resource_id, 766 parent_resource_id,
767 directory_name, 767 directory_name,
768 false, // shared_with_me
768 "folder"); 769 "folder");
769 if (!new_entry) { 770 if (!new_entry) {
770 scoped_ptr<ResourceEntry> null; 771 scoped_ptr<ResourceEntry> null;
771 MessageLoop::current()->PostTask( 772 MessageLoop::current()->PostTask(
772 FROM_HERE, 773 FROM_HERE,
773 base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null))); 774 base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null)));
774 return; 775 return;
775 } 776 }
776 777
777 scoped_ptr<ResourceEntry> parsed_entry(ResourceEntry::CreateFrom(*new_entry)); 778 scoped_ptr<ResourceEntry> parsed_entry(ResourceEntry::CreateFrom(*new_entry));
(...skipping 18 matching lines...) Expand all
796 base::Bind(callback, GDATA_NO_CONNECTION, GURL())); 797 base::Bind(callback, GDATA_NO_CONNECTION, GURL()));
797 return; 798 return;
798 } 799 }
799 800
800 // Content length should be zero, as we'll create an empty file first. The 801 // Content length should be zero, as we'll create an empty file first. The
801 // content will be added in ResumeUpload(). 802 // content will be added in ResumeUpload().
802 const base::DictionaryValue* new_entry = AddNewEntry(content_type, 803 const base::DictionaryValue* new_entry = AddNewEntry(content_type,
803 0, // content_length 804 0, // content_length
804 parent_resource_id, 805 parent_resource_id,
805 title, 806 title,
807 false, // shared_with_me
806 "file"); 808 "file");
807 if (!new_entry) { 809 if (!new_entry) {
808 MessageLoop::current()->PostTask( 810 MessageLoop::current()->PostTask(
809 FROM_HERE, 811 FROM_HERE,
810 base::Bind(callback, HTTP_NOT_FOUND, GURL())); 812 base::Bind(callback, HTTP_NOT_FOUND, GURL()));
811 return; 813 return;
812 } 814 }
813 const GURL upload_url = GetUploadUrl(*new_entry); 815 const GURL upload_url = GetUploadUrl(*new_entry);
814 DCHECK(upload_url.is_valid()); 816 DCHECK(upload_url.is_valid());
815 817
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 const std::string& app_id, 976 const std::string& app_id,
975 const AuthorizeAppCallback& callback) { 977 const AuthorizeAppCallback& callback) {
976 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 978 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
977 DCHECK(!callback.is_null()); 979 DCHECK(!callback.is_null());
978 } 980 }
979 981
980 void FakeDriveService::AddNewFile(const std::string& content_type, 982 void FakeDriveService::AddNewFile(const std::string& content_type,
981 int64 content_length, 983 int64 content_length,
982 const std::string& parent_resource_id, 984 const std::string& parent_resource_id,
983 const std::string& title, 985 const std::string& title,
986 bool shared_with_me,
984 const GetResourceEntryCallback& callback) { 987 const GetResourceEntryCallback& callback) {
985 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
986 DCHECK(!callback.is_null()); 989 DCHECK(!callback.is_null());
987 990
988 if (offline_) { 991 if (offline_) {
989 scoped_ptr<ResourceEntry> null; 992 scoped_ptr<ResourceEntry> null;
990 MessageLoop::current()->PostTask( 993 MessageLoop::current()->PostTask(
991 FROM_HERE, 994 FROM_HERE,
992 base::Bind(callback, 995 base::Bind(callback,
993 GDATA_NO_CONNECTION, 996 GDATA_NO_CONNECTION,
994 base::Passed(&null))); 997 base::Passed(&null)));
995 return; 998 return;
996 } 999 }
997 1000
998 // Prepare "kind" for hosted documents. This only supports Google Document. 1001 // Prepare "kind" for hosted documents. This only supports Google Document.
999 std::string entry_kind; 1002 std::string entry_kind;
1000 if (content_type == "application/vnd.google-apps.document") 1003 if (content_type == "application/vnd.google-apps.document")
1001 entry_kind = "document"; 1004 entry_kind = "document";
1002 else 1005 else
1003 entry_kind = "file"; 1006 entry_kind = "file";
1004 1007
1005 const base::DictionaryValue* new_entry = AddNewEntry(content_type, 1008 const base::DictionaryValue* new_entry = AddNewEntry(content_type,
1006 content_length, 1009 content_length,
1007 parent_resource_id, 1010 parent_resource_id,
1008 title, 1011 title,
1012 shared_with_me,
1009 entry_kind); 1013 entry_kind);
1010 if (!new_entry) { 1014 if (!new_entry) {
1011 scoped_ptr<ResourceEntry> null; 1015 scoped_ptr<ResourceEntry> null;
1012 MessageLoop::current()->PostTask( 1016 MessageLoop::current()->PostTask(
1013 FROM_HERE, 1017 FROM_HERE,
1014 base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null))); 1018 base::Bind(callback, HTTP_NOT_FOUND, base::Passed(&null)));
1015 return; 1019 return;
1016 } 1020 }
1017 1021
1018 scoped_ptr<ResourceEntry> parsed_entry( 1022 scoped_ptr<ResourceEntry> parsed_entry(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 ++largest_changestamp_; 1154 ++largest_changestamp_;
1151 entry->SetString("docs$changestamp.value", 1155 entry->SetString("docs$changestamp.value",
1152 base::Int64ToString(largest_changestamp_)); 1156 base::Int64ToString(largest_changestamp_));
1153 } 1157 }
1154 1158
1155 const base::DictionaryValue* FakeDriveService::AddNewEntry( 1159 const base::DictionaryValue* FakeDriveService::AddNewEntry(
1156 const std::string& content_type, 1160 const std::string& content_type,
1157 int64 content_length, 1161 int64 content_length,
1158 const std::string& parent_resource_id, 1162 const std::string& parent_resource_id,
1159 const std::string& title, 1163 const std::string& title,
1164 bool shared_with_me,
1160 const std::string& entry_kind) { 1165 const std::string& entry_kind) {
1161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1162 1167
1163 if (parent_resource_id != GetRootResourceId() && 1168 if (parent_resource_id != GetRootResourceId() &&
1164 !FindEntryByResourceId(parent_resource_id)) { 1169 !FindEntryByResourceId(parent_resource_id)) {
1165 return NULL; 1170 return NULL;
1166 } 1171 }
1167 1172
1168 base::DictionaryValue* resource_list_dict = NULL; 1173 base::DictionaryValue* resource_list_dict = NULL;
1169 if (!resource_list_value_->GetAsDictionary(&resource_list_dict)) 1174 if (!resource_list_value_->GetAsDictionary(&resource_list_dict))
(...skipping 16 matching lines...) Expand all
1186 } 1191 }
1187 1192
1188 // Add "category" which sets the resource type to |entry_kind|. 1193 // Add "category" which sets the resource type to |entry_kind|.
1189 base::ListValue* categories = new base::ListValue; 1194 base::ListValue* categories = new base::ListValue;
1190 base::DictionaryValue* category = new base::DictionaryValue; 1195 base::DictionaryValue* category = new base::DictionaryValue;
1191 category->SetString("scheme", "http://schemas.google.com/g/2005#kind"); 1196 category->SetString("scheme", "http://schemas.google.com/g/2005#kind");
1192 category->SetString("term", "http://schemas.google.com/docs/2007#" + 1197 category->SetString("term", "http://schemas.google.com/docs/2007#" +
1193 entry_kind); 1198 entry_kind);
1194 categories->Append(category); 1199 categories->Append(category);
1195 new_entry->Set("category", categories); 1200 new_entry->Set("category", categories);
1201 if (shared_with_me) {
1202 base::DictionaryValue* shared_with_me_label = new base::DictionaryValue;
1203 shared_with_me_label->SetString("label", "shared-with-me");
1204 shared_with_me_label->SetString("scheme",
1205 "http://schemas.google.com/g/2005/labels");
1206 shared_with_me_label->SetString(
1207 "term", "http://schemas.google.com/g/2005/labels#shared");
1208 categories->Append(shared_with_me_label);
1209 }
1196 1210
1197 // Add "content" which sets the content URL. 1211 // Add "content" which sets the content URL.
1198 base::DictionaryValue* content = new base::DictionaryValue; 1212 base::DictionaryValue* content = new base::DictionaryValue;
1199 content->SetString("src", "https://xxx/content/" + resource_id); 1213 content->SetString("src", "https://xxx/content/" + resource_id);
1200 content->SetString("type", content_type); 1214 content->SetString("type", content_type);
1201 new_entry->Set("content", content); 1215 new_entry->Set("content", content);
1202 1216
1203 // Add "link" which sets the parent URL, the edit URL and the upload URL. 1217 // Add "link" which sets the parent URL, the edit URL and the upload URL.
1204 base::ListValue* links = new base::ListValue; 1218 base::ListValue* links = new base::ListValue;
1205 1219
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 1357
1344 ++resource_list_load_count_; 1358 ++resource_list_load_count_;
1345 MessageLoop::current()->PostTask( 1359 MessageLoop::current()->PostTask(
1346 FROM_HERE, 1360 FROM_HERE,
1347 base::Bind(callback, 1361 base::Bind(callback,
1348 HTTP_SUCCESS, 1362 HTTP_SUCCESS,
1349 base::Passed(&resource_list))); 1363 base::Passed(&resource_list)));
1350 } 1364 }
1351 1365
1352 } // namespace google_apis 1366 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/fake_drive_service.h ('k') | chrome/browser/google_apis/fake_drive_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698