| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shortcut_helper.h" | 5 #include "chrome/browser/android/shortcut_helper.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 shortcut_info_.UpdateFromManifest(manifest); | 123 shortcut_info_.UpdateFromManifest(manifest); |
| 124 | 124 |
| 125 GURL icon_src = ManifestIconSelector::FindBestMatchingIcon( | 125 GURL icon_src = ManifestIconSelector::FindBestMatchingIcon( |
| 126 manifest.icons, | 126 manifest.icons, |
| 127 kPreferredIconSizeInDp, | 127 kPreferredIconSizeInDp, |
| 128 gfx::Screen::GetScreenFor(web_contents()->GetNativeView())); | 128 gfx::Screen::GetScreenFor(web_contents()->GetNativeView())); |
| 129 if (icon_src.is_valid()) { | 129 if (icon_src.is_valid()) { |
| 130 web_contents()->DownloadImage(icon_src, | 130 web_contents()->DownloadImage(icon_src, |
| 131 false, | 131 false, |
| 132 preferred_icon_size_in_px_, | 132 preferred_icon_size_in_px_, |
| 133 false, |
| 133 base::Bind(&ShortcutHelper::OnDidDownloadIcon, | 134 base::Bind(&ShortcutHelper::OnDidDownloadIcon, |
| 134 weak_ptr_factory_.GetWeakPtr())); | 135 weak_ptr_factory_.GetWeakPtr())); |
| 135 manifest_icon_status_ = MANIFEST_ICON_STATUS_FETCHING; | 136 manifest_icon_status_ = MANIFEST_ICON_STATUS_FETCHING; |
| 136 } | 137 } |
| 137 | 138 |
| 138 // The ShortcutHelper is now able to notify its Java counterpart that it is | 139 // The ShortcutHelper is now able to notify its Java counterpart that it is |
| 139 // initialized. OnInitialized method is not conceptually part of getting the | 140 // initialized. OnInitialized method is not conceptually part of getting the |
| 140 // manifest data but it happens that the initialization is finalized when | 141 // manifest data but it happens that the initialization is finalized when |
| 141 // these data are available. | 142 // these data are available. |
| 142 JNIEnv* env = base::android::AttachCurrentThread(); | 143 JNIEnv* env = base::android::AttachCurrentThread(); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 345 } |
| 345 | 346 |
| 346 void ShortcutHelper::RecordAddToHomescreen() { | 347 void ShortcutHelper::RecordAddToHomescreen() { |
| 347 // Record that the shortcut has been added, so no banners will be shown | 348 // Record that the shortcut has been added, so no banners will be shown |
| 348 // for this app. | 349 // for this app. |
| 349 AppBannerSettingsHelper::RecordBannerEvent( | 350 AppBannerSettingsHelper::RecordBannerEvent( |
| 350 web_contents(), shortcut_info_.url, shortcut_info_.url.spec(), | 351 web_contents(), shortcut_info_.url, shortcut_info_.url.spec(), |
| 351 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, | 352 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, |
| 352 base::Time::Now()); | 353 base::Time::Now()); |
| 353 } | 354 } |
| OLD | NEW |