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

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

Issue 2064943002: Pass in extra parameters to WebApkBuilder#buildWebApkAsync() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_manifest Created 4 years, 6 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const base::string16& user_title) { 57 const base::string16& user_title) {
58 JNIEnv* env = base::android::AttachCurrentThread(); 58 JNIEnv* env = base::android::AttachCurrentThread();
59 ScopedJavaLocalRef<jstring> j_user_title = 59 ScopedJavaLocalRef<jstring> j_user_title =
60 base::android::ConvertUTF16ToJavaString(env, user_title); 60 base::android::ConvertUTF16ToJavaString(env, user_title);
61 Java_AddToHomescreenDialogHelper_onUserTitleAvailable(env, 61 Java_AddToHomescreenDialogHelper_onUserTitleAvailable(env,
62 java_ref_.obj(), 62 java_ref_.obj(),
63 j_user_title.obj()); 63 j_user_title.obj());
64 } 64 }
65 65
66 void AddToHomescreenDialogHelper::OnDataAvailable(const ShortcutInfo& info, 66 void AddToHomescreenDialogHelper::OnDataAvailable(const ShortcutInfo& info,
67 const GURL& icon_url,
67 const SkBitmap& icon) { 68 const SkBitmap& icon) {
68 JNIEnv* env = base::android::AttachCurrentThread(); 69 JNIEnv* env = base::android::AttachCurrentThread();
69 ScopedJavaLocalRef<jobject> java_bitmap; 70 ScopedJavaLocalRef<jobject> java_bitmap;
70 if (icon.getSize()) 71 if (icon.getSize())
71 java_bitmap = gfx::ConvertToJavaBitmap(&icon); 72 java_bitmap = gfx::ConvertToJavaBitmap(&icon);
72 73
73 Java_AddToHomescreenDialogHelper_onIconAvailable(env, 74 Java_AddToHomescreenDialogHelper_onIconAvailable(env, java_ref_.obj(),
Xi Han 2016/06/15 14:09:35 Revert changes here?
pkotwicz 2016/06/15 14:19:13 I think that my change fixes the indentation in Ja
74 java_ref_.obj(), 75 java_bitmap.obj());
75 java_bitmap.obj());
76 76
77 if (add_shortcut_pending_) 77 if (add_shortcut_pending_)
78 AddShortcut(info, icon); 78 AddShortcut(info, icon_url, icon);
79 } 79 }
80 80
81 void AddToHomescreenDialogHelper::Destroy(JNIEnv* env, 81 void AddToHomescreenDialogHelper::Destroy(JNIEnv* env,
82 const JavaParamRef<jobject>& obj) { 82 const JavaParamRef<jobject>& obj) {
83 delete this; 83 delete this;
84 } 84 }
85 85
86 SkBitmap AddToHomescreenDialogHelper::FinalizeLauncherIcon( 86 SkBitmap AddToHomescreenDialogHelper::FinalizeLauncherIcon(
87 const SkBitmap& bitmap, 87 const SkBitmap& bitmap,
88 const GURL& url, 88 const GURL& url,
(...skipping 10 matching lines...) Expand all
99 add_shortcut_pending_ = true; 99 add_shortcut_pending_ = true;
100 100
101 base::string16 user_title = 101 base::string16 user_title =
102 base::android::ConvertJavaStringToUTF16(env, j_user_title); 102 base::android::ConvertJavaStringToUTF16(env, j_user_title);
103 if (!user_title.empty()) 103 if (!user_title.empty())
104 data_fetcher_->shortcut_info().user_title = user_title; 104 data_fetcher_->shortcut_info().user_title = user_title;
105 105
106 if (data_fetcher_->is_ready()) { 106 if (data_fetcher_->is_ready()) {
107 // If the fetcher isn't ready yet, the shortcut will be added when it is 107 // If the fetcher isn't ready yet, the shortcut will be added when it is
108 // via OnDataAvailable(); 108 // via OnDataAvailable();
109 AddShortcut(data_fetcher_->shortcut_info(), data_fetcher_->shortcut_icon()); 109 AddShortcut(data_fetcher_->shortcut_info(),
110 data_fetcher_->shortcut_icon_url(),
111 data_fetcher_->shortcut_icon());
110 } 112 }
111 } 113 }
112 114
113 void AddToHomescreenDialogHelper::AddShortcut(const ShortcutInfo& info, 115 void AddToHomescreenDialogHelper::AddShortcut(const ShortcutInfo& info,
116 const GURL& icon_url,
114 const SkBitmap& icon) { 117 const SkBitmap& icon) {
115 DCHECK(add_shortcut_pending_); 118 DCHECK(add_shortcut_pending_);
116 if (!add_shortcut_pending_) 119 if (!add_shortcut_pending_)
117 return; 120 return;
118 add_shortcut_pending_ = false; 121 add_shortcut_pending_ = false;
119 122
120 RecordAddToHomescreen(); 123 RecordAddToHomescreen();
121 124
122 const std::string& uid = base::GenerateGUID(); 125 const std::string& uid = base::GenerateGUID();
123 content::BrowserThread::PostTask( 126 content::BrowserThread::PostTask(
124 content::BrowserThread::IO, FROM_HERE, 127 content::BrowserThread::IO, FROM_HERE,
125 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, info, 128 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, info,
126 uid, icon, 129 uid, icon_url, icon,
127 data_fetcher_->FetchSplashScreenImageCallback(uid))); 130 data_fetcher_->FetchSplashScreenImageCallback(uid)));
128 } 131 }
129 132
130 bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper( 133 bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper(
131 JNIEnv* env) { 134 JNIEnv* env) {
132 return RegisterNativesImpl(env); 135 return RegisterNativesImpl(env);
133 } 136 }
134 137
135 void AddToHomescreenDialogHelper::RecordAddToHomescreen() { 138 void AddToHomescreenDialogHelper::RecordAddToHomescreen() {
136 // Record that the shortcut has been added, so no banners will be shown 139 // Record that the shortcut has been added, so no banners will be shown
137 // for this app. 140 // for this app.
138 content::WebContents* web_contents = data_fetcher_->web_contents(); 141 content::WebContents* web_contents = data_fetcher_->web_contents();
139 if (!web_contents) 142 if (!web_contents)
140 return; 143 return;
141 144
142 AppBannerSettingsHelper::RecordBannerEvent( 145 AppBannerSettingsHelper::RecordBannerEvent(
143 web_contents, web_contents->GetURL(), 146 web_contents, web_contents->GetURL(),
144 data_fetcher_->shortcut_info().url.spec(), 147 data_fetcher_->shortcut_info().url.spec(),
145 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 148 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
146 base::Time::Now()); 149 base::Time::Now());
147 } 150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698