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

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: 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/chrome_feature_list.h"
Xi Han 2016/11/24 14:27:50 Do you still need this include?
21 #include "chrome/browser/android/shortcut_helper.h" 22 #include "chrome/browser/android/shortcut_helper.h"
22 #include "chrome/browser/android/webapk/webapk.pb.h" 23 #include "chrome/browser/android/webapk/webapk.pb.h"
23 #include "chrome/browser/android/webapk/webapk_icon_hasher.h" 24 #include "chrome/browser/android/webapk/webapk_icon_hasher.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/common/chrome_switches.h"
25 #include "components/variations/variations_associated_data.h" 27 #include "components/variations/variations_associated_data.h"
Xi Han 2016/11/24 14:27:50 Do you still need this include? I see you removed
26 #include "components/version_info/version_info.h" 28 #include "components/version_info/version_info.h"
27 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
28 #include "content/public/common/manifest_util.h" 30 #include "content/public/common/manifest_util.h"
29 #include "jni/WebApkInstaller_jni.h" 31 #include "jni/WebApkInstaller_jni.h"
30 #include "net/http/http_status_code.h" 32 #include "net/http/http_status_code.h"
31 #include "net/url_request/url_fetcher.h" 33 #include "net/url_request/url_fetcher.h"
32 #include "ui/gfx/codec/png_codec.h" 34 #include "ui/gfx/codec/png_codec.h"
33 #include "url/gurl.h" 35 #include "url/gurl.h"
34 36
35 namespace { 37 namespace {
36 38
37 // The default WebAPK server URL. 39 // The default WebAPK server URL.
38 const char kDefaultServerUrl[] = 40 const char kDefaultServerUrl[] =
39 "https://webapk.googleapis.com/v1alpha/webApks/?alt=proto"; 41 "https://test-webapk.sandbox.googleapis.com/v1/webApks/?alt=proto&key=AIzaSy AoI6v-F31-3t9NunLYEiKcPIqgTJIUZBw";
Xi Han 2016/11/24 14:27:50 Is the test server public? I am wondering whether
pkotwicz 2016/11/25 01:29:19 A user can currently figure out what the URL is us
40
41 // Flag for setting the WebAPK server URL.
42 const char kServerUrlVariationsParamKey[] = "ServerUrl";
43 42
44 // The MIME type of the POST data sent to the server. 43 // The MIME type of the POST data sent to the server.
45 const char kProtoMimeType[] = "application/x-protobuf"; 44 const char kProtoMimeType[] = "application/x-protobuf";
46 45
47 // The default number of milliseconds to wait for the WebAPK download URL from 46 // The default number of milliseconds to wait for the WebAPK download URL from
48 // the WebAPK server. 47 // the WebAPK server.
49 const int kWebApkDownloadUrlTimeoutMs = 60000; 48 const int kWebApkDownloadUrlTimeoutMs = 60000;
50 49
51 // The default number of milliseconds to wait for the WebAPK download to 50 // The default number of milliseconds to wait for the WebAPK download to
52 // complete. 51 // complete.
53 const int kDownloadTimeoutMs = 60000; 52 const int kDownloadTimeoutMs = 60000;
54 53
55 const int kWorldReadableFilePermission = base::FILE_PERMISSION_READ_BY_USER | 54 const int kWorldReadableFilePermission = base::FILE_PERMISSION_READ_BY_USER |
56 base::FILE_PERMISSION_READ_BY_GROUP | 55 base::FILE_PERMISSION_READ_BY_GROUP |
57 base::FILE_PERMISSION_READ_BY_OTHERS; 56 base::FILE_PERMISSION_READ_BY_OTHERS;
58 57
59 // Returns the WebAPK server URL based on the command line flags and the 58 // Returns the WebAPK server URL based on the command line.
60 // currently active field trials.
61 GURL GetServerUrl() { 59 GURL GetServerUrl() {
62 GURL server_url(variations::GetVariationParamValueByFeature( 60 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
63 chrome::android::kWebApks, kServerUrlVariationsParamKey)); 61 std::string url_string =
64 return server_url.is_valid() ? server_url : GURL(kDefaultServerUrl); 62 command_line->HasSwitch(switches::kWebApkServerUrl)
63 ? command_line->GetSwitchValueASCII(switches::kWebApkServerUrl)
64 : kDefaultServerUrl;
65 return GURL(url_string);
65 } 66 }
66 67
67 // Returns the scope from |info| if it is specified. Otherwise, returns the 68 // Returns the scope from |info| if it is specified. Otherwise, returns the
68 // default scope. 69 // default scope.
69 GURL GetScope(const ShortcutInfo& info) { 70 GURL GetScope(const ShortcutInfo& info) {
70 return (info.scope.is_valid()) 71 return (info.scope.is_valid())
71 ? info.scope 72 ? info.scope
72 : ShortcutHelper::GetScopeFromURL(info.url); 73 : ShortcutHelper::GetScopeFromURL(info.url);
73 } 74 }
74 75
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 518
518 void WebApkInstaller::OnSuccess() { 519 void WebApkInstaller::OnSuccess() {
519 finish_callback_.Run(true, webapk_package_); 520 finish_callback_.Run(true, webapk_package_);
520 delete this; 521 delete this;
521 } 522 }
522 523
523 void WebApkInstaller::OnFailure() { 524 void WebApkInstaller::OnFailure() {
524 finish_callback_.Run(false, webapk_package_); 525 finish_callback_.Run(false, webapk_package_);
525 delete this; 526 delete this;
526 } 527 }
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