OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/task.h" | 11 #include "base/task.h" |
12 #include "chrome/browser/chromeos/network_state_notifier.h" | |
13 #include "chrome/browser/tab_contents/chrome_interstitial_page.h" | 12 #include "chrome/browser/tab_contents/chrome_interstitial_page.h" |
13 #include "net/base/network_change_notifier.h" | |
14 | 14 |
15 class Extension; | 15 class Extension; |
16 class TabContents; | 16 class TabContents; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class DictionaryValue; | 19 class DictionaryValue; |
20 } | 20 } |
21 | 21 |
22 namespace chromeos { | 22 namespace chromeos { |
23 | 23 |
24 // OfflineLoadPage class shows the interstitial page that is shown | 24 // OfflineLoadPage class shows the interstitial page that is shown |
25 // when no network is available and hides when some network (either | 25 // when no network is available and hides when some network (either |
26 // one of wifi, 3g or ethernet) becomes available. | 26 // one of wifi, 3g or ethernet) becomes available. |
27 // It deletes itself when the interstitial page is closed. | 27 // It deletes itself when the interstitial page is closed. |
28 class OfflineLoadPage : public ChromeInterstitialPage { | 28 class OfflineLoadPage : public ChromeInterstitialPage, |
29 net::NetworkChangeNotifier::OnlineStateObserver { | |
29 public: | 30 public: |
30 // A delegate class that is called when the interstitinal page | 31 // A delegate class that is called when the interstitinal page |
31 // is closed. | 32 // is closed. |
32 class Delegate { | 33 class Delegate { |
33 public: | 34 public: |
34 Delegate() {} | 35 Delegate() {} |
35 virtual ~Delegate() {} | 36 virtual ~Delegate() {} |
36 // Called when a user selected to proceed or not to proceed | 37 // Called when a user selected to proceed or not to proceed |
37 // with loading. | 38 // with loading. |
38 virtual void OnBlockingPageComplete(bool proceed) = 0; | 39 virtual void OnBlockingPageComplete(bool proceed) = 0; |
(...skipping 17 matching lines...) Expand all Loading... | |
56 in_test_ = true; | 57 in_test_ = true; |
57 } | 58 } |
58 | 59 |
59 private: | 60 private: |
60 // ChromeInterstitialPage implementation. | 61 // ChromeInterstitialPage implementation. |
61 virtual std::string GetHTMLContents(); | 62 virtual std::string GetHTMLContents(); |
62 virtual void CommandReceived(const std::string& command); | 63 virtual void CommandReceived(const std::string& command); |
63 virtual void Proceed(); | 64 virtual void Proceed(); |
64 virtual void DontProceed(); | 65 virtual void DontProceed(); |
65 | 66 |
66 // Overrides ChromeInterstitialPage's Observe. | 67 virtual void OnOnlineStateChanged(bool online); |
xiyuan
2011/09/20 04:20:37
nit: OVERRIDE
zel
2011/09/20 15:27:56
Done.
| |
67 virtual void Observe(int type, | |
68 const NotificationSource& source, | |
69 const NotificationDetails& details); | |
70 | 68 |
71 // Retrieves template strings of the offline page for app and | 69 // Retrieves template strings of the offline page for app and |
72 // normal site. | 70 // normal site. |
73 void GetAppOfflineStrings(const Extension* app, | 71 void GetAppOfflineStrings(const Extension* app, |
74 const string16& faield_url, | 72 const string16& faield_url, |
75 base::DictionaryValue* strings) const; | 73 base::DictionaryValue* strings) const; |
76 void GetNormalOfflineStrings(const string16& faield_url, | 74 void GetNormalOfflineStrings(const string16& faield_url, |
77 base::DictionaryValue* strings) const; | 75 base::DictionaryValue* strings) const; |
78 | 76 |
79 // True if there is a mobile network is available but | 77 // True if there is a mobile network is available but |
80 // has not been activated. | 78 // has not been activated. |
81 bool ShowActivationMessage(); | 79 bool ShowActivationMessage(); |
82 | 80 |
83 Delegate* delegate_; | 81 Delegate* delegate_; |
84 NotificationRegistrar registrar_; | 82 NotificationRegistrar registrar_; |
85 | 83 |
86 // True if the proceed is chosen. | 84 // True if the proceed is chosen. |
87 bool proceeded_; | 85 bool proceeded_; |
88 ScopedRunnableMethodFactory<OfflineLoadPage> method_factory_; | 86 ScopedRunnableMethodFactory<OfflineLoadPage> method_factory_; |
89 | 87 |
90 bool in_test_; | 88 bool in_test_; |
91 | 89 |
92 DISALLOW_COPY_AND_ASSIGN(OfflineLoadPage); | 90 DISALLOW_COPY_AND_ASSIGN(OfflineLoadPage); |
93 }; | 91 }; |
94 | 92 |
95 } // namespace chromeos | 93 } // namespace chromeos |
96 | 94 |
97 #endif // CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_ | 95 #endif // CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_ |
OLD | NEW |