summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/offline/offline_load_page.h
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-15 03:40:23 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-15 03:40:23 +0000
commit6692b0d7bca9e0e3327d371c312196f3af9ed7c6 (patch)
treee589215d311709b95cdbdbae330ae86c439b46a4 /chrome/browser/chromeos/offline/offline_load_page.h
parent2c77c96e4c474ff213c4cf2ed850970c48bbced0 (diff)
downloadchromium_src-6692b0d7bca9e0e3327d371c312196f3af9ed7c6.zip
chromium_src-6692b0d7bca9e0e3327d371c312196f3af9ed7c6.tar.gz
chromium_src-6692b0d7bca9e0e3327d371c312196f3af9ed7c6.tar.bz2
Show offline interstitial page when offline and reload when reconnected to network.
* Added OfflineResourceHandler that intercept the request and show interstitial page. * Added OfflineLoadPage that is shown when offline. This gets deleted when - User pressed "Load now" btton to proceed or - User pressed "Cancel" button to cancel loading - Network become available. The page first appears as blank page (a little darker than white for now. I'll update when mock is ready), and then options become available after 3 seconds maximum. * Added unit test for OfflineLoadPage class. * OfflineLoadService class to control when/if a load request should proceed regardless of network status. The current implementation is tentative and will proceed if if loading was requested in a given tab. I'll revisit this class to improve the logic in separate CL later. Known Issue: - thumbnail is not working yet. I'll working on this in separate Cl. - a tab shows URL instead of title string. I'll fix this in separate CL. - InitNavigationParams in offline_load_page_unittest is copied from safe_browsing_blocking_page_unittest. I'll move this to common place in separate CL. (hopefully before checking this in) BUG=chromium-os:3605 TEST=unit test: offline_load_page_unittest manual: disable wifi and ethernet, then login. chrome will show the offline page when tab is activated. Enable network (wifi or ethernet) and all tab will start loading again. Review URL: http://codereview.chromium.org/2931005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/offline/offline_load_page.h')
-rw-r--r--chrome/browser/chromeos/offline/offline_load_page.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/offline/offline_load_page.h b/chrome/browser/chromeos/offline/offline_load_page.h
new file mode 100644
index 0000000..3363853
--- /dev/null
+++ b/chrome/browser/chromeos/offline/offline_load_page.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2010 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 "chrome/browser/chromeos/network_state_notifier.h"
+#include "chrome/browser/tab_contents/interstitial_page.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_service.h"
+
+class TabContents;
+
+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 InterstitialPage {
+ public:
+ // A delegate class that is called when the interstitinal page
+ // is closed.
+ class Delegate {
+ public:
+ Delegate() {}
+ virtual ~Delegate() {}
+ // Called when a user selected to proceed or not to proceed
+ // with loading.
+ virtual void OnBlockingPageComplete(bool proceed) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Delegate);
+ };
+ static void Show(int process_host_id, int render_view_id,
+ const GURL& url, Delegate* delegate);
+ // Import show here so that overloading works.
+ using InterstitialPage::Show;
+
+ protected:
+ // Create a offline load page for the |tab_contents|.
+ OfflineLoadPage(TabContents* tab_contents, const GURL& url,
+ Delegate* delegate);
+ virtual ~OfflineLoadPage() {}
+
+ private:
+ // InterstitialPage implementation.
+ virtual std::string GetHTMLContents();
+ virtual void CommandReceived(const std::string& command);
+ virtual void Proceed();
+ virtual void DontProceed();
+
+ // Overrides InterstitialPage's Observe.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ Delegate* delegate_;
+ NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(OfflineLoadPage);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_OFFLINE_OFFLINE_LOAD_PAGE_H_