summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/offline/offline_load_page.h
blob: 5288291975a943e54d2e3ab04038d29d3b34f79b (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
// 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_
#pragma once

#include <string>

#include "base/compiler_specific.h"
#include "base/task.h"
#include "chrome/browser/tab_contents/chrome_interstitial_page.h"
#include "net/base/network_change_notifier.h"

class Extension;
class OfflineResourceHandler;

namespace base {
class DictionaryValue;
}

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 ChromeInterstitialPage,
                        public net::NetworkChangeNotifier::OnlineStateObserver {
 public:
  // Create a offline load page for the |web_contents|.
  OfflineLoadPage(content::WebContents* web_contents, const GURL& url,
                  OfflineResourceHandler* handler);

 protected:
  virtual ~OfflineLoadPage();

  // Overridden by tests.
  virtual void NotifyBlockingPageComplete(bool proceed);

 private:
  // ChromeInterstitialPage implementation.
  virtual std::string GetHTMLContents() OVERRIDE;
  virtual void CommandReceived(const std::string& command) OVERRIDE;
  virtual void Proceed() OVERRIDE;
  virtual void DontProceed() OVERRIDE;

  // net::NetworkChangeNotifier::OnlineStateObserver overrides.
  virtual void OnOnlineStateChanged(bool online) OVERRIDE;

  // Retrieves template strings of the offline page for app and
  // normal site.
  void GetAppOfflineStrings(const Extension* app,
                            const string16& faield_url,
                            base::DictionaryValue* strings) const;
  void GetNormalOfflineStrings(const string16& faield_url,
                               base::DictionaryValue* strings) const;

  // True if there is a mobile network is available but
  // has not been activated.
  bool ShowActivationMessage();

  scoped_refptr<OfflineResourceHandler> handler_;

  // True if the proceed is chosen.
  bool proceeded_;

  bool in_test_;

  DISALLOW_COPY_AND_ASSIGN(OfflineLoadPage);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_