OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/banners/app_banner_manager.h" | 5 #include "chrome/browser/android/banners/app_banner_manager.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" | 12 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" |
13 #include "chrome/browser/android/banners/app_banner_metrics_ids.h" | 13 #include "chrome/browser/android/banners/app_banner_metrics_ids.h" |
14 #include "chrome/browser/android/banners/app_banner_utilities.h" | 14 #include "chrome/browser/android/banners/app_banner_utilities.h" |
| 15 #include "chrome/browser/android/manifest_icon_selector.h" |
15 #include "chrome/browser/banners/app_banner_settings_helper.h" | 16 #include "chrome/browser/banners/app_banner_settings_helper.h" |
16 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 17 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
17 #include "chrome/browser/infobars/infobar_service.h" | 18 #include "chrome/browser/infobars/infobar_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
22 #include "content/public/browser/android/content_view_core.h" | 23 #include "content/public/browser/android/content_view_core.h" |
23 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
24 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 kBannerTag)); | 133 kBannerTag)); |
133 return; | 134 return; |
134 } | 135 } |
135 | 136 |
136 // TODO(benwells): Check triggering parameters here and if there is a meta | 137 // TODO(benwells): Check triggering parameters here and if there is a meta |
137 // tag. | 138 // tag. |
138 | 139 |
139 // Create an infobar to promote the manifest's app. | 140 // Create an infobar to promote the manifest's app. |
140 manifest_ = manifest; | 141 manifest_ = manifest; |
141 | 142 |
142 /* TODO(dfalcantara): Use after landing https://crrev.com/880203004. | |
143 GURL icon_url = | 143 GURL icon_url = |
144 ManifestIconSelector::FindBestMatchingIcon(manifest.icons, | 144 ManifestIconSelector::FindBestMatchingIcon(manifest.icons, |
145 GetPreferredIconSize(), | 145 GetPreferredIconSize(), |
146 web_contents()); | 146 web_contents()); |
147 if (icon_url.is_empty()) | 147 if (icon_url.is_empty()) |
148 return; | 148 return; |
149 */ | |
150 if (manifest.icons.empty()) | |
151 return; | |
152 GURL icon_url = manifest.icons.back().src; | |
153 | 149 |
154 FetchIcon(icon_url); | 150 FetchIcon(icon_url); |
155 } | 151 } |
156 | 152 |
157 bool AppBannerManager::OnMessageReceived(const IPC::Message& message) { | 153 bool AppBannerManager::OnMessageReceived(const IPC::Message& message) { |
158 bool handled = true; | 154 bool handled = true; |
159 IPC_BEGIN_MESSAGE_MAP(AppBannerManager, message) | 155 IPC_BEGIN_MESSAGE_MAP(AppBannerManager, message) |
160 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidRetrieveMetaTagContent, | 156 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidRetrieveMetaTagContent, |
161 OnDidRetrieveMetaTagContent) | 157 OnDidRetrieveMetaTagContent) |
162 IPC_MESSAGE_UNHANDLED(handled = false) | 158 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 281 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
286 switches::kEnableAppInstallAlerts); | 282 switches::kEnableAppInstallAlerts); |
287 } | 283 } |
288 | 284 |
289 // Register native methods | 285 // Register native methods |
290 bool RegisterAppBannerManager(JNIEnv* env) { | 286 bool RegisterAppBannerManager(JNIEnv* env) { |
291 return RegisterNativesImpl(env); | 287 return RegisterNativesImpl(env); |
292 } | 288 } |
293 | 289 |
294 } // namespace banners | 290 } // namespace banners |
OLD | NEW |