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

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

Issue 1420743002: Web app: set a flag on the Intent if the icon was generated by Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@splashscreen-even-more-tests
Patch Set: review comments Created 5 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_dialog_helper.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_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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (add_shortcut_pending_) 78 if (add_shortcut_pending_)
79 AddShortcut(info, icon); 79 AddShortcut(info, icon);
80 } 80 }
81 81
82 void AddToHomescreenDialogHelper::Destroy(JNIEnv* env, jobject obj) { 82 void AddToHomescreenDialogHelper::Destroy(JNIEnv* env, 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,
89 bool* is_generated) {
89 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 90 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
90 91
91 // Determine a single color to use for the favicon if the favicon that is 92 return ShortcutHelper::FinalizeLauncherIcon(bitmap, url, is_generated);
92 // returned it is too low quality.
93 SkColor color = color_utils::CalculateKMeanColorOfBitmap(bitmap);
94 int dominant_red = SkColorGetR(color);
95 int dominant_green = SkColorGetG(color);
96 int dominant_blue = SkColorGetB(color);
97
98 // Make the icon acceptable for the Android launcher.
99 JNIEnv* env = base::android::AttachCurrentThread();
100 ScopedJavaLocalRef<jstring> java_url =
101 base::android::ConvertUTF8ToJavaString(env, url.spec());
102 ScopedJavaLocalRef<jobject> java_bitmap;
103 if (bitmap.getSize())
104 java_bitmap = gfx::ConvertToJavaBitmap(&bitmap);
105
106 base::android::ScopedJavaLocalRef<jobject> ref =
107 Java_AddToHomescreenDialogHelper_finalizeLauncherIcon(env,
108 java_url.obj(),
109 java_bitmap.obj(),
110 dominant_red,
111 dominant_green,
112 dominant_blue);
113 return gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(ref.obj()));
114 } 93 }
115 94
116 void AddToHomescreenDialogHelper::AddShortcut(JNIEnv* env, 95 void AddToHomescreenDialogHelper::AddShortcut(JNIEnv* env,
117 jobject obj, 96 jobject obj,
118 jstring j_user_title) { 97 jstring j_user_title) {
119 add_shortcut_pending_ = true; 98 add_shortcut_pending_ = true;
120 99
121 base::string16 user_title = 100 base::string16 user_title =
122 base::android::ConvertJavaStringToUTF16(env, j_user_title); 101 base::android::ConvertJavaStringToUTF16(env, j_user_title);
123 if (!user_title.empty()) 102 if (!user_title.empty())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 content::WebContents* web_contents = data_fetcher_->web_contents(); 141 content::WebContents* web_contents = data_fetcher_->web_contents();
163 if (!web_contents) 142 if (!web_contents)
164 return; 143 return;
165 144
166 AppBannerSettingsHelper::RecordBannerEvent( 145 AppBannerSettingsHelper::RecordBannerEvent(
167 web_contents, web_contents->GetURL(), 146 web_contents, web_contents->GetURL(),
168 data_fetcher_->shortcut_info().url.spec(), 147 data_fetcher_->shortcut_info().url.spec(),
169 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 148 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
170 base::Time::Now()); 149 base::Time::Now());
171 } 150 }
OLDNEW
« no previous file with comments | « chrome/browser/android/webapps/add_to_homescreen_dialog_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698