blob: d75b34ecc0ea275077377f32b0b3880934209d32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_
#define CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_
#include <string>
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "content/public/browser/interstitial_page_delegate.h"
#include "net/base/network_change_notifier.h"
#include "url/gurl.h"
namespace base {
class DictionaryValue;
}
namespace content {
class InterstitialPage;
class WebContents;
}
namespace extensions {
class Extension;
}
namespace chromeos {
// OfflineLoadPage class shows the interstitial page that is shown
// when no network is available and hides when some network (either
// one of wifi, 3g or ethernet) becomes available.
// It deletes itself when the interstitial page is closed.
class OfflineLoadPage
: public content::InterstitialPageDelegate,
public net::NetworkChangeNotifier::ConnectionTypeObserver {
public:
// Passed a boolean indicating whether or not it is OK to proceed with the
// page load.
typedef base::Callback<void(bool /*proceed*/)> CompletionCallback;
// Create a offline load page for the |web_contents|. The callback will be
// run on the IO thread.
OfflineLoadPage(content::WebContents* web_contents, const GURL& url,
const CompletionCallback& callback);
void Show();
protected:
virtual ~OfflineLoadPage();
// Overridden by tests.
virtual void NotifyBlockingPageComplete(bool proceed);
private:
friend class TestOfflineLoadPage;
// InterstitialPageDelegate implementation.
virtual std::string GetHTMLContents() override;
virtual void CommandReceived(const std::string& command) override;
virtual void OverrideRendererPrefs(
content::RendererPreferences* prefs) override;
virtual void OnProceed() override;
virtual void OnDontProceed() override;
// net::NetworkChangeNotifier::ConnectionTypeObserver overrides.
virtual void OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) override;
CompletionCallback callback_;
// True if the proceed is chosen.
bool proceeded_;
content::WebContents* web_contents_;
GURL url_;
content::InterstitialPage* interstitial_page_; // Owns us.
DISALLOW_COPY_AND_ASSIGN(OfflineLoadPage);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_
|