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_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/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
25 #include "jni/AddToHomescreenManager_jni.h" | 25 #include "jni/AddToHomescreenManager_jni.h" |
26 #include "mojo/public/cpp/bindings/interface_request.h" | 26 #include "mojo/public/cpp/bindings/interface_request.h" |
27 #include "services/service_manager/public/cpp/interface_provider.h" | 27 #include "services/service_manager/public/cpp/interface_provider.h" |
28 #include "third_party/WebKit/public/platform/modules/installation/installation.m
ojom.h" | 28 #include "third_party/WebKit/public/platform/modules/installation/installation.m
ojom.h" |
29 #include "ui/gfx/android/java_bitmap.h" | 29 #include "ui/gfx/android/java_bitmap.h" |
30 | 30 |
31 using base::android::JavaParamRef; | 31 using base::android::JavaParamRef; |
32 using base::android::ScopedJavaLocalRef; | 32 using base::android::ScopedJavaLocalRef; |
33 | 33 |
| 34 namespace { |
| 35 |
| 36 // The length of time to allow the add to homescreen data fetcher to run before |
| 37 // timing out and generating an icon. |
| 38 const int kDataTimeoutInMilliseconds = 4000; |
| 39 |
| 40 } // namespace |
| 41 |
34 jlong InitializeAndStart(JNIEnv* env, | 42 jlong InitializeAndStart(JNIEnv* env, |
35 const JavaParamRef<jobject>& obj, | 43 const JavaParamRef<jobject>& obj, |
36 const JavaParamRef<jobject>& java_web_contents) { | 44 const JavaParamRef<jobject>& java_web_contents) { |
37 content::WebContents* web_contents = | 45 content::WebContents* web_contents = |
38 content::WebContents::FromJavaWebContents(java_web_contents); | 46 content::WebContents::FromJavaWebContents(java_web_contents); |
39 AddToHomescreenManager* manager = new AddToHomescreenManager(env, obj); | 47 AddToHomescreenManager* manager = new AddToHomescreenManager(env, obj); |
40 manager->Start(web_contents); | 48 manager->Start(web_contents); |
41 return reinterpret_cast<intptr_t>(manager); | 49 return reinterpret_cast<intptr_t>(manager); |
42 } | 50 } |
43 | 51 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 check_webapk_compatible = true; | 95 check_webapk_compatible = true; |
88 } else { | 96 } else { |
89 ShowDialog(); | 97 ShowDialog(); |
90 } | 98 } |
91 | 99 |
92 data_fetcher_ = new AddToHomescreenDataFetcher( | 100 data_fetcher_ = new AddToHomescreenDataFetcher( |
93 web_contents, ShortcutHelper::GetIdealHomescreenIconSizeInPx(), | 101 web_contents, ShortcutHelper::GetIdealHomescreenIconSizeInPx(), |
94 ShortcutHelper::GetMinimumHomescreenIconSizeInPx(), | 102 ShortcutHelper::GetMinimumHomescreenIconSizeInPx(), |
95 ShortcutHelper::GetIdealSplashImageSizeInPx(), | 103 ShortcutHelper::GetIdealSplashImageSizeInPx(), |
96 ShortcutHelper::GetMinimumSplashImageSizeInPx(), | 104 ShortcutHelper::GetMinimumSplashImageSizeInPx(), |
97 ShortcutHelper::GetIdealBadgeIconSizeInPx(), | 105 ShortcutHelper::GetIdealBadgeIconSizeInPx(), kDataTimeoutInMilliseconds, |
98 check_webapk_compatible, this); | 106 check_webapk_compatible, this); |
99 } | 107 } |
100 | 108 |
101 AddToHomescreenManager::~AddToHomescreenManager() { | 109 AddToHomescreenManager::~AddToHomescreenManager() { |
102 if (data_fetcher_) { | 110 if (data_fetcher_) { |
103 data_fetcher_->set_weak_observer(nullptr); | 111 data_fetcher_->set_weak_observer(nullptr); |
104 data_fetcher_ = nullptr; | 112 data_fetcher_ = nullptr; |
105 } | 113 } |
106 } | 114 } |
107 | 115 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 192 |
185 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground( | 193 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground( |
186 const SkBitmap& bitmap, | 194 const SkBitmap& bitmap, |
187 const GURL& url, | 195 const GURL& url, |
188 bool* is_generated) { | 196 bool* is_generated) { |
189 base::ThreadRestrictions::AssertIOAllowed(); | 197 base::ThreadRestrictions::AssertIOAllowed(); |
190 | 198 |
191 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url, | 199 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url, |
192 is_generated); | 200 is_generated); |
193 } | 201 } |
OLD | NEW |