OLD | NEW |
---|---|
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/guid.h" | 11 #include "base/guid.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "chrome/browser/android/shortcut_helper.h" | 15 #include "chrome/browser/android/shortcut_helper.h" |
16 #include "chrome/browser/banners/app_banner_settings_helper.h" | 16 #include "chrome/browser/banners/app_banner_settings_helper.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
dominickn
2016/08/10 05:18:10
Remove unnecessary browser_thread.h include.
pkotwicz
2016/08/10 20:28:43
The include is still needed for AddToHomescreenDia
| |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "content/public/common/manifest.h" | 19 #include "content/public/common/manifest.h" |
20 #include "jni/AddToHomescreenDialogHelper_jni.h" | 20 #include "jni/AddToHomescreenDialogHelper_jni.h" |
21 #include "ui/gfx/android/java_bitmap.h" | 21 #include "ui/gfx/android/java_bitmap.h" |
22 #include "ui/gfx/color_analysis.h" | 22 #include "ui/gfx/color_analysis.h" |
23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
24 | 24 |
25 using base::android::JavaParamRef; | 25 using base::android::JavaParamRef; |
26 using base::android::ScopedJavaLocalRef; | 26 using base::android::ScopedJavaLocalRef; |
27 using content::Manifest; | 27 using content::Manifest; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 return; | 120 return; |
121 add_shortcut_pending_ = false; | 121 add_shortcut_pending_ = false; |
122 | 122 |
123 content::WebContents* web_contents = data_fetcher_->web_contents(); | 123 content::WebContents* web_contents = data_fetcher_->web_contents(); |
124 if (!web_contents) | 124 if (!web_contents) |
125 return; | 125 return; |
126 | 126 |
127 RecordAddToHomescreen(); | 127 RecordAddToHomescreen(); |
128 | 128 |
129 const std::string& uid = base::GenerateGUID(); | 129 const std::string& uid = base::GenerateGUID(); |
130 content::BrowserThread::PostTask( | 130 ShortcutHelper::AddToLauncherWithSkBitmap( |
131 content::BrowserThread::IO, FROM_HERE, | 131 web_contents->GetBrowserContext(), info, uid, icon, |
132 base::Bind(&ShortcutHelper::AddToLauncherInBackgroundWithSkBitmap, | 132 data_fetcher_->FetchSplashScreenImageCallback(uid)); |
133 web_contents->GetBrowserContext(), info, uid, icon, | |
134 data_fetcher_->FetchSplashScreenImageCallback(uid))); | |
135 } | 133 } |
136 | 134 |
137 bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper( | 135 bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper( |
138 JNIEnv* env) { | 136 JNIEnv* env) { |
139 return RegisterNativesImpl(env); | 137 return RegisterNativesImpl(env); |
140 } | 138 } |
141 | 139 |
142 void AddToHomescreenDialogHelper::RecordAddToHomescreen() { | 140 void AddToHomescreenDialogHelper::RecordAddToHomescreen() { |
143 // Record that the shortcut has been added, so no banners will be shown | 141 // Record that the shortcut has been added, so no banners will be shown |
144 // for this app. | 142 // for this app. |
145 content::WebContents* web_contents = data_fetcher_->web_contents(); | 143 content::WebContents* web_contents = data_fetcher_->web_contents(); |
146 if (!web_contents) | 144 if (!web_contents) |
147 return; | 145 return; |
148 | 146 |
149 AppBannerSettingsHelper::RecordBannerEvent( | 147 AppBannerSettingsHelper::RecordBannerEvent( |
150 web_contents, web_contents->GetURL(), | 148 web_contents, web_contents->GetURL(), |
151 data_fetcher_->shortcut_info().url.spec(), | 149 data_fetcher_->shortcut_info().url.spec(), |
152 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, | 150 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, |
153 base::Time::Now()); | 151 base::Time::Now()); |
154 } | 152 } |
OLD | NEW |