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.
4 
5 #ifndef CONTENT_PUBLIC_BROWSER_INTERSTITIAL_PAGE_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_INTERSTITIAL_PAGE_DELEGATE_H_
7 
8 #include <string>
9 
10 #include "content/common/content_export.h"
11 
12 namespace blink {
13 namespace mojom {
14 class RendererPreferences;
15 }
16 }  // namespace blink
17 
18 namespace content {
19 
20 class NavigationEntry;
21 
22 // Controls and provides the html for an interstitial page. The delegate is
23 // owned by the InterstitialPage.
24 class CONTENT_EXPORT InterstitialPageDelegate {
25  public:
26   // An identifier used to identify an InterstitialPage.
27   typedef const void* TypeID;
28 
~InterstitialPageDelegate()29   virtual ~InterstitialPageDelegate() {}
30 
31   // Return the HTML that should be displayed in the page.
32   virtual std::string GetHTMLContents() = 0;
33 
34   // Called when the interstitial is proceeded or cancelled. Note that this may
35   // be called by content directly even if the embedder didn't call Proceed or
36   // DontProceed on InterstitialPage, since navigations etc may cancel them.
OnProceed()37   virtual void OnProceed() {}
OnDontProceed()38   virtual void OnDontProceed() {}
39 
40   // Invoked when the page sent a command through DOMAutomation.
CommandReceived(const std::string & command)41   virtual void CommandReceived(const std::string& command) {}
42 
43   // Invoked with the NavigationEntry that is going to be added to the
44   // navigation controller.
45   // Gives an opportunity to delegates to set states on the |entry|.
46   // Note that this is only called if the InterstitialPage was constructed with
47   // |new_navigation| set to true.
OverrideEntry(content::NavigationEntry * entry)48   virtual void OverrideEntry(content::NavigationEntry* entry) {}
49 
50   // Allows the delegate to override the renderer preferences structure that's
51   // sent to the new RenderViewHost.
OverrideRendererPrefs(blink::mojom::RendererPreferences * prefs)52   virtual void OverrideRendererPrefs(blink::mojom::RendererPreferences* prefs) {
53   }
54 
55   // Return the interstitial type for testing.
56   virtual TypeID GetTypeForTesting();
57 };
58 
59 }  // namespace content
60 
61 #endif  // CONTENT_PUBLIC_BROWSER_INTERSTITIAL_PAGE_DELEGATE_H_
62