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

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

Issue 2379923002: Implement "appinstalled" event on Android. (Closed)
Patch Set: Rebase. Created 4 years 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_manager.h" 5 #include "chrome/browser/android/webapps/add_to_homescreen_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/guid.h" 9 #include "base/guid.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" 14 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
15 #include "chrome/browser/android/shortcut_helper.h" 15 #include "chrome/browser/android/shortcut_helper.h"
16 #include "chrome/browser/android/webapk/chrome_webapk_host.h" 16 #include "chrome/browser/android/webapk/chrome_webapk_host.h"
17 #include "chrome/browser/android/webapk/webapk_metrics.h" 17 #include "chrome/browser/android/webapk/webapk_metrics.h"
18 #include "chrome/browser/banners/app_banner_settings_helper.h" 18 #include "chrome/browser/banners/app_banner_settings_helper.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/render_frame_host.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "content/public/common/origin_util.h" 22 #include "content/public/common/origin_util.h"
22 #include "jni/AddToHomescreenManager_jni.h" 23 #include "jni/AddToHomescreenManager_jni.h"
24 #include "mojo/public/cpp/bindings/interface_request.h"
25 #include "services/service_manager/public/cpp/interface_provider.h"
26 #include "third_party/WebKit/public/platform/modules/installation/installation.m ojom.h"
23 #include "ui/gfx/android/java_bitmap.h" 27 #include "ui/gfx/android/java_bitmap.h"
24 28
25 using base::android::JavaParamRef; 29 using base::android::JavaParamRef;
26 using base::android::ScopedJavaLocalRef; 30 using base::android::ScopedJavaLocalRef;
27 31
28 jlong InitializeAndStart(JNIEnv* env, 32 jlong InitializeAndStart(JNIEnv* env,
29 const JavaParamRef<jobject>& obj, 33 const JavaParamRef<jobject>& obj,
30 const JavaParamRef<jobject>& java_web_contents) { 34 const JavaParamRef<jobject>& java_web_contents) {
31 content::WebContents* web_contents = 35 content::WebContents* web_contents =
32 content::WebContents::FromJavaWebContents(java_web_contents); 36 content::WebContents::FromJavaWebContents(java_web_contents);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 content::WebContents* web_contents = data_fetcher_->web_contents(); 112 content::WebContents* web_contents = data_fetcher_->web_contents();
109 if (!web_contents) 113 if (!web_contents)
110 return; 114 return;
111 115
112 RecordAddToHomescreen(); 116 RecordAddToHomescreen();
113 117
114 const std::string& uid = base::GenerateGUID(); 118 const std::string& uid = base::GenerateGUID();
115 ShortcutHelper::AddToLauncherWithSkBitmap( 119 ShortcutHelper::AddToLauncherWithSkBitmap(
116 web_contents->GetBrowserContext(), info, uid, icon, 120 web_contents->GetBrowserContext(), info, uid, icon,
117 data_fetcher_->FetchSplashScreenImageCallback(uid)); 121 data_fetcher_->FetchSplashScreenImageCallback(uid));
122
123 // Fire the appinstalled event.
124 blink::mojom::InstallationServicePtr installation_service;
125 web_contents->GetMainFrame()->GetRemoteInterfaces()->GetInterface(
126 mojo::GetProxy(&installation_service));
127 DCHECK(installation_service);
128 installation_service->OnInstall();
118 } 129 }
119 130
120 void AddToHomescreenManager::RecordAddToHomescreen() { 131 void AddToHomescreenManager::RecordAddToHomescreen() {
121 // Record that the shortcut has been added, so no banners will be shown 132 // Record that the shortcut has been added, so no banners will be shown
122 // for this app. 133 // for this app.
123 content::WebContents* web_contents = data_fetcher_->web_contents(); 134 content::WebContents* web_contents = data_fetcher_->web_contents();
124 if (!web_contents) 135 if (!web_contents)
125 return; 136 return;
126 137
127 AppBannerSettingsHelper::RecordBannerEvent( 138 AppBannerSettingsHelper::RecordBannerEvent(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 189
179 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground( 190 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground(
180 const SkBitmap& bitmap, 191 const SkBitmap& bitmap,
181 const GURL& url, 192 const GURL& url,
182 bool* is_generated) { 193 bool* is_generated) {
183 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 194 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
184 195
185 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url, 196 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url,
186 is_generated); 197 is_generated);
187 } 198 }
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_infobar_delegate_android.cc ('k') | chrome/browser/banners/app_banner_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698