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

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

Issue 371883003: Files.app: Add an private API to get a download URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
(...skipping 29 matching lines...) Expand all
40 using google_apis::EntryActionCallback; 40 using google_apis::EntryActionCallback;
41 using google_apis::FileList; 41 using google_apis::FileList;
42 using google_apis::FileListCallback; 42 using google_apis::FileListCallback;
43 using google_apis::FileResource; 43 using google_apis::FileResource;
44 using google_apis::FileResourceCallback; 44 using google_apis::FileResourceCallback;
45 using google_apis::GDATA_FILE_ERROR; 45 using google_apis::GDATA_FILE_ERROR;
46 using google_apis::GDATA_NO_CONNECTION; 46 using google_apis::GDATA_NO_CONNECTION;
47 using google_apis::GDATA_OTHER_ERROR; 47 using google_apis::GDATA_OTHER_ERROR;
48 using google_apis::GDataErrorCode; 48 using google_apis::GDataErrorCode;
49 using google_apis::GetContentCallback; 49 using google_apis::GetContentCallback;
50 using google_apis::GetShareUrlCallback; 50 using google_apis::GetUrlCallback;
51 using google_apis::HTTP_BAD_REQUEST; 51 using google_apis::HTTP_BAD_REQUEST;
52 using google_apis::HTTP_CREATED; 52 using google_apis::HTTP_CREATED;
53 using google_apis::HTTP_NOT_FOUND; 53 using google_apis::HTTP_NOT_FOUND;
54 using google_apis::HTTP_NO_CONTENT; 54 using google_apis::HTTP_NO_CONTENT;
55 using google_apis::HTTP_PRECONDITION; 55 using google_apis::HTTP_PRECONDITION;
56 using google_apis::HTTP_RESUME_INCOMPLETE; 56 using google_apis::HTTP_RESUME_INCOMPLETE;
57 using google_apis::HTTP_SUCCESS; 57 using google_apis::HTTP_SUCCESS;
58 using google_apis::InitiateUploadCallback; 58 using google_apis::InitiateUploadCallback;
59 using google_apis::ParentReference; 59 using google_apis::ParentReference;
60 using google_apis::ProgressCallback; 60 using google_apis::ProgressCallback;
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return CancelCallback(); 507 return CancelCallback();
508 } 508 }
509 509
510 base::MessageLoop::current()->PostTask( 510 base::MessageLoop::current()->PostTask(
511 FROM_HERE, 511 FROM_HERE,
512 base::Bind(callback, HTTP_NOT_FOUND, 512 base::Bind(callback, HTTP_NOT_FOUND,
513 base::Passed(scoped_ptr<FileResource>()))); 513 base::Passed(scoped_ptr<FileResource>())));
514 return CancelCallback(); 514 return CancelCallback();
515 } 515 }
516 516
517 CancelCallback FakeDriveService::GetShareUrl( 517 CancelCallback FakeDriveService::GetShareUrl(const std::string& resource_id,
518 const std::string& resource_id, 518 const GURL& /* embed_origin */,
519 const GURL& /* embed_origin */, 519 const GetUrlCallback& callback) {
520 const GetShareUrlCallback& callback) {
521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
522 DCHECK(!callback.is_null()); 521 DCHECK(!callback.is_null());
523 522
524 if (offline_) { 523 if (offline_) {
525 base::MessageLoop::current()->PostTask( 524 base::MessageLoop::current()->PostTask(
526 FROM_HERE, 525 FROM_HERE,
527 base::Bind(callback, 526 base::Bind(callback,
528 GDATA_NO_CONNECTION, 527 GDATA_NO_CONNECTION,
529 GURL())); 528 GURL()));
530 return CancelCallback(); 529 return CancelCallback();
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 new_file->set_md5_checksum(base::MD5String(content_data)); 1392 new_file->set_md5_checksum(base::MD5String(content_data));
1394 } 1393 }
1395 1394
1396 if (shared_with_me) { 1395 if (shared_with_me) {
1397 // Set current time to mark the file as shared_with_me. 1396 // Set current time to mark the file as shared_with_me.
1398 new_file->set_shared_with_me_date(base::Time::Now()); 1397 new_file->set_shared_with_me_date(base::Time::Now());
1399 } 1398 }
1400 1399
1401 std::string escaped_resource_id = net::EscapePath(resource_id); 1400 std::string escaped_resource_id = net::EscapePath(resource_id);
1402 1401
1403 // Set mime type. 1402 // Set download URL and mime type.
1404 new_file->set_mime_type(content_type); 1403 new_file->set_mime_type(content_type);
1404 new_file->set_download_url(
1405 GURL("https://xxx/content/" + escaped_resource_id));
1405 1406
1406 // Set alternate link if needed. 1407 // Set alternate link if needed.
1407 if (content_type == util::kGoogleDocumentMimeType) 1408 if (content_type == util::kGoogleDocumentMimeType)
1408 new_file->set_alternate_link(GURL("https://document_alternate_link")); 1409 new_file->set_alternate_link(GURL("https://document_alternate_link"));
1409 1410
1410 // Set parents. 1411 // Set parents.
1411 if (!parent_resource_id.empty()) { 1412 if (!parent_resource_id.empty()) {
1412 ParentReference parent; 1413 ParentReference parent;
1413 parent.set_file_id(parent_resource_id); 1414 parent.set_file_id(parent_resource_id);
1414 parent.set_parent_link(GetFakeLinkUrl(parent.file_id())); 1415 parent.set_parent_link(GetFakeLinkUrl(parent.file_id()));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 google_apis::drive::PermissionRole role, 1569 google_apis::drive::PermissionRole role,
1569 const google_apis::EntryActionCallback& callback) { 1570 const google_apis::EntryActionCallback& callback) {
1570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1571 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1571 DCHECK(!callback.is_null()); 1572 DCHECK(!callback.is_null());
1572 1573
1573 NOTREACHED(); 1574 NOTREACHED();
1574 return CancelCallback(); 1575 return CancelCallback();
1575 } 1576 }
1576 1577
1577 } // namespace drive 1578 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698