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

Side by Side Diff: chrome/browser/android/webapps/add_to_homescreen_dialog_helper.cc

Issue 2138973002: Initial CL for talking to the WebAPK server to generate WebAPK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'webapk_builder_impl0' into webapk_builder_impl2 Created 4 years, 5 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/webapps/add_to_homescreen_dialog_helper.h" 5 #include "chrome/browser/android/webapps/add_to_homescreen_dialog_helper.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 21 matching lines...) Expand all
32 AddToHomescreenDialogHelper* add_to_homescreen_helper = 32 AddToHomescreenDialogHelper* add_to_homescreen_helper =
33 new AddToHomescreenDialogHelper(env, obj, web_contents); 33 new AddToHomescreenDialogHelper(env, obj, web_contents);
34 return reinterpret_cast<intptr_t>(add_to_homescreen_helper); 34 return reinterpret_cast<intptr_t>(add_to_homescreen_helper);
35 } 35 }
36 36
37 AddToHomescreenDialogHelper::AddToHomescreenDialogHelper( 37 AddToHomescreenDialogHelper::AddToHomescreenDialogHelper(
38 JNIEnv* env, 38 JNIEnv* env,
39 jobject obj, 39 jobject obj,
40 content::WebContents* web_contents) 40 content::WebContents* web_contents)
41 : add_shortcut_pending_(false), 41 : add_shortcut_pending_(false),
42 data_fetcher_(new AddToHomescreenDataFetcher(web_contents, 42 data_fetcher_(new AddToHomescreenDataFetcher(
43 web_contents,
43 ShortcutHelper::GetIdealHomescreenIconSizeInDp(), 44 ShortcutHelper::GetIdealHomescreenIconSizeInDp(),
44 ShortcutHelper::GetMinimumHomescreenIconSizeInDp(), 45 ShortcutHelper::GetMinimumHomescreenIconSizeInDp(),
45 ShortcutHelper::GetIdealSplashImageSizeInDp(), 46 ShortcutHelper::GetIdealSplashImageSizeInDp(),
46 ShortcutHelper::GetMinimumSplashImageSizeInDp(), 47 ShortcutHelper::GetMinimumSplashImageSizeInDp(),
47 this)) { 48 this)),
49 browser_context_(web_contents->GetBrowserContext()) {
48 java_ref_.Reset(env, obj); 50 java_ref_.Reset(env, obj);
49 } 51 }
50 52
51 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() { 53 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() {
52 data_fetcher_->set_weak_observer(nullptr); 54 data_fetcher_->set_weak_observer(nullptr);
53 data_fetcher_ = nullptr; 55 data_fetcher_ = nullptr;
54 } 56 }
55 57
56 void AddToHomescreenDialogHelper::OnUserTitleAvailable( 58 void AddToHomescreenDialogHelper::OnUserTitleAvailable(
57 const base::string16& user_title) { 59 const base::string16& user_title) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 DCHECK(add_shortcut_pending_); 117 DCHECK(add_shortcut_pending_);
116 if (!add_shortcut_pending_) 118 if (!add_shortcut_pending_)
117 return; 119 return;
118 add_shortcut_pending_ = false; 120 add_shortcut_pending_ = false;
119 121
120 RecordAddToHomescreen(); 122 RecordAddToHomescreen();
121 123
122 const std::string& uid = base::GenerateGUID(); 124 const std::string& uid = base::GenerateGUID();
123 content::BrowserThread::PostTask( 125 content::BrowserThread::PostTask(
124 content::BrowserThread::IO, FROM_HERE, 126 content::BrowserThread::IO, FROM_HERE,
125 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, info, 127 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap,
126 uid, icon, 128 browser_context_, info, uid, icon,
127 data_fetcher_->FetchSplashScreenImageCallback(uid))); 129 data_fetcher_->FetchSplashScreenImageCallback(uid)));
128 } 130 }
129 131
130 bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper( 132 bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper(
131 JNIEnv* env) { 133 JNIEnv* env) {
132 return RegisterNativesImpl(env); 134 return RegisterNativesImpl(env);
133 } 135 }
134 136
135 void AddToHomescreenDialogHelper::RecordAddToHomescreen() { 137 void AddToHomescreenDialogHelper::RecordAddToHomescreen() {
136 // Record that the shortcut has been added, so no banners will be shown 138 // Record that the shortcut has been added, so no banners will be shown
137 // for this app. 139 // for this app.
138 content::WebContents* web_contents = data_fetcher_->web_contents(); 140 content::WebContents* web_contents = data_fetcher_->web_contents();
139 if (!web_contents) 141 if (!web_contents)
140 return; 142 return;
141 143
142 AppBannerSettingsHelper::RecordBannerEvent( 144 AppBannerSettingsHelper::RecordBannerEvent(
143 web_contents, web_contents->GetURL(), 145 web_contents, web_contents->GetURL(),
144 data_fetcher_->shortcut_info().url.spec(), 146 data_fetcher_->shortcut_info().url.spec(),
145 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 147 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
146 base::Time::Now()); 148 base::Time::Now());
147 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698