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

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

Issue 1308533006: webapps: allow callers of icon downloader/selector to specify a minimum size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webapps-splashscreen-icon
Patch Set: Fix non-compiling test Created 5 years, 3 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"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/guid.h" 12 #include "base/guid.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/android/shortcut_helper.h" 16 #include "chrome/browser/android/shortcut_helper.h"
17 #include "chrome/browser/banners/app_banner_settings_helper.h" 17 #include "chrome/browser/banners/app_banner_settings_helper.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/manifest.h" 20 #include "content/public/common/manifest.h"
21 #include "jni/AddToHomescreenDialogHelper_jni.h" 21 #include "jni/AddToHomescreenDialogHelper_jni.h"
22 #include "ui/gfx/android/java_bitmap.h" 22 #include "ui/gfx/android/java_bitmap.h"
23 #include "ui/gfx/color_analysis.h" 23 #include "ui/gfx/color_analysis.h"
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 using content::Manifest; 26 using content::Manifest;
27 27
28 jlong Initialize(JNIEnv* env, 28 jlong Initialize(JNIEnv* env,
29 const JavaParamRef<jobject>& obj, 29 const JavaParamRef<jobject>& obj,
30 const JavaParamRef<jobject>& java_web_contents, 30 const JavaParamRef<jobject>& java_web_contents) {
31 jint ideal_splash_image_size_in_dp,
32 jint ideal_icon_size_in_dp) {
33 content::WebContents* web_contents = 31 content::WebContents* web_contents =
34 content::WebContents::FromJavaWebContents(java_web_contents); 32 content::WebContents::FromJavaWebContents(java_web_contents);
35 AddToHomescreenDialogHelper* add_to_homescreen_helper = 33 AddToHomescreenDialogHelper* add_to_homescreen_helper =
36 new AddToHomescreenDialogHelper(env, obj, web_contents, 34 new AddToHomescreenDialogHelper(
37 ideal_splash_image_size_in_dp, ideal_icon_size_in_dp); 35 env, obj, web_contents);
38 return reinterpret_cast<intptr_t>(add_to_homescreen_helper); 36 return reinterpret_cast<intptr_t>(add_to_homescreen_helper);
39 } 37 }
40 38
41 AddToHomescreenDialogHelper::AddToHomescreenDialogHelper( 39 AddToHomescreenDialogHelper::AddToHomescreenDialogHelper(
42 JNIEnv* env, 40 JNIEnv* env,
43 jobject obj, 41 jobject obj,
44 content::WebContents* web_contents, 42 content::WebContents* web_contents)
45 int ideal_splash_image_size_in_dp,
46 int ideal_icon_size_in_dp)
47 : add_shortcut_pending_(false), 43 : add_shortcut_pending_(false),
48 data_fetcher_(new AddToHomescreenDataFetcher(web_contents, 44 data_fetcher_(new AddToHomescreenDataFetcher(web_contents,
49 ideal_splash_image_size_in_dp, 45 ShortcutHelper::GetIdealSplashImageSizeInDp(),
50 ideal_icon_size_in_dp, 46 ShortcutHelper::GetMinimumSplashImageSizeInDp(),
47 ShortcutHelper::GetIdealIconSizeInDp(),
48 ShortcutHelper::GetMinimumIconSizeInDp(),
51 this)) { 49 this)) {
52 java_ref_.Reset(env, obj); 50 java_ref_.Reset(env, obj);
53 } 51 }
54 52
55 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() { 53 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() {
56 data_fetcher_->set_weak_observer(nullptr); 54 data_fetcher_->set_weak_observer(nullptr);
57 data_fetcher_ = nullptr; 55 data_fetcher_ = nullptr;
58 } 56 }
59 57
60 void AddToHomescreenDialogHelper::OnUserTitleAvailable( 58 void AddToHomescreenDialogHelper::OnUserTitleAvailable(
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 content::WebContents* web_contents = data_fetcher_->web_contents(); 163 content::WebContents* web_contents = data_fetcher_->web_contents();
166 if (!web_contents) 164 if (!web_contents)
167 return; 165 return;
168 166
169 AppBannerSettingsHelper::RecordBannerEvent( 167 AppBannerSettingsHelper::RecordBannerEvent(
170 web_contents, web_contents->GetURL(), 168 web_contents, web_contents->GetURL(),
171 data_fetcher_->shortcut_info().url.spec(), 169 data_fetcher_->shortcut_info().url.spec(),
172 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 170 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
173 base::Time::Now()); 171 base::Time::Now());
174 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698