diff options
13 files changed, 50 insertions, 28 deletions
diff --git a/chrome/browser/apps/drive/drive_service_bridge.cc b/chrome/browser/apps/drive/drive_service_bridge.cc index f3facb04..916bcd5e 100644 --- a/chrome/browser/apps/drive/drive_service_bridge.cc +++ b/chrome/browser/apps/drive/drive_service_bridge.cc @@ -83,6 +83,7 @@ void DriveServiceBridgeImpl::Initialize() { drive_task_runner.get(), GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction), GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction), + GURL(google_apis::DriveApiUrlGenerator::kBaseThumbnailUrlForProduction), std::string() /* custom_user_agent */)); SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(profile_); diff --git a/chrome/browser/chromeos/drive/drive_integration_service.cc b/chrome/browser/chromeos/drive/drive_integration_service.cc index a9951e3..37c9f84 100644 --- a/chrome/browser/chromeos/drive/drive_integration_service.cc +++ b/chrome/browser/chromeos/drive/drive_integration_service.cc @@ -234,11 +234,11 @@ DriveIntegrationService::DriveIntegrationService( drive_service_.reset(test_drive_service); } else { drive_service_.reset(new DriveAPIService( - oauth_service, - g_browser_process->system_request_context(), + oauth_service, g_browser_process->system_request_context(), blocking_task_runner_.get(), GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction), GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction), + GURL(google_apis::DriveApiUrlGenerator::kBaseThumbnailUrlForProduction), GetDriveUserAgent())); } scheduler_.reset(new JobScheduler( diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc index aa9414e..7f2f1d7 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc @@ -96,7 +96,9 @@ void FillEntryPropertiesValueForDrive(const drive::ResourceEntry& entry_proto, DriveApiUrlGenerator url_generator( (GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction)), (GURL( - google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction))); + google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction)), + (GURL(google_apis::DriveApiUrlGenerator:: + kBaseThumbnailUrlForProduction))); properties->thumbnail_url.reset(new std::string( url_generator.GetThumbnailUrl(entry_proto.resource_id(), 500 /* width */, 500 /* height */, @@ -1098,7 +1100,9 @@ void FileManagerPrivateInternalGetDownloadUrlFunction::OnGetResourceEntry( DriveApiUrlGenerator url_generator( (GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction)), - (GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction))); + (GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction)), + (GURL( + google_apis::DriveApiUrlGenerator::kBaseThumbnailUrlForProduction))); download_url_ = url_generator.GenerateDownloadFileUrl(entry->resource_id()); ProfileOAuth2TokenService* oauth2_token_service = diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc index af08422..6fbd594 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc @@ -75,6 +75,8 @@ SyncEngine::DriveServiceFactory::CreateDriveService( GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction), GURL(google_apis::DriveApiUrlGenerator:: kBaseDownloadUrlForProduction), + GURL(google_apis::DriveApiUrlGenerator:: + kBaseThumbnailUrlForProduction), std::string() /* custom_user_agent */)); } diff --git a/components/drive/service/drive_api_service.cc b/components/drive/service/drive_api_service.cc index 2f47fe6..446503a 100644 --- a/components/drive/service/drive_api_service.cc +++ b/components/drive/service/drive_api_service.cc @@ -248,11 +248,12 @@ DriveAPIService::DriveAPIService( base::SequencedTaskRunner* blocking_task_runner, const GURL& base_url, const GURL& base_download_url, + const GURL& base_thumbnail_url, const std::string& custom_user_agent) : oauth2_token_service_(oauth2_token_service), url_request_context_getter_(url_request_context_getter), blocking_task_runner_(blocking_task_runner), - url_generator_(base_url, base_download_url), + url_generator_(base_url, base_download_url, base_thumbnail_url), custom_user_agent_(custom_user_agent) { } diff --git a/components/drive/service/drive_api_service.h b/components/drive/service/drive_api_service.h index 22bb7d4..374edc0 100644 --- a/components/drive/service/drive_api_service.h +++ b/components/drive/service/drive_api_service.h @@ -93,6 +93,8 @@ class DriveAPIService : public DriveServiceInterface, // |base_url| is used to generate URLs for communication with the drive API. // |base_download_url| is used to generate URLs for downloading file from the // drive API. + // |base_thumbnail_url| is used to generate URLs for downloading thumbnail + // from image server. // |custom_user_agent| will be used for the User-Agent header in HTTP // requests issues through the service if the value is not empty. DriveAPIService( @@ -101,6 +103,7 @@ class DriveAPIService : public DriveServiceInterface, base::SequencedTaskRunner* blocking_task_runner, const GURL& base_url, const GURL& base_download_url, + const GURL& base_thumbnail_url, const std::string& custom_user_agent); ~DriveAPIService() override; diff --git a/components/drive/service/drive_api_service_unittest.cc b/components/drive/service/drive_api_service_unittest.cc index 6655e68..c6a4e2f 100644 --- a/components/drive/service/drive_api_service_unittest.cc +++ b/components/drive/service/drive_api_service_unittest.cc @@ -36,7 +36,8 @@ class TestAuthService : public google_apis::DummyAuthService { TEST(DriveAPIServiceTest, BatchRequestConfiguratorWithAuthFailure) { const GURL test_base_url("http://localhost/"); - google_apis::DriveApiUrlGenerator url_generator(test_base_url, test_base_url); + google_apis::DriveApiUrlGenerator url_generator( + test_base_url, test_base_url, test_base_url); scoped_refptr<base::TestSimpleTaskRunner> task_runner = new base::TestSimpleTaskRunner(); scoped_refptr<net::TestURLRequestContextGetter> request_context_getter = diff --git a/google_apis/drive/drive_api_requests_unittest.cc b/google_apis/drive/drive_api_requests_unittest.cc index 817fffa..1df9680 100644 --- a/google_apis/drive/drive_api_requests_unittest.cc +++ b/google_apis/drive/drive_api_requests_unittest.cc @@ -160,7 +160,7 @@ class DriveApiRequestsTest : public testing::Test { GURL test_base_url = test_util::GetBaseUrlForTesting(test_server_.port()); url_generator_.reset( - new DriveApiUrlGenerator(test_base_url, test_base_url)); + new DriveApiUrlGenerator(test_base_url, test_base_url, test_base_url)); // Reset the server's expected behavior just in case. ResetExpectedResponse(); diff --git a/google_apis/drive/drive_api_url_generator.cc b/google_apis/drive/drive_api_url_generator.cc index 14da8a3..a097527 100644 --- a/google_apis/drive/drive_api_url_generator.cc +++ b/google_apis/drive/drive_api_url_generator.cc @@ -32,7 +32,8 @@ const char kDriveV2UploadExistingFileUrlPrefix[] = "upload/drive/v2/files/"; const char kDriveV2BatchUploadUrl[] = "upload/drive"; const char kDriveV2PermissionsUrlFormat[] = "drive/v2/files/%s/permissions"; const char kDriveV2DownloadUrlFormat[] = "host/%s"; -const char kDriveV2ThumbnailUrlFormat[] = "thumb/%s?width=%d&height=%d"; +const char kDriveV2ThumbnailUrlFormat[] = "d/%s=w%d-h%d"; +const char kDriveV2ThumbnailUrlWithCropFormat[] = "d/%s=w%d-h%d-c"; // apps.delete and file.authorize API is exposed through a special endpoint // v2internal that is accessible only by the official API key for Chrome. @@ -53,9 +54,11 @@ GURL AddMultipartUploadParam(const GURL& url) { } // namespace DriveApiUrlGenerator::DriveApiUrlGenerator(const GURL& base_url, - const GURL& base_download_url) + const GURL& base_download_url, + const GURL& base_thumbnail_url) : base_url_(base_url), - base_download_url_(base_download_url) { + base_download_url_(base_download_url), + base_thumbnail_url_(base_thumbnail_url) { // Do nothing. } @@ -73,6 +76,9 @@ const char DriveApiUrlGenerator::kBaseDownloadUrlForProduction[] = "https://www.googledrive.com"; #endif +const char DriveApiUrlGenerator::kBaseThumbnailUrlForProduction[] = + "https://lh3.googleusercontent.com"; + GURL DriveApiUrlGenerator::GetAboutGetUrl() const { return base_url_.Resolve(kDriveV2AboutUrl); } @@ -298,15 +304,10 @@ GURL DriveApiUrlGenerator::GetThumbnailUrl(const std::string& resource_id, int width, int height, bool crop) const { - GURL url = base_download_url_.Resolve( - base::StringPrintf(kDriveV2ThumbnailUrlFormat, - net::EscapePath(resource_id).c_str(), width, height)); - - // crop is "false" by default. - if (crop) - url = net::AppendOrReplaceQueryParameter(url, "crop", "true"); - - return url; + return base_thumbnail_url_.Resolve( + base::StringPrintf( + crop ? kDriveV2ThumbnailUrlWithCropFormat : kDriveV2ThumbnailUrlFormat, + net::EscapePath(resource_id).c_str(), width, height)); } GURL DriveApiUrlGenerator::GetBatchUploadUrl() const { diff --git a/google_apis/drive/drive_api_url_generator.h b/google_apis/drive/drive_api_url_generator.h index 7e498fb..67f402f 100644 --- a/google_apis/drive/drive_api_url_generator.h +++ b/google_apis/drive/drive_api_url_generator.h @@ -17,7 +17,9 @@ class DriveApiUrlGenerator { public: // |base_url| is the path to the target drive api server. // Note that this is an injecting point for a testing server. - DriveApiUrlGenerator(const GURL& base_url, const GURL& base_download_url); + DriveApiUrlGenerator(const GURL& base_url, + const GURL& base_download_url, + const GURL& base_thumbnail_url); ~DriveApiUrlGenerator(); // The base URL for communicating with the production drive api server. @@ -26,6 +28,9 @@ class DriveApiUrlGenerator { // The base URL for the file download server for production. static const char kBaseDownloadUrlForProduction[]; + // The base URL for the thumbnail download server for production. + static const char kBaseThumbnailUrlForProduction[]; + // Returns a URL to invoke "About: get" method. GURL GetAboutGetUrl() const; @@ -121,6 +126,7 @@ class DriveApiUrlGenerator { private: const GURL base_url_; const GURL base_download_url_; + const GURL base_thumbnail_url_; // This class is copyable hence no DISALLOW_COPY_AND_ASSIGN here. }; diff --git a/google_apis/drive/drive_api_url_generator_unittest.cc b/google_apis/drive/drive_api_url_generator_unittest.cc index 28e79c4..1240b24 100644 --- a/google_apis/drive/drive_api_url_generator_unittest.cc +++ b/google_apis/drive/drive_api_url_generator_unittest.cc @@ -15,13 +15,15 @@ namespace { // OS, so use testing base urls. const char kBaseUrlForTesting[] = "https://www.example.com"; const char kBaseDownloadUrlForTesting[] = "https://download.example.com/p/"; +const char kBaseThumbnailUrlForTesting[] = "https://thumbnail.example.com"; } // namespace class DriveApiUrlGeneratorTest : public testing::Test { public: DriveApiUrlGeneratorTest() : url_generator_(GURL(kBaseUrlForTesting), - GURL(kBaseDownloadUrlForTesting)) {} + GURL(kBaseDownloadUrlForTesting), + GURL(kBaseThumbnailUrlForTesting)) {} protected: DriveApiUrlGenerator url_generator_; @@ -369,13 +371,12 @@ TEST_F(DriveApiUrlGeneratorTest, GeneratePermissionsInsertUrl) { TEST_F(DriveApiUrlGeneratorTest, GenerateThumbnailUrl) { EXPECT_EQ( - "https://download.example.com/p/thumb/0ADK06pfg?width=500&height=500", - url_generator_.GetThumbnailUrl("0ADK06pfg", 500, 500, false).spec()); + "https://thumbnail.example.com/d/0ADK06pfg=w500-h480", + url_generator_.GetThumbnailUrl("0ADK06pfg", 500, 480, false).spec()); EXPECT_EQ( - "https://download.example.com/p/thumb/" - "0ADK06pfg?width=360&height=360&crop=true", - url_generator_.GetThumbnailUrl("0ADK06pfg", 360, 360, true).spec()); + "https://thumbnail.example.com/d/0ADK06pfg=w360-h380-c", + url_generator_.GetThumbnailUrl("0ADK06pfg", 360, 380, true).spec()); } TEST_F(DriveApiUrlGeneratorTest, BatchUploadUrl) { diff --git a/google_apis/drive/files_list_request_runner_unittest.cc b/google_apis/drive/files_list_request_runner_unittest.cc index d8d8e78..51b72c6 100644 --- a/google_apis/drive/files_list_request_runner_unittest.cc +++ b/google_apis/drive/files_list_request_runner_unittest.cc @@ -78,7 +78,8 @@ class FilesListRequestRunnerTest : public testing::Test { runner_.reset(new FilesListRequestRunner( request_sender_.get(), google_apis::DriveApiUrlGenerator(test_server_.base_url(), - test_server_.GetURL("/download/")))); + test_server_.GetURL("/download/"), + test_server_.GetURL("/thumbnail/")))); } void TearDown() override { diff --git a/ui/file_manager/image_loader/manifest.json b/ui/file_manager/image_loader/manifest.json index ab0fd83..0d0673f 100644 --- a/ui/file_manager/image_loader/manifest.json +++ b/ui/file_manager/image_loader/manifest.json @@ -14,10 +14,11 @@ "fileManagerPrivate", "https://www.google-analytics.com/", "https://www.googledrive.com/", + "https://lh3.googleusercontent.com/", "metricsPrivate", "storage" ], - "content_security_policy": "default-src 'none'; script-src 'self' blob: filesystem: chrome://resources chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj; style-src 'self' blob: filesystem:; frame-src 'self' blob: filesystem:; img-src 'self' blob: filesystem: data:; media-src 'self' blob: filesystem:; connect-src 'self' blob: filesystem: https://www.googledrive.com https://www.google-analytics.com", + "content_security_policy": "default-src 'none'; script-src 'self' blob: filesystem: chrome://resources chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj; style-src 'self' blob: filesystem:; frame-src 'self' blob: filesystem:; img-src 'self' blob: filesystem: data:; media-src 'self' blob: filesystem:; connect-src 'self' blob: filesystem: https://www.googledrive.com https://www.google-analytics.com https://lh3.googleusercontent.com", "background": { "scripts": [ "chrome://resources/js/assert.js", |