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

Side by Side Diff: chrome/browser/android/banners/app_banner_manager.h

Issue 884623003: Suppress native app install banner if the site has a manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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 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"
11 #include "chrome/browser/android/meta_tag_observer.h"
12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" 11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
12 #include "content/public/browser/web_contents_observer.h"
13 13
14 namespace content { 14 namespace content {
15 struct FrameNavigateParams; 15 struct FrameNavigateParams;
16 struct LoadCommittedDetails; 16 struct LoadCommittedDetails;
17 struct Manifest;
17 } // namespace content 18 } // namespace content
18 19
19 /** 20 /**
20 * Manages when an app banner is created or dismissed. 21 * Manages when an app banner is created or dismissed.
21 * 22 *
22 * Hooks the wiring together for getting the data for a particular app. 23 * Hooks the wiring together for getting the data for a particular app.
23 * Monitors at most one package at a time, and tracks the info for the 24 * Monitors at most one package at a time, and tracks the info for the
24 * most recent app that was requested. Any work in progress for other apps is 25 * most recent app that was requested. Any work in progress for other apps is
25 * discarded. 26 * discarded.
26 * 27 *
(...skipping 23 matching lines...) Expand all
50 * 51 *
51 * Because of the asynchronous nature of this pipeline, it's entirely possible 52 * Because of the asynchronous nature of this pipeline, it's entirely possible
52 * that a request to show a banner is interrupted by another request. The 53 * that a request to show a banner is interrupted by another request. The
53 * Java side manages what happens in these situations, which will usually result 54 * Java side manages what happens in these situations, which will usually result
54 * in dropping the old banner request on the floor. 55 * in dropping the old banner request on the floor.
55 */ 56 */
56 57
57 namespace banners { 58 namespace banners {
58 59
59 class AppBannerManager : public chrome::BitmapFetcherDelegate, 60 class AppBannerManager : public chrome::BitmapFetcherDelegate,
60 public MetaTagObserver { 61 public content::WebContentsObserver {
61 public: 62 public:
62 AppBannerManager(JNIEnv* env, jobject obj); 63 AppBannerManager(JNIEnv* env, jobject obj);
63 virtual ~AppBannerManager(); 64 virtual ~AppBannerManager();
64 65
65 // Destroys the AppBannerManager. 66 // Destroys the AppBannerManager.
66 void Destroy(JNIEnv* env, jobject obj); 67 void Destroy(JNIEnv* env, jobject obj);
67 68
68 // Blocks a banner for |package_name| from appearing on the domain for |url|. 69 // Blocks a banner for |package_name| from appearing on the domain for |url|.
69 void BlockBanner(JNIEnv* env, jobject obj, jstring jurl, jstring jpackage); 70 void BlockBanner(JNIEnv* env, jobject obj, jstring jurl, jstring jpackage);
70 71
71 // Observes a new WebContents, if necessary. 72 // Observes a new WebContents, if necessary.
72 void ReplaceWebContents(JNIEnv* env, 73 void ReplaceWebContents(JNIEnv* env,
73 jobject obj, 74 jobject obj,
74 jobject jweb_contents); 75 jobject jweb_contents);
75 76
76 // Fetches the icon at the give URL. 77 // Fetches the icon at the give URL.
77 // Returns |false| if this couldn't be kicked off. 78 // Returns |false| if this couldn't be kicked off.
78 bool FetchIcon(JNIEnv* env, 79 bool FetchIcon(JNIEnv* env,
79 jobject obj, 80 jobject obj,
80 jstring jimage_url); 81 jstring jimage_url);
81 82
82 // WebContentsObserver overrides. 83 // WebContentsObserver overrides.
83 virtual void DidNavigateMainFrame( 84 virtual void DidNavigateMainFrame(
84 const content::LoadCommittedDetails& details, 85 const content::LoadCommittedDetails& details,
85 const content::FrameNavigateParams& params) override; 86 const content::FrameNavigateParams& params) override;
87 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host,
88 const GURL& validated_url) override;
89 virtual bool OnMessageReceived(const IPC::Message& message) override;
90
86 91
87 // BitmapFetcherDelegate overrides. 92 // BitmapFetcherDelegate overrides.
88 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) override; 93 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) override;
89 94
90 private: 95 private:
91 // Kicks off the process of showing a banner for the package designated by 96 // Called when the manifest has been retrieved, or if there is no manifest to
92 // |tag_content| on the page at the |expected_url|. 97 // retrieve.
93 virtual void HandleMetaTagContent(const std::string& tag_content, 98 void OnDidGetManifest(const content::Manifest& manifest);
94 const GURL& expected_url) override; 99
100 // Called when the renderer has returned information about the meta tag.
101 // If there is some metadata for the play store tag, this kicks off the
102 // process of showing a banner for the package designated by |tag_content| on
103 // the page at the |expected_url|.
104 void OnDidRetrieveMetaTagContent(bool success,
105 const std::string& tag_name,
106 const std::string& tag_content,
107 const GURL& expected_url);
95 108
96 // Fetches the icon for an app. 109 // Fetches the icon for an app.
97 scoped_ptr<chrome::BitmapFetcher> fetcher_; 110 scoped_ptr<chrome::BitmapFetcher> fetcher_;
111 GURL validated_url_;
98 112
99 // AppBannerManager on the Java side. 113 // AppBannerManager on the Java side.
100 JavaObjectWeakGlobalRef weak_java_banner_view_manager_; 114 JavaObjectWeakGlobalRef weak_java_banner_view_manager_;
101 115
102 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); 116 DISALLOW_COPY_AND_ASSIGN(AppBannerManager);
103 }; // class AppBannerManager 117 }; // class AppBannerManager
104 118
105 // Register native methods 119 // Register native methods
106 bool RegisterAppBannerManager(JNIEnv* env); 120 bool RegisterAppBannerManager(JNIEnv* env);
107 121
108 } // namespace banners 122 } // namespace banners
109 123
110 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ 124 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698