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

Side by Side Diff: chrome/browser/android/webapk/webapk_installer.cc

Issue 2526713002: Specify the WebAPK server URL in Chromium source code (Closed)
Patch Set: Disable http/tests/serviceworker/registration.html Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/android/webapk/webapk_installer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
19 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
20 #include "chrome/browser/android/chrome_feature_list.h"
21 #include "chrome/browser/android/shortcut_helper.h" 21 #include "chrome/browser/android/shortcut_helper.h"
22 #include "chrome/browser/android/webapk/webapk.pb.h" 22 #include "chrome/browser/android/webapk/webapk.pb.h"
23 #include "chrome/browser/android/webapk/webapk_icon_hasher.h" 23 #include "chrome/browser/android/webapk/webapk_icon_hasher.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "components/variations/variations_associated_data.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "components/version_info/version_info.h" 26 #include "components/version_info/version_info.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 #include "content/public/common/manifest_util.h" 28 #include "content/public/common/manifest_util.h"
29 #include "jni/WebApkInstaller_jni.h" 29 #include "jni/WebApkInstaller_jni.h"
30 #include "net/http/http_status_code.h" 30 #include "net/http/http_status_code.h"
31 #include "net/url_request/url_fetcher.h" 31 #include "net/url_request/url_fetcher.h"
32 #include "ui/gfx/codec/png_codec.h" 32 #include "ui/gfx/codec/png_codec.h"
33 #include "url/gurl.h" 33 #include "url/gurl.h"
34 34
35 namespace { 35 namespace {
36 36
37 // The default WebAPK server URL. 37 // The default WebAPK server URL.
38 const char kDefaultServerUrl[] = 38 const char kDefaultServerUrl[] =
39 "https://webapk.googleapis.com/v1alpha/webApks/?alt=proto"; 39 "https://test-webapk.sandbox.googleapis.com/v1/webApks/?alt=proto&key=AIzaSy AoI6v-F31-3t9NunLYEiKcPIqgTJIUZBw";
40
41 // Flag for setting the WebAPK server URL.
42 const char kServerUrlVariationsParamKey[] = "ServerUrl";
43 40
44 // The MIME type of the POST data sent to the server. 41 // The MIME type of the POST data sent to the server.
45 const char kProtoMimeType[] = "application/x-protobuf"; 42 const char kProtoMimeType[] = "application/x-protobuf";
46 43
47 // The default number of milliseconds to wait for the WebAPK download URL from 44 // The default number of milliseconds to wait for the WebAPK download URL from
48 // the WebAPK server. 45 // the WebAPK server.
49 const int kWebApkDownloadUrlTimeoutMs = 60000; 46 const int kWebApkDownloadUrlTimeoutMs = 60000;
50 47
51 // The default number of milliseconds to wait for the WebAPK download to 48 // The default number of milliseconds to wait for the WebAPK download to
52 // complete. 49 // complete.
53 const int kDownloadTimeoutMs = 60000; 50 const int kDownloadTimeoutMs = 60000;
54 51
55 const int kWorldReadableFilePermission = base::FILE_PERMISSION_READ_BY_USER | 52 const int kWorldReadableFilePermission = base::FILE_PERMISSION_READ_BY_USER |
56 base::FILE_PERMISSION_READ_BY_GROUP | 53 base::FILE_PERMISSION_READ_BY_GROUP |
57 base::FILE_PERMISSION_READ_BY_OTHERS; 54 base::FILE_PERMISSION_READ_BY_OTHERS;
58 55
59 // Returns the WebAPK server URL based on the command line flags and the 56 // Returns the WebAPK server URL based on the command line.
60 // currently active field trials.
61 GURL GetServerUrl() { 57 GURL GetServerUrl() {
62 GURL server_url(variations::GetVariationParamValueByFeature( 58 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
63 chrome::android::kWebApks, kServerUrlVariationsParamKey)); 59 std::string url_string =
64 return server_url.is_valid() ? server_url : GURL(kDefaultServerUrl); 60 command_line->HasSwitch(switches::kWebApkServerUrl)
61 ? command_line->GetSwitchValueASCII(switches::kWebApkServerUrl)
62 : kDefaultServerUrl;
63 return GURL(url_string);
dominickn 2016/11/25 22:27:41 Should you check whether the GURL is valid here, i
65 } 64 }
66 65
67 // Returns the scope from |info| if it is specified. Otherwise, returns the 66 // Returns the scope from |info| if it is specified. Otherwise, returns the
68 // default scope. 67 // default scope.
69 GURL GetScope(const ShortcutInfo& info) { 68 GURL GetScope(const ShortcutInfo& info) {
70 return (info.scope.is_valid()) 69 return (info.scope.is_valid())
71 ? info.scope 70 ? info.scope
72 : ShortcutHelper::GetScopeFromURL(info.url); 71 : ShortcutHelper::GetScopeFromURL(info.url);
73 } 72 }
74 73
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 516
518 void WebApkInstaller::OnSuccess() { 517 void WebApkInstaller::OnSuccess() {
519 finish_callback_.Run(true, webapk_package_); 518 finish_callback_.Run(true, webapk_package_);
520 delete this; 519 delete this;
521 } 520 }
522 521
523 void WebApkInstaller::OnFailure() { 522 void WebApkInstaller::OnFailure() {
524 finish_callback_.Run(false, webapk_package_); 523 finish_callback_.Run(false, webapk_package_);
525 delete this; 524 delete this;
526 } 525 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/webapk/webapk_installer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698