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

Side by Side Diff: chrome/browser/android/banners/app_banner_manager.cc

Issue 880203004: Break out manifest icon logic from ShortcutHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changing unittest Created 5 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/android/manifest_icon_selector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "content/public/common/frame_navigate_params.h" 27 #include "content/public/common/frame_navigate_params.h"
27 #include "content/public/common/manifest.h" 28 #include "content/public/common/manifest.h"
28 #include "jni/AppBannerManager_jni.h" 29 #include "jni/AppBannerManager_jni.h"
29 #include "net/base/load_flags.h" 30 #include "net/base/load_flags.h"
30 #include "ui/gfx/android/java_bitmap.h" 31 #include "ui/gfx/android/java_bitmap.h"
32 #include "ui/gfx/screen.h"
31 33
32 using base::android::ConvertJavaStringToUTF8; 34 using base::android::ConvertJavaStringToUTF8;
33 using base::android::ConvertUTF8ToJavaString; 35 using base::android::ConvertUTF8ToJavaString;
34 using base::android::ConvertUTF16ToJavaString; 36 using base::android::ConvertUTF16ToJavaString;
35 37
36 namespace { 38 namespace {
37 const char kBannerTag[] = "google-play-id"; 39 const char kBannerTag[] = "google-play-id";
38 } 40 }
39 41
40 namespace banners { 42 namespace banners {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 kBannerTag)); 134 kBannerTag));
133 return; 135 return;
134 } 136 }
135 137
136 // TODO(benwells): Check triggering parameters here and if there is a meta 138 // TODO(benwells): Check triggering parameters here and if there is a meta
137 // tag. 139 // tag.
138 140
139 // Create an infobar to promote the manifest's app. 141 // Create an infobar to promote the manifest's app.
140 manifest_ = manifest; 142 manifest_ = manifest;
141 143
142 /* TODO(dfalcantara): Use after landing https://crrev.com/880203004.
143 GURL icon_url = 144 GURL icon_url =
144 ManifestIconSelector::FindBestMatchingIcon(manifest.icons, 145 ManifestIconSelector::FindBestMatchingIcon(
145 GetPreferredIconSize(), 146 manifest.icons,
146 web_contents()); 147 GetPreferredIconSize(),
148 gfx::Screen::GetScreenFor(web_contents()->GetNativeView()));
147 if (icon_url.is_empty()) 149 if (icon_url.is_empty())
148 return; 150 return;
149 */
150 if (manifest.icons.empty())
151 return;
152 GURL icon_url = manifest.icons.back().src;
153 151
154 FetchIcon(icon_url); 152 FetchIcon(icon_url);
155 } 153 }
156 154
157 bool AppBannerManager::OnMessageReceived(const IPC::Message& message) { 155 bool AppBannerManager::OnMessageReceived(const IPC::Message& message) {
158 bool handled = true; 156 bool handled = true;
159 IPC_BEGIN_MESSAGE_MAP(AppBannerManager, message) 157 IPC_BEGIN_MESSAGE_MAP(AppBannerManager, message)
160 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidRetrieveMetaTagContent, 158 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidRetrieveMetaTagContent,
161 OnDidRetrieveMetaTagContent) 159 OnDidRetrieveMetaTagContent)
162 IPC_MESSAGE_UNHANDLED(handled = false) 160 IPC_MESSAGE_UNHANDLED(handled = false)
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return base::CommandLine::ForCurrentProcess()->HasSwitch( 283 return base::CommandLine::ForCurrentProcess()->HasSwitch(
286 switches::kEnableAppInstallAlerts); 284 switches::kEnableAppInstallAlerts);
287 } 285 }
288 286
289 // Register native methods 287 // Register native methods
290 bool RegisterAppBannerManager(JNIEnv* env) { 288 bool RegisterAppBannerManager(JNIEnv* env) {
291 return RegisterNativesImpl(env); 289 return RegisterNativesImpl(env);
292 } 290 }
293 291
294 } // namespace banners 292 } // namespace banners
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/manifest_icon_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698