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

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

Issue 2124513002: Introduce ManifestUpgradeDetector for WebAPK to detect web manifest changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce manifest upgrade detector. 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 26 matching lines...) Expand all
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(web_contents,
43 ShortcutHelper::GetIdealHomescreenIconSizeInDp(), 43 ShortcutHelper::GetIdealHomescreenIconSizeInDp(),
44 ShortcutHelper::GetMinimumHomescreenIconSizeInDp(), 44 ShortcutHelper::GetMinimumHomescreenIconSizeInDp(),
45 ShortcutHelper::GetIdealSplashImageSizeInDp(), 45 ShortcutHelper::GetIdealSplashImageSizeInDp(),
46 ShortcutHelper::GetMinimumSplashImageSizeInDp(), 46 ShortcutHelper::GetMinimumSplashImageSizeInDp(),
47 this)) { 47 false, this)) {
48 java_ref_.Reset(env, obj); 48 java_ref_.Reset(env, obj);
49 } 49 }
50 50
51 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() { 51 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() {
52 data_fetcher_->set_weak_observer(nullptr); 52 data_fetcher_->set_weak_observer(nullptr);
53 data_fetcher_ = nullptr; 53 data_fetcher_ = nullptr;
54 } 54 }
55 55
56 void AddToHomescreenDialogHelper::OnUserTitleAvailable( 56 void AddToHomescreenDialogHelper::OnUserTitleAvailable(
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(
67 const SkBitmap& icon) { 67 const ShortcutInfo& info,
68 const SkBitmap& icon,
69 const std::vector<std::string>& icon_urls) {
68 JNIEnv* env = base::android::AttachCurrentThread(); 70 JNIEnv* env = base::android::AttachCurrentThread();
69 ScopedJavaLocalRef<jobject> java_bitmap; 71 ScopedJavaLocalRef<jobject> java_bitmap;
70 if (icon.getSize()) 72 if (icon.getSize())
71 java_bitmap = gfx::ConvertToJavaBitmap(&icon); 73 java_bitmap = gfx::ConvertToJavaBitmap(&icon);
72 74
73 Java_AddToHomescreenDialogHelper_onIconAvailable(env, 75 Java_AddToHomescreenDialogHelper_onIconAvailable(env,
74 java_ref_.obj(), 76 java_ref_.obj(),
75 java_bitmap.obj()); 77 java_bitmap.obj());
76 78
77 if (add_shortcut_pending_) 79 if (add_shortcut_pending_)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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