Popular sites on the NTP: Try to keep the ordering constant
[chromium-blink-merge.git] / content / public / browser / interstitial_page.h
blob71b8707e54dfa88395cecda7ce7c4cd794d65e06
1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_INTERSTITIAL_PAGE_H_
6 #define CONTENT_PUBLIC_BROWSER_INTERSTITIAL_PAGE_H_
8 #include "content/common/content_export.h"
10 class GURL;
12 namespace gfx {
13 class Size;
16 namespace content {
18 class InterstitialPageDelegate;
19 class RenderFrameHost;
20 class WebContents;
22 // This class is used for showing interstitial pages, pages that show some
23 // informative message asking for user validation before reaching the target
24 // page. (Navigating to a page served over bad HTTPS or a page containing
25 // malware are typical cases where an interstitial is required.)
27 // If specified in the Create function, this class creates a navigation entry so
28 // that when the interstitial shows, the current entry is the target URL.
30 // InterstitialPage instances take care of deleting themselves when closed
31 // through a navigation, the WebContents closing them or the tab containing them
32 // being closed.
34 class InterstitialPage {
35 public:
36 // Creates an interstitial page to show in |web_contents|. |new_navigation|
37 // should be set to true when the interstitial is caused by loading a new
38 // page, in which case a temporary navigation entry is created with the URL
39 // |url| and added to the navigation controller (so the interstitial page
40 // appears as a new navigation entry). |new_navigation| should be false when
41 // the interstitial was triggered by a loading a sub-resource in a page. Takes
42 // ownership of |delegate|.
44 // Reloading the interstitial page will result in a new navigation to |url|.
45 CONTENT_EXPORT static InterstitialPage* Create(
46 WebContents* web_contents,
47 bool new_navigation,
48 const GURL& url,
49 InterstitialPageDelegate* delegate);
51 // Retrieves the InterstitialPage if any associated with the specified
52 // |web_contents|.
53 CONTENT_EXPORT static InterstitialPage* GetInterstitialPage(
54 WebContents* web_contents);
56 virtual ~InterstitialPage() {}
58 // Shows the interstitial page in the tab.
59 virtual void Show() = 0;
61 // Hides the interstitial page.
62 virtual void Hide() = 0;
64 // Reverts to the page showing before the interstitial.
65 // Delegates should call this method when the user has chosen NOT to proceed
66 // to the target URL.
67 // Warning: if |new_navigation| was set to true in the constructor, 'this'
68 // will be deleted when this method returns.
69 virtual void DontProceed() = 0;
71 // Delegates should call this method when the user has chosen to proceed to
72 // the target URL.
73 // Warning: 'this' has been deleted when this method returns.
74 virtual void Proceed() = 0;
76 // Sizes the RenderViewHost showing the actual interstitial page contents.
77 virtual void SetSize(const gfx::Size& size) = 0;
79 // Sets the focus to the interstitial.
80 virtual void Focus() = 0;
82 // Gets the RenderFrameHost associated with
83 // the interstitial page's main frame.
84 virtual RenderFrameHost* GetMainFrame() const = 0;
86 virtual InterstitialPageDelegate* GetDelegateForTesting() = 0;
87 virtual void DontCreateViewForTesting() = 0;
90 } // namespace content
92 #endif // CONTENT_PUBLIC_BROWSER_INTERSTITIAL_PAGE_H_