| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/android/webapk/webapk_installer.h" | 5 #include "chrome/browser/android/webapk/webapk_installer.h" |
| 6 | 6 |
| 7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/path_utils.h" | 10 #include "base/android/path_utils.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/threading/sequenced_worker_pool.h" | 21 #include "base/threading/sequenced_worker_pool.h" |
| 22 #include "chrome/browser/android/shortcut_helper.h" | 22 #include "chrome/browser/android/shortcut_helper.h" |
| 23 #include "chrome/browser/android/webapk/webapk.pb.h" | 23 #include "chrome/browser/android/webapk/webapk.pb.h" |
| 24 #include "chrome/browser/android/webapk/webapk_icon_hasher.h" | 24 #include "chrome/browser/android/webapk/webapk_icon_hasher.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "components/version_info/version_info.h" | 27 #include "components/version_info/version_info.h" |
| 28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/common/manifest_util.h" | 29 #include "content/public/common/manifest_util.h" |
| 30 #include "jni/WebApkInstaller_jni.h" | 30 #include "jni/WebApkInstaller_jni.h" |
| 31 #include "net/base/load_flags.h" |
| 31 #include "net/http/http_status_code.h" | 32 #include "net/http/http_status_code.h" |
| 32 #include "net/url_request/url_fetcher.h" | 33 #include "net/url_request/url_fetcher.h" |
| 33 #include "ui/gfx/codec/png_codec.h" | 34 #include "ui/gfx/codec/png_codec.h" |
| 34 #include "url/gurl.h" | 35 #include "url/gurl.h" |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 // The default WebAPK server URL. | 39 // The default WebAPK server URL. |
| 39 const char kDefaultServerUrl[] = | 40 const char kDefaultServerUrl[] = |
| 40 "https://webapk.googleapis.com/v1/webApks/?alt=proto&key=AIzaSyAoI6v-F31-3t9
NunLYEiKcPIqgTJIUZBw"; | 41 "https://webapk.googleapis.com/v1/webApks/?alt=proto&key=AIzaSyAoI6v-F31-3t9
NunLYEiKcPIqgTJIUZBw"; |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 FROM_HERE, | 501 FROM_HERE, |
| 501 base::TimeDelta::FromMilliseconds(webapk_download_url_timeout_ms_), | 502 base::TimeDelta::FromMilliseconds(webapk_download_url_timeout_ms_), |
| 502 base::Bind(&WebApkInstaller::OnTimeout, weak_ptr_factory_.GetWeakPtr())); | 503 base::Bind(&WebApkInstaller::OnTimeout, weak_ptr_factory_.GetWeakPtr())); |
| 503 | 504 |
| 504 url_fetcher_ = | 505 url_fetcher_ = |
| 505 net::URLFetcher::Create(server_url, net::URLFetcher::POST, this); | 506 net::URLFetcher::Create(server_url, net::URLFetcher::POST, this); |
| 506 url_fetcher_->SetRequestContext(request_context_getter_); | 507 url_fetcher_->SetRequestContext(request_context_getter_); |
| 507 std::string serialized_request; | 508 std::string serialized_request; |
| 508 request_proto->SerializeToString(&serialized_request); | 509 request_proto->SerializeToString(&serialized_request); |
| 509 url_fetcher_->SetUploadData(kProtoMimeType, serialized_request); | 510 url_fetcher_->SetUploadData(kProtoMimeType, serialized_request); |
| 511 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | |
| 512 net::LOAD_DO_NOT_SEND_COOKIES | |
| 513 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 514 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
| 510 url_fetcher_->Start(); | 515 url_fetcher_->Start(); |
| 511 } | 516 } |
| 512 | 517 |
| 513 void WebApkInstaller::OnGotWebApkDownloadUrl(const GURL& download_url, | 518 void WebApkInstaller::OnGotWebApkDownloadUrl(const GURL& download_url, |
| 514 const std::string& package_name) { | 519 const std::string& package_name) { |
| 515 webapk_package_ = package_name; | 520 webapk_package_ = package_name; |
| 516 | 521 |
| 517 base::PostTaskAndReplyWithResult( | 522 base::PostTaskAndReplyWithResult( |
| 518 GetBackgroundTaskRunner().get(), FROM_HERE, | 523 GetBackgroundTaskRunner().get(), FROM_HERE, |
| 519 base::Bind(&CreateSubDirAndSetPermissionsInBackground, | 524 base::Bind(&CreateSubDirAndSetPermissionsInBackground, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 620 |
| 616 void WebApkInstaller::OnSuccess() { | 621 void WebApkInstaller::OnSuccess() { |
| 617 finish_callback_.Run(true, webapk_package_); | 622 finish_callback_.Run(true, webapk_package_); |
| 618 delete this; | 623 delete this; |
| 619 } | 624 } |
| 620 | 625 |
| 621 void WebApkInstaller::OnFailure() { | 626 void WebApkInstaller::OnFailure() { |
| 622 finish_callback_.Run(false, webapk_package_); | 627 finish_callback_.Run(false, webapk_package_); |
| 623 delete this; | 628 delete this; |
| 624 } | 629 } |
| OLD | NEW |