| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ | 6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 * in dropping the old banner request on the floor. | 57 * in dropping the old banner request on the floor. |
| 58 */ | 58 */ |
| 59 | 59 |
| 60 namespace banners { | 60 namespace banners { |
| 61 | 61 |
| 62 class AppBannerManager : public chrome::BitmapFetcherDelegate, | 62 class AppBannerManager : public chrome::BitmapFetcherDelegate, |
| 63 public content::WebContentsObserver, | 63 public content::WebContentsObserver, |
| 64 public AppBannerInfoBarDelegate::AppDelegate { | 64 public AppBannerInfoBarDelegate::AppDelegate { |
| 65 public: | 65 public: |
| 66 AppBannerManager(JNIEnv* env, jobject obj); | 66 AppBannerManager(JNIEnv* env, jobject obj); |
| 67 virtual ~AppBannerManager(); | 67 ~AppBannerManager() override; |
| 68 | 68 |
| 69 // Destroys the AppBannerManager. | 69 // Destroys the AppBannerManager. |
| 70 void Destroy(JNIEnv* env, jobject obj); | 70 void Destroy(JNIEnv* env, jobject obj); |
| 71 | 71 |
| 72 // Blocks a banner for |package_name| from appearing on the domain for |url|. | 72 // Blocks a banner for |package_name| from appearing on the domain for |url|. |
| 73 void BlockBanner(JNIEnv* env, jobject obj, jstring jurl, jstring jpackage); | 73 void BlockBanner(JNIEnv* env, jobject obj, jstring jurl, jstring jpackage); |
| 74 | 74 |
| 75 // Observes a new WebContents, if necessary. | 75 // Observes a new WebContents, if necessary. |
| 76 void ReplaceWebContents(JNIEnv* env, | 76 void ReplaceWebContents(JNIEnv* env, |
| 77 jobject obj, | 77 jobject obj, |
| 78 jobject jweb_contents); | 78 jobject jweb_contents); |
| 79 | 79 |
| 80 // Fetches the icon at the given URL asynchronously. | 80 // Fetches the icon at the given URL asynchronously. |
| 81 // Returns |false| if this couldn't be kicked off. | 81 // Returns |false| if this couldn't be kicked off. |
| 82 bool FetchIcon(JNIEnv* env, | 82 bool FetchIcon(JNIEnv* env, |
| 83 jobject obj, | 83 jobject obj, |
| 84 jstring jimage_url); | 84 jstring jimage_url); |
| 85 | 85 |
| 86 // Fetches the icon at the given URL asynchronously. | 86 // Fetches the icon at the given URL asynchronously. |
| 87 // Returns |false| if this couldn't be kicked off. | 87 // Returns |false| if this couldn't be kicked off. |
| 88 bool FetchIcon(const GURL& image_url); | 88 bool FetchIcon(const GURL& image_url); |
| 89 | 89 |
| 90 // Installs the app defined by the manifest. | 90 // Installs the app defined by the manifest. |
| 91 // TODO(dfalcantara): Fold into Install() when more CLs land. | 91 // TODO(dfalcantara): Fold into Install() when more CLs land. |
| 92 static void InstallManifestApp(const content::Manifest& manifest, | 92 static void InstallManifestApp(const content::Manifest& manifest, |
| 93 const SkBitmap& icon); | 93 const SkBitmap& icon); |
| 94 | 94 |
| 95 // WebContentsObserver overrides. | 95 // WebContentsObserver overrides. |
| 96 virtual void DidNavigateMainFrame( | 96 void DidNavigateMainFrame( |
| 97 const content::LoadCommittedDetails& details, | 97 const content::LoadCommittedDetails& details, |
| 98 const content::FrameNavigateParams& params) override; | 98 const content::FrameNavigateParams& params) override; |
| 99 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 99 void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
| 100 const GURL& validated_url) override; | 100 const GURL& validated_url) override; |
| 101 virtual bool OnMessageReceived(const IPC::Message& message) override; | 101 bool OnMessageReceived(const IPC::Message& message) override; |
| 102 | 102 |
| 103 // BitmapFetcherDelegate overrides. | 103 // BitmapFetcherDelegate overrides. |
| 104 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) override; | 104 void OnFetchComplete(const GURL url, const SkBitmap* bitmap) override; |
| 105 | 105 |
| 106 // AppBannerInfoBarDelegate::AppDelegate overrides. | 106 // AppBannerInfoBarDelegate::AppDelegate overrides. |
| 107 virtual void Block() const override; | 107 void Block() const override; |
| 108 virtual void Install() const override; | 108 void Install() const override; |
| 109 virtual gfx::Image GetIcon() const override; | 109 gfx::Image GetIcon() const override; |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 // Gets the preferred icon size for the banner icons. | 112 // Gets the preferred icon size for the banner icons. |
| 113 int GetPreferredIconSize(); | 113 int GetPreferredIconSize(); |
| 114 | 114 |
| 115 // Called when the manifest has been retrieved, or if there is no manifest to | 115 // Called when the manifest has been retrieved, or if there is no manifest to |
| 116 // retrieve. | 116 // retrieve. |
| 117 void OnDidGetManifest(const content::Manifest& manifest); | 117 void OnDidGetManifest(const content::Manifest& manifest); |
| 118 | 118 |
| 119 // Called when the renderer has returned information about the meta tag. | 119 // Called when the renderer has returned information about the meta tag. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); | 137 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); |
| 138 }; // class AppBannerManager | 138 }; // class AppBannerManager |
| 139 | 139 |
| 140 // Register native methods | 140 // Register native methods |
| 141 bool RegisterAppBannerManager(JNIEnv* env); | 141 bool RegisterAppBannerManager(JNIEnv* env); |
| 142 | 142 |
| 143 } // namespace banners | 143 } // namespace banners |
| 144 | 144 |
| 145 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ | 145 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ |
| OLD | NEW |