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

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

Issue 22185002: Add browser test to the sharing dialog feature in Files.app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added the licence header. Created 7 years, 4 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/drive/fake_drive_service.h" 5 #include "chrome/browser/drive/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 using google_apis::ResourceEntry; 55 using google_apis::ResourceEntry;
56 using google_apis::ResourceList; 56 using google_apis::ResourceList;
57 using google_apis::UploadRangeCallback; 57 using google_apis::UploadRangeCallback;
58 using google_apis::UploadRangeResponse; 58 using google_apis::UploadRangeResponse;
59 namespace test_util = google_apis::test_util; 59 namespace test_util = google_apis::test_util;
60 namespace util = google_apis::util; 60 namespace util = google_apis::util;
61 61
62 namespace drive { 62 namespace drive {
63 namespace { 63 namespace {
64 64
65 // Rel property of upload link in the entries dictionary value. 65 // Rel property of an upload link in the entries dictionary value.
66 const char kUploadUrlRel[] = 66 const char kUploadUrlRel[] =
67 "http://schemas.google.com/g/2005#resumable-create-media"; 67 "http://schemas.google.com/g/2005#resumable-create-media";
68 68
69 // Rel property of a share link in the entries dictionary value.
70 const char kShareUrlRel[] =
71 "http://schemas.google.com/docs/2007#share";
72
69 // Returns true if a resource entry matches with the search query. 73 // Returns true if a resource entry matches with the search query.
70 // Supports queries consist of following format. 74 // Supports queries consist of following format.
71 // - Phrases quoted by double/single quotes 75 // - Phrases quoted by double/single quotes
72 // - AND search for multiple words/phrases segmented by space 76 // - AND search for multiple words/phrases segmented by space
73 // - Limited attribute search. Only "title:" is supported. 77 // - Limited attribute search. Only "title:" is supported.
74 bool EntryMatchWithQuery(const ResourceEntry& entry, 78 bool EntryMatchWithQuery(const ResourceEntry& entry,
75 const std::string& query) { 79 const std::string& query) {
76 base::StringTokenizer tokenizer(query, " "); 80 base::StringTokenizer tokenizer(query, " ");
77 tokenizer.set_quote_chars("\"'"); 81 tokenizer.set_quote_chars("\"'");
78 while (tokenizer.GetNext()) { 82 while (tokenizer.GetNext()) {
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 1386
1383 base::DictionaryValue* edit_link = new base::DictionaryValue; 1387 base::DictionaryValue* edit_link = new base::DictionaryValue;
1384 edit_link->SetString("href", "https://xxx/edit/" + escaped_resource_id); 1388 edit_link->SetString("href", "https://xxx/edit/" + escaped_resource_id);
1385 edit_link->SetString("rel", "edit"); 1389 edit_link->SetString("rel", "edit");
1386 links->Append(edit_link); 1390 links->Append(edit_link);
1387 1391
1388 base::DictionaryValue* upload_link = new base::DictionaryValue; 1392 base::DictionaryValue* upload_link = new base::DictionaryValue;
1389 upload_link->SetString("href", upload_url.spec()); 1393 upload_link->SetString("href", upload_url.spec());
1390 upload_link->SetString("rel", kUploadUrlRel); 1394 upload_link->SetString("rel", kUploadUrlRel);
1391 links->Append(upload_link); 1395 links->Append(upload_link);
1396
1397 const GURL share_url = net::AppendOrReplaceQueryParameter(
1398 share_url_base_, "name", title);
1399 base::DictionaryValue* share_link = new base::DictionaryValue;
1400 upload_link->SetString("href", share_url.spec());
1401 upload_link->SetString("rel", kShareUrlRel);
1402 links->Append(share_link);
1392 new_entry->Set("link", links); 1403 new_entry->Set("link", links);
1393 1404
1394 AddNewChangestampAndETag(new_entry.get()); 1405 AddNewChangestampAndETag(new_entry.get());
1395 1406
1396 base::Time published_date = 1407 base::Time published_date =
1397 base::Time() + base::TimeDelta::FromMilliseconds(++published_date_seq_); 1408 base::Time() + base::TimeDelta::FromMilliseconds(++published_date_seq_);
1398 new_entry->SetString("published.$t", 1409 new_entry->SetString("published.$t",
1399 util::FormatTimeAsString(published_date)); 1410 util::FormatTimeAsString(published_date));
1400 1411
1401 // If there are no entries, prepare an empty entry to add. 1412 // If there are no entries, prepare an empty entry to add.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 FROM_HERE, 1544 FROM_HERE,
1534 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_list))); 1545 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_list)));
1535 } 1546 }
1536 1547
1537 GURL FakeDriveService::GetNewUploadSessionUrl() { 1548 GURL FakeDriveService::GetNewUploadSessionUrl() {
1538 return GURL("https://upload_session_url/" + 1549 return GURL("https://upload_session_url/" +
1539 base::Int64ToString(next_upload_sequence_number_++)); 1550 base::Int64ToString(next_upload_sequence_number_++));
1540 } 1551 }
1541 1552
1542 } // namespace drive 1553 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/drive/fake_drive_service.h ('k') | chrome/browser/resources/file_manager/js/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698