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 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_DATA_FETCHER_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_DATA_FETCHER_ANDROID_H_ |
6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_DATA_FETCHER_ANDROID_H_ | 6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_DATA_FETCHER_ANDROID_H_ |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "chrome/browser/banners/app_banner_data_fetcher.h" | 9 #include "chrome/browser/banners/app_banner_data_fetcher.h" |
10 | 10 |
11 namespace banners { | 11 namespace banners { |
12 | 12 |
13 // Fetches data required to show a banner for the URL currently shown by the | 13 // Fetches data required to show a banner for the URL currently shown by the |
14 // WebContents. Extends the regular fetch to add support for Android apps. | 14 // WebContents. Extends the regular fetch to add support for Android apps. |
15 class AppBannerDataFetcherAndroid : public AppBannerDataFetcher { | 15 class AppBannerDataFetcherAndroid : public AppBannerDataFetcher { |
16 public: | 16 public: |
17 AppBannerDataFetcherAndroid( | 17 AppBannerDataFetcherAndroid( |
18 content::WebContents* web_contents, | 18 content::WebContents* web_contents, |
19 base::WeakPtr<Delegate> weak_delegate, | 19 base::WeakPtr<Delegate> weak_delegate, |
20 int ideal_icon_size); | 20 int ideal_icon_size); |
21 | 21 |
22 // Saves information about the Android app being promoted by the current page, | 22 // Saves information about the Android app being promoted by the current page, |
23 // then continues the creation pipeline. | 23 // then continues the creation pipeline. |
24 bool ContinueFetching(const base::string16& app_title, | 24 bool ContinueFetching(const base::string16& app_title, |
25 const std::string& app_package, | 25 const std::string& app_package, |
26 base::android::ScopedJavaLocalRef<jobject> app_data, | 26 base::android::ScopedJavaLocalRef<jobject> app_data, |
27 const GURL& image_url); | 27 const GURL& image_url); |
28 | 28 |
| 29 // Avoid compiler warning about hiding a virtual function with the same name. |
| 30 using AppBannerDataFetcher::OnMessageReceived; |
| 31 |
| 32 // WebContentsObserver override. |
| 33 bool OnMessageReceived(const IPC::Message& message) override; |
| 34 |
29 protected: | 35 protected: |
30 ~AppBannerDataFetcherAndroid() override; | 36 ~AppBannerDataFetcherAndroid() override; |
31 | 37 |
32 std::string GetBannerType() override; | 38 std::string GetBannerType() override; |
33 std::string GetAppIdentifier() override; | 39 std::string GetAppIdentifier() override; |
| 40 |
| 41 // AppBannerDataFetcher override. Queries the site's meta viewport tag to |
| 42 // detect whether it is responsive, and proceeds by calling the base class |
| 43 // implementation. |
| 44 void HandleWebApp(content::WebContents* web_contents) override; |
| 45 |
34 void ShowBanner(const SkBitmap* icon, | 46 void ShowBanner(const SkBitmap* icon, |
35 const base::string16& title) override; | 47 const base::string16& title) override; |
36 | 48 |
37 private: | 49 private: |
| 50 void OnDidRetrieveMetaTagContent(bool success, |
| 51 const std::string& tag_name, |
| 52 const std::string& tag_content, |
| 53 const GURL& expected_url); |
| 54 |
38 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; | 55 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; |
39 std::string native_app_package_; | 56 std::string native_app_package_; |
40 | 57 |
41 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcherAndroid); | 58 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcherAndroid); |
42 }; | 59 }; |
43 | 60 |
44 } // namespace banners | 61 } // namespace banners |
45 | 62 |
46 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_DATA_FETCHER_ANDROID_H_ | 63 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_DATA_FETCHER_ANDROID_H_ |
OLD | NEW |