Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 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/base/load_flags.h" |
| 32 #include "net/http/http_status_code.h" | 32 #include "net/http/http_status_code.h" |
| 33 #include "net/traffic_annotation/network_traffic_annotation.h" | 33 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 34 #include "net/url_request/url_fetcher.h" | 34 #include "net/url_request/url_fetcher.h" |
| 35 #include "ui/gfx/codec/png_codec.h" | 35 #include "ui/gfx/codec/png_codec.h" |
| 36 #include "ui/gfx/color_utils.h" | |
| 36 #include "url/gurl.h" | 37 #include "url/gurl.h" |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 // The default WebAPK server URL. | 41 // The default WebAPK server URL. |
| 41 const char kDefaultServerUrl[] = | 42 const char kDefaultServerUrl[] = |
| 42 "https://webapk.googleapis.com/v1/webApks/" | 43 "https://webapk.googleapis.com/v1/webApks/" |
| 43 "?alt=proto&key=AIzaSyAoI6v-F31-3t9NunLYEiKcPIqgTJIUZBw"; | 44 "?alt=proto&key=AIzaSyAoI6v-F31-3t9NunLYEiKcPIqgTJIUZBw"; |
| 44 | 45 |
| 45 // The MIME type of the POST data sent to the server. | 46 // The MIME type of the POST data sent to the server. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 71 GURL GetScope(const ShortcutInfo& info) { | 72 GURL GetScope(const ShortcutInfo& info) { |
| 72 return (info.scope.is_valid()) ? info.scope | 73 return (info.scope.is_valid()) ? info.scope |
| 73 : ShortcutHelper::GetScopeFromURL(info.url); | 74 : ShortcutHelper::GetScopeFromURL(info.url); |
| 74 } | 75 } |
| 75 | 76 |
| 76 // Converts a color from the format specified in content::Manifest to a CSS | 77 // Converts a color from the format specified in content::Manifest to a CSS |
| 77 // string. | 78 // string. |
| 78 std::string ColorToString(int64_t color) { | 79 std::string ColorToString(int64_t color) { |
| 79 if (color == content::Manifest::kInvalidOrMissingColor) | 80 if (color == content::Manifest::kInvalidOrMissingColor) |
| 80 return ""; | 81 return ""; |
| 81 | 82 return color_utils::SkColorToRGBAString(reinterpret_cast<uint32_t&>(color)); |
| 82 SkColor sk_color = reinterpret_cast<uint32_t&>(color); | |
|
pkotwicz
2017/02/27 23:39:39
Nit: Please keep this line and call color_utils::S
gonzalon
2017/02/28 14:59:32
Done, but it would be nice if reviews were consist
| |
| 83 int r = SkColorGetR(sk_color); | |
| 84 int g = SkColorGetG(sk_color); | |
| 85 int b = SkColorGetB(sk_color); | |
| 86 double a = SkColorGetA(sk_color) / 255.0; | |
| 87 return base::StringPrintf("rgba(%d,%d,%d,%.2f)", r, g, b, a); | |
| 88 } | 83 } |
| 89 | 84 |
| 90 // Get Chrome's current ABI. It depends on whether Chrome is running as a 32 bit | 85 // Get Chrome's current ABI. It depends on whether Chrome is running as a 32 bit |
| 91 // app or 64 bit, and the device's cpu architecture as well. Note: please keep | 86 // app or 64 bit, and the device's cpu architecture as well. Note: please keep |
| 92 // this function stay in sync with |chromium_android_linker::GetCpuAbi()|. | 87 // this function stay in sync with |chromium_android_linker::GetCpuAbi()|. |
| 93 std::string getCurrentAbi() { | 88 std::string getCurrentAbi() { |
| 94 #if defined(__arm__) && defined(__ARM_ARCH_7A__) | 89 #if defined(__arm__) && defined(__ARM_ARCH_7A__) |
| 95 return "armeabi-v7a"; | 90 return "armeabi-v7a"; |
| 96 #elif defined(__arm__) | 91 #elif defined(__arm__) |
| 97 return "armeabi"; | 92 return "armeabi"; |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 | 623 |
| 629 void WebApkInstaller::OnSuccess() { | 624 void WebApkInstaller::OnSuccess() { |
| 630 finish_callback_.Run(true, webapk_package_); | 625 finish_callback_.Run(true, webapk_package_); |
| 631 delete this; | 626 delete this; |
| 632 } | 627 } |
| 633 | 628 |
| 634 void WebApkInstaller::OnFailure() { | 629 void WebApkInstaller::OnFailure() { |
| 635 finish_callback_.Run(false, webapk_package_); | 630 finish_callback_.Run(false, webapk_package_); |
| 636 delete this; | 631 delete this; |
| 637 } | 632 } |
| OLD | NEW |