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

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

Issue 2384533004: Fix style nit and update variable naming for AddToHomescreenManager. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « chrome/browser/android/webapps/add_to_homescreen_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_manager.h" 5 #include "chrome/browser/android/webapps/add_to_homescreen_manager.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 data_fetcher_->shortcut_info().user_title = user_title; 63 data_fetcher_->shortcut_info().user_title = user_title;
64 64
65 if (data_fetcher_->is_ready()) { 65 if (data_fetcher_->is_ready()) {
66 // If the fetcher isn't ready yet, the shortcut will be added when it is 66 // If the fetcher isn't ready yet, the shortcut will be added when it is
67 // via OnDataAvailable(); 67 // via OnDataAvailable();
68 AddShortcut(data_fetcher_->shortcut_info(), data_fetcher_->shortcut_icon()); 68 AddShortcut(data_fetcher_->shortcut_info(), data_fetcher_->shortcut_icon());
69 } 69 }
70 } 70 }
71 71
72 void AddToHomescreenManager::Start(content::WebContents* web_contents) { 72 void AddToHomescreenManager::Start(content::WebContents* web_contents) {
73 bool check_installable = false; 73 // Check whether to check WebApk compatibility.
pkotwicz 2016/09/30 21:57:03 Nit: Remove the comment. The comment does not say
F 2016/10/03 14:04:02 Done. Thx
74 bool check_webapk_compatible = false;
74 if (ChromeWebApkHost::AreWebApkEnabled() && 75 if (ChromeWebApkHost::AreWebApkEnabled() &&
75 content::IsOriginSecure(web_contents->GetLastCommittedURL())) { 76 content::IsOriginSecure(web_contents->GetLastCommittedURL())) {
76 check_installable = true; 77 check_webapk_compatible = true;
77 } else { 78 } else {
78 ShowDialog(); 79 ShowDialog();
79 } 80 }
80 81
81 data_fetcher_ = new AddToHomescreenDataFetcher( 82 data_fetcher_ = new AddToHomescreenDataFetcher(
82 web_contents, ShortcutHelper::GetIdealHomescreenIconSizeInDp(), 83 web_contents, ShortcutHelper::GetIdealHomescreenIconSizeInDp(),
83 ShortcutHelper::GetMinimumHomescreenIconSizeInDp(), 84 ShortcutHelper::GetMinimumHomescreenIconSizeInDp(),
84 ShortcutHelper::GetIdealSplashImageSizeInDp(), 85 ShortcutHelper::GetIdealSplashImageSizeInDp(),
85 ShortcutHelper::GetMinimumSplashImageSizeInDp(), 86 ShortcutHelper::GetMinimumSplashImageSizeInDp(),
86 check_installable, this); 87 check_webapk_compatible, this);
87 } 88 }
88 89
89 AddToHomescreenManager::~AddToHomescreenManager() { 90 AddToHomescreenManager::~AddToHomescreenManager() {
90 if (data_fetcher_) { 91 if (data_fetcher_) {
91 data_fetcher_->set_weak_observer(nullptr); 92 data_fetcher_->set_weak_observer(nullptr);
92 data_fetcher_ = nullptr; 93 data_fetcher_ = nullptr;
93 } 94 }
94 } 95 }
95 96
96 void AddToHomescreenManager::ShowDialog() { 97 void AddToHomescreenManager::ShowDialog() {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 ScopedJavaLocalRef<jstring> j_user_title = 147 ScopedJavaLocalRef<jstring> j_user_title =
147 base::android::ConvertUTF16ToJavaString(env, user_title); 148 base::android::ConvertUTF16ToJavaString(env, user_title);
148 Java_AddToHomescreenManager_onUserTitleAvailable(env, 149 Java_AddToHomescreenManager_onUserTitleAvailable(env,
149 java_ref_, 150 java_ref_,
150 j_user_title); 151 j_user_title);
151 } 152 }
152 153
153 void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info, 154 void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info,
154 const SkBitmap& icon) { 155 const SkBitmap& icon) {
155 if (is_webapk_compatible_) { 156 if (is_webapk_compatible_) {
156 CreateInfoBarForWebAPK(info, icon); 157 CreateInfoBarForWebApk(info, icon);
157 return; 158 return;
158 } 159 }
159 160
160 JNIEnv* env = base::android::AttachCurrentThread(); 161 JNIEnv* env = base::android::AttachCurrentThread();
161 ScopedJavaLocalRef<jobject> java_bitmap; 162 ScopedJavaLocalRef<jobject> java_bitmap;
162 if (icon.getSize()) 163 if (icon.getSize())
163 java_bitmap = gfx::ConvertToJavaBitmap(&icon); 164 java_bitmap = gfx::ConvertToJavaBitmap(&icon);
164 165
165 Java_AddToHomescreenManager_onReadyToAdd(env, java_ref_, java_bitmap); 166 Java_AddToHomescreenManager_onReadyToAdd(env, java_ref_, java_bitmap);
166 167
167 if (add_shortcut_pending_) 168 if (add_shortcut_pending_)
168 AddShortcut(info, icon); 169 AddShortcut(info, icon);
169 } 170 }
170 171
171 void AddToHomescreenManager::CreateInfoBarForWebAPK(const ShortcutInfo& info, 172 void AddToHomescreenManager::CreateInfoBarForWebApk(const ShortcutInfo& info,
172 const SkBitmap& icon) { 173 const SkBitmap& icon) {
173 banners::AppBannerInfoBarDelegateAndroid::Create( 174 banners::AppBannerInfoBarDelegateAndroid::Create(
174 data_fetcher_->web_contents(), nullptr, info.user_title, 175 data_fetcher_->web_contents(), nullptr, info.user_title,
175 base::MakeUnique<ShortcutInfo>(info), base::MakeUnique<SkBitmap>(icon), 176 base::MakeUnique<ShortcutInfo>(info), base::MakeUnique<SkBitmap>(icon),
176 -1 /* event_request_id */, true /* is_webapk */, 177 -1 /* event_request_id */, true /* is_webapk */,
177 webapk::INSTALL_SOURCE_MENU); 178 webapk::INSTALL_SOURCE_MENU);
178 } 179 }
179 180
180 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground( 181 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground(
181 const SkBitmap& bitmap, 182 const SkBitmap& bitmap,
182 const GURL& url, 183 const GURL& url,
183 bool* is_generated) { 184 bool* is_generated) {
184 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 185 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
185 186
186 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url, 187 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url,
187 is_generated); 188 is_generated);
188 } 189 }
OLDNEW
« no previous file with comments | « chrome/browser/android/webapps/add_to_homescreen_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698