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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_ANDROID_H_
8 #include "base/android/jni_android.h"
9 #include "base/android/jni_weak_ref.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/android/banners/app_banner_data_fetcher_android.h"
12 #include "chrome/browser/banners/app_banner_debug_log.h"
13 #include "chrome/browser/banners/app_banner_manager.h"
16 class AppBannerDataFetcherAndroid
;
18 // Extends the AppBannerManager to support native Android apps.
19 // TODO(dfalcantara): Flip it so the C++ AppBannerManagerAndroid owns the
20 // Java AppBannerManager, move ownership of the AppBannerManagerAndroid to
21 // the TabAndroid class, then move functions for retriving info from Java to
22 // the AppBannerDataFetcherAndroid.
23 class AppBannerManagerAndroid
: public AppBannerManager
{
25 // Registers native methods.
26 static bool Register(JNIEnv
* env
);
28 AppBannerManagerAndroid(JNIEnv
* env
, jobject obj
);
29 ~AppBannerManagerAndroid() override
;
31 // Destroys the AppBannerManagerAndroid.
32 void Destroy(JNIEnv
* env
, jobject obj
);
34 // Observes a new WebContents, if necessary.
35 void ReplaceWebContents(JNIEnv
* env
,
37 jobject jweb_contents
);
39 // Return whether a BitmapFetcher is active.
40 bool IsFetcherActive(JNIEnv
* env
, jobject jobj
);
42 // Called when the Java-side has retrieved information for the app.
43 // Returns |false| if an icon fetch couldn't be kicked off.
44 bool OnAppDetailsRetrieved(JNIEnv
* env
,
52 AppBannerDataFetcher
* CreateAppBannerDataFetcher(
53 base::WeakPtr
<AppBannerDataFetcher::Delegate
> weak_delegate
) override
;
56 // AppBannerDataFetcher::Delegate overrides.
57 bool HandleNonWebApp(const std::string
& platform
,
59 const std::string
& id
) override
;
61 bool CheckPlatformAndId(const std::string
& platform
, const std::string
& id
);
63 bool CheckFetcherMatchesContents();
65 std::string
ExtractQueryValueForName(const GURL
& url
,
66 const std::string
& name
);
68 // AppBannerManager on the Java side.
69 JavaObjectWeakGlobalRef weak_java_banner_view_manager_
;
71 DISALLOW_COPY_AND_ASSIGN(AppBannerManagerAndroid
);
72 }; // class AppBannerManagerAndroid
74 } // namespace banners
76 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_ANDROID_H_