Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5656)

Unified Diff: chrome/browser/chromeos/offline/offline_load_page.cc

Issue 9323071: Use InterstitialPage through a delegate interface instead of deriving from it. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/offline/offline_load_page.cc
===================================================================
--- chrome/browser/chromeos/offline/offline_load_page.cc (revision 120733)
+++ chrome/browser/chromeos/offline/offline_load_page.cc (working copy)
@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
@@ -21,6 +22,7 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/url_constants.h"
+#include "content/browser/tab_contents/interstitial_page.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
@@ -49,10 +51,13 @@
OfflineLoadPage::OfflineLoadPage(WebContents* web_contents,
const GURL& url,
const CompletionCallback& callback)
- : ChromeInterstitialPage(web_contents, true, url),
- callback_(callback),
- proceeded_(false) {
+ : callback_(callback),
+ proceeded_(false),
+ web_contents_(web_contents),
+ url_(url) {
net::NetworkChangeNotifier::AddOnlineStateObserver(this);
+ interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this);
+ interstitial_page_->Show();
}
OfflineLoadPage::~OfflineLoadPage() {
@@ -76,20 +81,21 @@
bool rtl = base::i18n::IsRTL();
strings.SetString("textdirection", rtl ? "rtl" : "ltr");
- string16 failed_url(ASCIIToUTF16(url().spec()));
+ string16 failed_url(ASCIIToUTF16(url_.spec()));
if (rtl)
base::i18n::WrapStringWithLTRFormatting(&failed_url);
strings.SetString("url", failed_url);
// The offline page for app has icons and slightly different message.
- Profile* profile = Profile::FromBrowserContext(tab()->GetBrowserContext());
+ Profile* profile = Profile::FromBrowserContext(
+ web_contents_->GetBrowserContext());
DCHECK(profile);
const Extension* extension = NULL;
ExtensionService* extensions_service = profile->GetExtensionService();
// Extension service does not exist in test.
if (extensions_service)
extension = extensions_service->extensions()->GetHostedAppByURL(
- ExtensionURLInfo(url()));
+ ExtensionURLInfo(url_));
if (extension)
GetAppOfflineStrings(extension, failed_url, &strings);
@@ -102,6 +108,27 @@
return jstemplate_builder::GetI18nTemplateHtml(html, &strings);
}
+ void OfflineLoadPage::OverrideRendererPrefs(
+ content::RendererPreferences* prefs) {
+ Profile* profile = Profile::FromBrowserContext(
+ web_contents_->GetBrowserContext());
+ renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
+ }
+
+void OfflineLoadPage::OnProceed() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ proceeded_ = true;
+ NotifyBlockingPageComplete(true);
+}
+
+void OfflineLoadPage::OnDontProceed() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ // Ignore if it's already proceeded.
+ if (proceeded_)
+ return;
+ NotifyBlockingPageComplete(false);
+}
+
void OfflineLoadPage::GetAppOfflineStrings(
const Extension* app,
const string16& failed_url,
@@ -128,7 +155,7 @@
void OfflineLoadPage::GetNormalOfflineStrings(
const string16& failed_url, DictionaryValue* strings) const {
- strings->SetString("title", tab()->GetTitle());
+ strings->SetString("title", web_contents_->GetTitle());
// No icon for normal web site.
strings->SetString("display_icon", "none");
@@ -148,9 +175,9 @@
}
// TODO(oshima): record action for metrics.
if (command == "proceed") {
- Proceed();
+ interstitial_page_->Proceed();
} else if (command == "dontproceed") {
- DontProceed();
+ interstitial_page_->DontProceed();
} else if (command == "open_network_settings") {
Browser* browser = BrowserList::GetLastActive();
DCHECK(browser);
@@ -169,29 +196,13 @@
BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed));
}
-void OfflineLoadPage::Proceed() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- proceeded_ = true;
- NotifyBlockingPageComplete(true);
- InterstitialPage::Proceed();
-}
-
-void OfflineLoadPage::DontProceed() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // Ignore if it's already proceeded.
- if (proceeded_)
- return;
- NotifyBlockingPageComplete(false);
- InterstitialPage::DontProceed();
-}
-
void OfflineLoadPage::OnOnlineStateChanged(bool online) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DVLOG(1) << "OnlineStateObserver notification received: state="
<< (online ? "online" : "offline");
if (online) {
net::NetworkChangeNotifier::RemoveOnlineStateObserver(this);
- Proceed();
+ interstitial_page_->Proceed();
}
}
« no previous file with comments | « chrome/browser/chromeos/offline/offline_load_page.h ('k') | chrome/browser/chromeos/offline/offline_load_page_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698