Skip to content

Commit

Permalink
Adopt InterstitialPage to RenderViewHost message changes which were i…
Browse files Browse the repository at this point in the history
…ntroduced by http://codereview.chromium.org/6883177.

This makes the buttons on interstitial pages work again.

Committed by sfeuz

Review URL: http://codereview.chromium.org/6904159

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83880 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
markusheintz@chromium.org committed May 3, 2011
1 parent 2178814 commit ef1cef9
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 43 deletions.
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/offline/offline_load_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void OfflineLoadPage::Show(int process_host_id, int render_view_id,
OfflineLoadPage::OfflineLoadPage(TabContents* tab_contents,
const GURL& url,
Delegate* delegate)
: InterstitialPage(tab_contents, true, url),
: ChromeInterstitialPage(tab_contents, true, url),
delegate_(delegate),
proceeded_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
Expand Down Expand Up @@ -211,7 +211,7 @@ void OfflineLoadPage::Observe(NotificationType type,
Proceed();
}
} else {
InterstitialPage::Observe(type, source, details);
ChromeInterstitialPage::Observe(type, source, details);
}
}

Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/chromeos/offline/offline_load_page.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Copyright (c) 2011 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.

Expand All @@ -10,7 +10,7 @@

#include "base/task.h"
#include "chrome/browser/chromeos/network_state_notifier.h"
#include "content/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/tab_contents/chrome_interstitial_page.h"

class DictionaryValue;
class Extension;
Expand All @@ -22,7 +22,7 @@ namespace chromeos {
// 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 {
class OfflineLoadPage : public ChromeInterstitialPage {
public:
// A delegate class that is called when the interstitinal page
// is closed.
Expand All @@ -40,7 +40,7 @@ class OfflineLoadPage : public InterstitialPage {
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;
using ChromeInterstitialPage::Show;

protected:
// Create a offline load page for the |tab_contents|.
Expand All @@ -54,13 +54,13 @@ class OfflineLoadPage : public InterstitialPage {
}

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

// Overrides InterstitialPage's Observe.
// Overrides ChromeInterstitialPage's Observe.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/pdf_unsupported_feature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include "base/version.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/chrome_interstitial_page.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/pref_names.h"
#include "content/browser/plugin_service.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/interstitial_page.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/user_metrics.h"
#include "grit/browser_resources.h"
Expand Down Expand Up @@ -159,18 +159,18 @@ void OpenUsingReader(TabContents* tab,

// An interstitial to be used when the user chooses to open a PDF using Adobe
// Reader, but it is out of date.
class PDFUnsupportedFeatureInterstitial : public InterstitialPage {
class PDFUnsupportedFeatureInterstitial : public ChromeInterstitialPage {
public:
PDFUnsupportedFeatureInterstitial(
TabContents* tab,
const WebPluginInfo& reader_webplugininfo)
: InterstitialPage(tab, false, tab->GetURL()),
: ChromeInterstitialPage(tab, false, tab->GetURL()),
reader_webplugininfo_(reader_webplugininfo) {
UserMetrics::RecordAction(UserMetricsAction("PDF_ReaderInterstitialShown"));
}

protected:
// InterstitialPage implementation.
// ChromeInterstitialPage implementation.
virtual std::string GetHTMLContents() {
DictionaryValue strings;
strings.SetString(
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
SafeBrowsingService* sb_service,
TabContents* tab_contents,
const UnsafeResourceList& unsafe_resources)
: InterstitialPage(tab_contents,
IsMainPage(unsafe_resources),
unsafe_resources[0].url),
: ChromeInterstitialPage(tab_contents,
IsMainPage(unsafe_resources),
unsafe_resources[0].url),
sb_service_(sb_service),
is_main_frame_(IsMainPage(unsafe_resources)),
unsafe_resources_(unsafe_resources) {
Expand Down
10 changes: 5 additions & 5 deletions chrome/browser/safe_browsing/safe_browsing_blocking_page.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Copyright (c) 2011 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.
//
Expand Down Expand Up @@ -33,7 +33,7 @@
#include <vector>

#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "content/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/tab_contents/chrome_interstitial_page.h"
#include "googleurl/src/gurl.h"

class DictionaryValue;
Expand All @@ -42,7 +42,7 @@ class SafeBrowsingBlockingPageFactory;
class MalwareDetails;
class TabContents;

class SafeBrowsingBlockingPage : public InterstitialPage {
class SafeBrowsingBlockingPage : public ChromeInterstitialPage {
public:
typedef std::vector<SafeBrowsingService::UnsafeResource> UnsafeResourceList;
typedef std::map<TabContents*, UnsafeResourceList> UnsafeResourceMap;
Expand All @@ -64,7 +64,7 @@ class SafeBrowsingBlockingPage : public InterstitialPage {
factory_ = factory;
}

// InterstitialPage method:
// ChromeInterstitialPage method:
virtual std::string GetHTMLContents();
virtual void SetReportingPreference(bool report);
virtual void Proceed();
Expand All @@ -73,7 +73,7 @@ class SafeBrowsingBlockingPage : public InterstitialPage {
protected:
friend class SafeBrowsingBlockingPageTest;

// InterstitialPage method:
// ChromeInterstitialPage method:
virtual void CommandReceived(const std::string& command);

// Don't instanciate this class directly, use ShowBlockingPage instead.
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/ssl/ssl_blocking_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ void RecordSSLBlockingPageStats(SSLBlockingPageEvent event) {
SSLBlockingPage::SSLBlockingPage(SSLCertErrorHandler* handler,
Delegate* delegate,
ErrorLevel error_level)
: InterstitialPage(handler->GetTabContents(), true, handler->request_url()),
: ChromeInterstitialPage(handler->GetTabContents(),
true,
handler->request_url()),
handler_(handler),
delegate_(delegate),
delegate_has_been_notified_(false),
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/ssl/ssl_blocking_page.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2011 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.

Expand All @@ -11,15 +11,15 @@

#include "base/string16.h"
#include "chrome/browser/ssl/ssl_error_info.h"
#include "content/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/tab_contents/chrome_interstitial_page.h"

class DictionaryValue;
class SSLCertErrorHandler;

// This class is responsible for showing/hiding the interstitial page that is
// shown when a certificate error happens.
// It deletes itself when the interstitial page is closed.
class SSLBlockingPage : public InterstitialPage {
class SSLBlockingPage : public ChromeInterstitialPage {
public:
// An interface that classes that want to interact with the SSLBlockingPage
// should implement.
Expand Down Expand Up @@ -58,7 +58,7 @@ class SSLBlockingPage : public InterstitialPage {
const std::vector<string16>& extra_info);

protected:
// InterstitialPage implementation.
// ChromeInterstitialPage implementation.
virtual std::string GetHTMLContents();
virtual void CommandReceived(const std::string& command);
virtual void UpdateEntry(NavigationEntry* entry);
Expand Down
38 changes: 38 additions & 0 deletions chrome/browser/tab_contents/chrome_interstitial_page.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2011 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.

#include "chrome/browser/tab_contents/chrome_interstitial_page.h"

#include "chrome/browser/dom_operation_notification_details.h"
#include "content/common/notification_service.h"
#include "content/common/notification_source.h"

ChromeInterstitialPage::ChromeInterstitialPage(TabContents* tab,
bool new_navigation,
const GURL& url)
: InterstitialPage(tab, new_navigation, url) {
}

ChromeInterstitialPage::~ChromeInterstitialPage() {
}

void ChromeInterstitialPage::Show() {
InterstitialPage::Show();

notification_registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE,
Source<RenderViewHost>(render_view_host()));
}

void ChromeInterstitialPage::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
if (NotificationType::DOM_OPERATION_RESPONSE == type.value) {
if (enabled()) {
Details<DomOperationNotificationDetails> dom_op_details(details);
CommandReceived(dom_op_details->json());
}
return;
}
InterstitialPage::Observe(type, source, details);
}
43 changes: 43 additions & 0 deletions chrome/browser/tab_contents/chrome_interstitial_page.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2011 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_TAB_CONTENTS_CHROME_INTERSTITIAL_PAGE_H_
#define CHROME_BROWSER_TAB_CONTENTS_CHROME_INTERSTITIAL_PAGE_H_
#pragma once

#include <map>
#include <string>

#include "content/browser/tab_contents/interstitial_page.h"
#include "content/common/notification_observer.h"
#include "googleurl/src/gurl.h"

class TabContents;

// This class adds the possibility to react to DOMResponse-messages sent by
// the RenderViewHost via ChromeRenderViewHostObserver to the InterstitialPage.
class ChromeInterstitialPage : public InterstitialPage {
public:
ChromeInterstitialPage(TabContents* tab,
bool new_navigation,
const GURL& url);
virtual ~ChromeInterstitialPage();

// Shows the interstitial page in the tab.
virtual void Show();

protected:
// NotificationObserver method:
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);

// Invoked when the page sent a command through DOMAutomation.
virtual void CommandReceived(const std::string& command) {}

private:
DISALLOW_COPY_AND_ASSIGN(ChromeInterstitialPage);
};

#endif // CHROME_BROWSER_TAB_CONTENTS_CHROME_INTERSTITIAL_PAGE_H_
14 changes: 10 additions & 4 deletions chrome/browser/tab_contents/web_contents_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/pref_value_store.h"
#include "chrome/browser/tab_contents/chrome_interstitial_page.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
Expand All @@ -20,11 +22,12 @@
#include "content/browser/renderer_host/test_render_view_host.h"
#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/constrained_window.h"
#include "content/browser/tab_contents/interstitial_page.h"
#include "content/browser/tab_contents/navigation_controller.h"
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "content/common/bindings_policy.h"
#include "content/common/notification_service.h"
#include "content/common/notification_source.h"
#include "content/common/view_messages.h"
#include "ipc/ipc_channel.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down Expand Up @@ -52,7 +55,7 @@ static void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params,
params->content_state = webkit_glue::CreateHistoryStateForURL(GURL(url));
}

class TestInterstitialPage : public InterstitialPage {
class TestInterstitialPage : public ChromeInterstitialPage {
public:
enum InterstitialState {
UNDECIDED = 0, // No decision taken yet.
Expand Down Expand Up @@ -83,7 +86,7 @@ class TestInterstitialPage : public InterstitialPage {
const GURL& url,
InterstitialState* state,
bool* deleted)
: InterstitialPage(tab, new_navigation, url),
: ChromeInterstitialPage(tab, new_navigation, url),
state_(state),
deleted_(deleted),
command_received_count_(0),
Expand Down Expand Up @@ -115,7 +118,10 @@ class TestInterstitialPage : public InterstitialPage {
}

void TestDomOperationResponse(const std::string& json_string) {
DomOperationResponse(json_string, 1);
DomOperationNotificationDetails details(json_string, 1);
Observe(NotificationType::DOM_OPERATION_RESPONSE,
Source<RenderViewHost>(render_view_host()),
Details<DomOperationNotificationDetails>(&details));
}

void TestDidNavigate(int page_id, const GURL& url) {
Expand Down
2 changes: 2 additions & 0 deletions chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,8 @@
'browser/tab_closeable_state_watcher.h',
'browser/tab_contents/background_contents.cc',
'browser/tab_contents/background_contents.h',
'browser/tab_contents/chrome_interstitial_page.cc',
'browser/tab_contents/chrome_interstitial_page.h',
'browser/tab_contents/confirm_infobar_delegate.cc',
'browser/tab_contents/confirm_infobar_delegate.h',
'browser/tab_contents/infobar_delegate.cc',
Expand Down
6 changes: 0 additions & 6 deletions content/browser/tab_contents/interstitial_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,6 @@ void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host,
tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE);
}

void InterstitialPage::DomOperationResponse(const std::string& json_string,
int automation_id) {
if (enabled_)
CommandReceived(json_string);
}

RendererPreferences InterstitialPage::GetRendererPrefs(Profile* profile) const {
return renderer_preferences_;
}
Expand Down
Loading

0 comments on commit ef1cef9

Please sign in to comment.