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

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

Issue 1092193004: Use related_applications manifest fields when showing native app banners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 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_BANNERS_APP_BANNER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
6 #define CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 25 matching lines...) Expand all
36 // Returns whether or not the URLs match for everything except for the ref. 36 // Returns whether or not the URLs match for everything except for the ref.
37 static bool URLsAreForTheSamePage(const GURL& first, const GURL& second); 37 static bool URLsAreForTheSamePage(const GURL& first, const GURL& second);
38 38
39 explicit AppBannerManager(int icon_size); 39 explicit AppBannerManager(int icon_size);
40 ~AppBannerManager() override; 40 ~AppBannerManager() override;
41 41
42 // WebContentsObserver overrides. 42 // WebContentsObserver overrides.
43 void DidFinishLoad(content::RenderFrameHost* render_frame_host, 43 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
44 const GURL& validated_url) override; 44 const GURL& validated_url) override;
45 45
46 // AppBannerDataFetcher::Delegate overrides.
47 bool OnInvalidManifest(AppBannerDataFetcher* fetcher) override;
48
49 protected: 46 protected:
50 void ReplaceWebContents(content::WebContents* web_contents); 47 void ReplaceWebContents(content::WebContents* web_contents);
51 48
52 // Creates an AppBannerDataFetcher, which constructs an app banner. 49 // Creates an AppBannerDataFetcher, which constructs an app banner.
53 virtual AppBannerDataFetcher* CreateAppBannerDataFetcher( 50 virtual AppBannerDataFetcher* CreateAppBannerDataFetcher(
54 base::WeakPtr<AppBannerDataFetcher::Delegate> weak_delegate, 51 base::WeakPtr<AppBannerDataFetcher::Delegate> weak_delegate,
55 const int ideal_icon_size); 52 const int ideal_icon_size);
56 53
57 // Return whether the AppBannerDataFetcher is active. 54 // Return whether the AppBannerDataFetcher is active.
58 bool IsFetcherActive(); 55 bool IsFetcherActive();
59 56
60 scoped_refptr<AppBannerDataFetcher> data_fetcher() { return data_fetcher_; } 57 scoped_refptr<AppBannerDataFetcher> data_fetcher() { return data_fetcher_; }
61 int ideal_icon_size() { return ideal_icon_size_; } 58 int ideal_icon_size() { return ideal_icon_size_; }
62 59
63 private: 60 private:
61 // AppBannerDataFetcher::Delegate overrides.
62 bool HandleNonWebApp(const std::string& platform,
63 const GURL& url,
64 const std::string& id) override;
65
64 // Called after the manager sends a message to the renderer regarding its 66 // Called after the manager sends a message to the renderer regarding its
65 // intention to show a prompt. The renderer will send a message back with the 67 // intention to show a prompt. The renderer will send a message back with the
66 // opportunity to cancel. 68 // opportunity to cancel.
67 void OnBannerPromptReply(content::RenderFrameHost* render_frame_host, 69 void OnBannerPromptReply(content::RenderFrameHost* render_frame_host,
68 int request_id, 70 int request_id,
69 blink::WebAppBannerPromptReply reply); 71 blink::WebAppBannerPromptReply reply);
70 72
71 // Cancels an active DataFetcher, stopping its banners from appearing. 73 // Cancels an active DataFetcher, stopping its banners from appearing.
72 void CancelActiveFetcher(); 74 void CancelActiveFetcher();
73 75
74 // Ideal icon size to use. 76 // Ideal icon size to use.
75 const int ideal_icon_size_; 77 const int ideal_icon_size_;
76 78
77 // Fetches the data required to display a banner for the current page. 79 // Fetches the data required to display a banner for the current page.
78 scoped_refptr<AppBannerDataFetcher> data_fetcher_; 80 scoped_refptr<AppBannerDataFetcher> data_fetcher_;
79 81
80 // A weak pointer is used as the lifetime of the ServiceWorkerContext is 82 // A weak pointer is used as the lifetime of the ServiceWorkerContext is
81 // longer than the lifetime of this banner manager. The banner manager 83 // longer than the lifetime of this banner manager. The banner manager
82 // might be gone when calls sent to the ServiceWorkerContext are completed. 84 // might be gone when calls sent to the ServiceWorkerContext are completed.
83 base::WeakPtrFactory<AppBannerManager> weak_factory_; 85 base::WeakPtrFactory<AppBannerManager> weak_factory_;
84 86
85 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); 87 DISALLOW_COPY_AND_ASSIGN(AppBannerManager);
86 }; // class AppBannerManager 88 }; // class AppBannerManager
87 89
88 } // namespace banners 90 } // namespace banners
89 91
90 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ 92 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_data_fetcher_unittest.cc ('k') | chrome/browser/banners/app_banner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698