summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-08 01:23:06 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-08 01:23:06 +0000
commitbbe7250added91877c9570465a407aab4a2a7e7e (patch)
treefca09e869668d43450caaa16797503425892b943
parentb5641a407904cae6aada72dbb9a4a458ca86d349 (diff)
downloadchromium_src-bbe7250added91877c9570465a407aab4a2a7e7e.zip
chromium_src-bbe7250added91877c9570465a407aab4a2a7e7e.tar.gz
chromium_src-bbe7250added91877c9570465a407aab4a2a7e7e.tar.bz2
Remove TabContents from constrained web dialogs.
BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11474011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171907 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/printing/print_preview_tab_controller.cc25
-rw-r--r--chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm27
-rw-r--r--chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc28
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents.h2
-rw-r--r--chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc39
-rw-r--r--chrome/browser/ui/webui/certificate_viewer_webui.cc7
-rw-r--r--chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc42
-rw-r--r--chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h19
-rw-r--r--chrome/browser/ui/webui/constrained_web_dialog_ui.h22
-rw-r--r--chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc26
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui.cc2
-rw-r--r--chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc2
12 files changed, 107 insertions, 134 deletions
diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc
index 00530111..89148e7 100644
--- a/chrome/browser/printing/print_preview_tab_controller.cc
+++ b/chrome/browser/printing/print_preview_tab_controller.cc
@@ -20,9 +20,6 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
@@ -163,9 +160,8 @@ bool PrintPreviewTabDelegate::ShouldShowDialogTitle() const {
}
// WebContentsDelegate that forwards shortcut keys in the print preview
-// renderer to the browser and makes sure users can't reload/save.
-class PrintPreviewWebContentDelegate : public WebDialogWebContentsDelegate,
- public CoreTabHelperDelegate {
+// renderer to the browser.
+class PrintPreviewWebContentDelegate : public WebDialogWebContentsDelegate {
public:
PrintPreviewWebContentDelegate(Profile* profile, WebContents* initiator_tab);
virtual ~PrintPreviewWebContentDelegate();
@@ -175,10 +171,6 @@ class PrintPreviewWebContentDelegate : public WebDialogWebContentsDelegate,
WebContents* source,
const NativeWebKeyboardEvent& event) OVERRIDE;
- // Overridden from CoreTabHelperDelegate:
- virtual bool CanReloadContents(WebContents* web_contents) const OVERRIDE;
- virtual bool CanSaveContents(WebContents* web_contents) const OVERRIDE;
-
private:
WebContents* tab_;
@@ -193,16 +185,6 @@ PrintPreviewWebContentDelegate::PrintPreviewWebContentDelegate(
PrintPreviewWebContentDelegate::~PrintPreviewWebContentDelegate() {}
-bool PrintPreviewWebContentDelegate::CanReloadContents(
- WebContents* web_contents) const {
- return false;
-}
-
-bool PrintPreviewWebContentDelegate::CanSaveContents(
- WebContents* web_contents) const {
- return false;
-}
-
void PrintPreviewWebContentDelegate::HandleKeyboardEvent(
WebContents* source,
const NativeWebKeyboardEvent& event) {
@@ -437,9 +419,8 @@ WebContents* PrintPreviewTabController::CreatePrintPreviewTab(
web_dialog_delegate,
pp_wcd,
initiator_tab);
- WebContents* preview_tab = constrained_delegate->tab()->web_contents();
+ WebContents* preview_tab = constrained_delegate->GetWebContents();
EnableInternalPDFPluginForTab(preview_tab);
- CoreTabHelper::FromWebContents(preview_tab)->set_delegate(pp_wcd);
// Add an entry to the map.
preview_tab_map_[preview_tab] = initiator_tab;
diff --git a/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm b/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm
index 7f17992..424359a 100644
--- a/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm
+++ b/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm
@@ -9,7 +9,6 @@
#include "base/memory/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac2.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "content/public/browser/web_contents.h"
#include "ui/gfx/size.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
@@ -26,7 +25,7 @@ class ConstrainedWebDialogDelegateMac :
public:
ConstrainedWebDialogDelegateMac(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate,
content::WebContents* web_contents);
@@ -43,14 +42,14 @@ class ConstrainedWebDialogDelegateMac :
virtual void OnDialogCloseFromWebUI() OVERRIDE {
return impl_->OnDialogCloseFromWebUI();
}
- virtual void ReleaseTabContentsOnDialogClose() OVERRIDE {
- return impl_->ReleaseTabContentsOnDialogClose();
+ virtual void ReleaseWebContentsOnDialogClose() OVERRIDE {
+ return impl_->ReleaseWebContentsOnDialogClose();
}
- virtual ConstrainedWindow* window() OVERRIDE {
- return impl_->window();
+ virtual ConstrainedWindow* GetWindow() OVERRIDE {
+ return impl_->GetWindow();
}
- virtual TabContents* tab() OVERRIDE {
- return impl_->tab();
+ virtual WebContents* GetWebContents() OVERRIDE {
+ return impl_->GetWebContents();
}
// ConstrainedWindowMacDelegate2 interface
@@ -70,11 +69,11 @@ class ConstrainedWebDialogDelegateMac :
};
ConstrainedWebDialogDelegateMac::ConstrainedWebDialogDelegateMac(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate,
content::WebContents* web_contents)
- : impl_(new ConstrainedWebDialogDelegateBase(profile,
+ : impl_(new ConstrainedWebDialogDelegateBase(browser_context,
delegate,
tab_delegate)) {
// Create a window to hold web_contents in the constrained sheet:
@@ -84,8 +83,8 @@ ConstrainedWebDialogDelegateMac::ConstrainedWebDialogDelegateMac(
window_.reset(
[[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]);
- [tab()->web_contents()->GetNativeView() setFrame:frame];
- [[window_ contentView] addSubview:tab()->web_contents()->GetNativeView()];
+ [GetWebContents()->GetNativeView() setFrame:frame];
+ [[window_ contentView] addSubview:GetWebContents()->GetNativeView()];
constrained_window_.reset(new ConstrainedWindowMac2(
this, web_contents, window_));
@@ -93,13 +92,13 @@ ConstrainedWebDialogDelegateMac::ConstrainedWebDialogDelegateMac(
}
ConstrainedWebDialogDelegate* CreateConstrainedWebDialog(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate,
content::WebContents* web_contents) {
// Deleted when the dialog closes.
ConstrainedWebDialogDelegateMac* constrained_delegate =
new ConstrainedWebDialogDelegateMac(
- profile, delegate, tab_delegate, web_contents);
+ browser_context, delegate, tab_delegate, web_contents);
return constrained_delegate;
}
diff --git a/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc b/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc
index 05dfb0f..e59def4 100644
--- a/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc
+++ b/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h"
#include "chrome/browser/ui/gtk/constrained_window_gtk.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
@@ -23,7 +22,7 @@ class ConstrainedWebDialogDelegateGtk : public ConstrainedWindowGtkDelegate,
public ConstrainedWebDialogDelegate {
public:
ConstrainedWebDialogDelegateGtk(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate);
@@ -44,22 +43,22 @@ class ConstrainedWebDialogDelegateGtk : public ConstrainedWindowGtkDelegate,
virtual void OnDialogCloseFromWebUI() OVERRIDE {
return impl_->OnDialogCloseFromWebUI();
}
- virtual void ReleaseTabContentsOnDialogClose() OVERRIDE {
- return impl_->ReleaseTabContentsOnDialogClose();
+ virtual void ReleaseWebContentsOnDialogClose() OVERRIDE {
+ return impl_->ReleaseWebContentsOnDialogClose();
}
- virtual ConstrainedWindow* window() OVERRIDE {
- return impl_->window();
+ virtual ConstrainedWindow* GetWindow() OVERRIDE {
+ return impl_->GetWindow();
}
- virtual TabContents* tab() OVERRIDE {
- return impl_->tab();
+ virtual WebContents* GetWebContents() OVERRIDE {
+ return impl_->GetWebContents();
}
// ConstrainedWindowGtkDelegate interface
virtual GtkWidget* GetWidgetRoot() OVERRIDE {
- return tab()->web_contents()->GetView()->GetNativeView();
+ return GetWebContents()->GetView()->GetNativeView();
}
virtual GtkWidget* GetFocusWidget() OVERRIDE {
- return tab()->web_contents()->GetContentNativeView();
+ return GetWebContents()->GetContentNativeView();
}
virtual void DeleteDelegate() OVERRIDE {
if (!impl_->closed_via_webui())
@@ -78,11 +77,11 @@ class ConstrainedWebDialogDelegateGtk : public ConstrainedWindowGtkDelegate,
};
ConstrainedWebDialogDelegateGtk::ConstrainedWebDialogDelegateGtk(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate)
: impl_(new ConstrainedWebDialogDelegateBase(
- profile, delegate, tab_delegate)) {
+ browser_context, delegate, tab_delegate)) {
gfx::Size dialog_size;
delegate->GetDialogSize(&dialog_size);
gtk_widget_set_size_request(GTK_WIDGET(GetWidgetRoot()),
@@ -93,12 +92,13 @@ ConstrainedWebDialogDelegateGtk::ConstrainedWebDialogDelegateGtk(
}
ConstrainedWebDialogDelegate* CreateConstrainedWebDialog(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate,
content::WebContents* web_contents) {
ConstrainedWebDialogDelegateGtk* constrained_delegate =
- new ConstrainedWebDialogDelegateGtk(profile, delegate, tab_delegate);
+ new ConstrainedWebDialogDelegateGtk(
+ browser_context, delegate, tab_delegate);
ConstrainedWindow* constrained_window =
new ConstrainedWindowGtk(web_contents, constrained_delegate);
constrained_delegate->set_window(constrained_window);
diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h
index 86960b9..d5135e4 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.h
+++ b/chrome/browser/ui/tab_contents/tab_contents.h
@@ -13,7 +13,6 @@
class Browser;
class BrowserTabstripTabContentsCreator;
-class ConstrainedWebDialogDelegateBase;
class InstantLoader;
class Profile;
class TabStripModel;
@@ -48,7 +47,6 @@ class TabContents : public content::WebContentsObserver {
friend class Browser;
friend class BrowserTabstripTabContentsCreator;
- friend class ConstrainedWebDialogDelegateBase;
friend class InstantLoader;
friend class prerender::PrerenderContents;
// See crbug.com/153587
diff --git a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc
index c499899..1419b04 100644
--- a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc
+++ b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc
@@ -5,8 +5,6 @@
#include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/views/constrained_window_views.h"
#include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h"
#include "content/public/browser/native_web_keyboard_event.h"
@@ -28,13 +26,14 @@ class ConstrainedWebDialogDelegateViews
: public ConstrainedWebDialogDelegateBase {
public:
ConstrainedWebDialogDelegateViews(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate,
views::WebView* view)
- : ConstrainedWebDialogDelegateBase(profile, delegate, tab_delegate),
+ : ConstrainedWebDialogDelegateBase(
+ browser_context, delegate, tab_delegate),
view_(view) {
- WebContents* web_contents = tab()->web_contents();
+ WebContents* web_contents = GetWebContents();
if (tab_delegate) {
set_override_tab_delegate(tab_delegate);
web_contents->SetDelegate(tab_delegate);
@@ -47,7 +46,7 @@ class ConstrainedWebDialogDelegateViews
// WebDialogWebContentsDelegate interface.
virtual void CloseContents(WebContents* source) OVERRIDE {
- window()->CloseConstrainedWindow();
+ GetWindow()->CloseConstrainedWindow();
}
// contents::WebContentsDelegate
@@ -75,7 +74,7 @@ class ConstrainedWebDialogDelegateViewViews
public views::WidgetDelegate {
public:
ConstrainedWebDialogDelegateViewViews(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate);
virtual ~ConstrainedWebDialogDelegateViewViews();
@@ -95,14 +94,14 @@ class ConstrainedWebDialogDelegateViewViews
virtual void OnDialogCloseFromWebUI() OVERRIDE {
return impl_->OnDialogCloseFromWebUI();
}
- virtual void ReleaseTabContentsOnDialogClose() OVERRIDE {
- return impl_->ReleaseTabContentsOnDialogClose();
+ virtual void ReleaseWebContentsOnDialogClose() OVERRIDE {
+ return impl_->ReleaseWebContentsOnDialogClose();
}
- virtual ConstrainedWindow* window() OVERRIDE {
- return impl_->window();
+ virtual ConstrainedWindow* GetWindow() OVERRIDE {
+ return impl_->GetWindow();
}
- virtual TabContents* tab() OVERRIDE {
- return impl_->tab();
+ virtual WebContents* GetWebContents() OVERRIDE {
+ return impl_->GetWebContents();
}
// views::WidgetDelegate interface.
@@ -152,7 +151,7 @@ class ConstrainedWebDialogDelegateViewViews
const ui::Accelerator& accelerator) OVERRIDE {
// Pressing ESC closes the dialog.
DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code());
- window()->CloseConstrainedWindow();
+ GetWindow()->CloseConstrainedWindow();
return true;
}
virtual gfx::Size GetPreferredSize() OVERRIDE {
@@ -173,15 +172,15 @@ class ConstrainedWebDialogDelegateViewViews
};
ConstrainedWebDialogDelegateViewViews::ConstrainedWebDialogDelegateViewViews(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate)
- : views::WebView(profile),
- impl_(new ConstrainedWebDialogDelegateViews(profile,
+ : views::WebView(browser_context),
+ impl_(new ConstrainedWebDialogDelegateViews(browser_context,
delegate,
tab_delegate,
this)) {
- SetWebContents(tab()->web_contents());
+ SetWebContents(GetWebContents());
// Pressing ESC closes the dialog.
set_allow_accelerators(true);
@@ -192,13 +191,13 @@ ConstrainedWebDialogDelegateViewViews::~ConstrainedWebDialogDelegateViewViews()
}
ConstrainedWebDialogDelegate* CreateConstrainedWebDialog(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate,
content::WebContents* web_contents) {
ConstrainedWebDialogDelegateViewViews* constrained_delegate =
new ConstrainedWebDialogDelegateViewViews(
- profile, delegate, tab_delegate);
+ browser_context, delegate, tab_delegate);
ConstrainedWindow* constrained_window =
new ConstrainedWindowViews(web_contents,
constrained_delegate,
diff --git a/chrome/browser/ui/webui/certificate_viewer_webui.cc b/chrome/browser/ui/webui/certificate_viewer_webui.cc
index 0cebba5..8571195 100644
--- a/chrome/browser/ui/webui/certificate_viewer_webui.cc
+++ b/chrome/browser/ui/webui/certificate_viewer_webui.cc
@@ -11,7 +11,6 @@
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/certificate_viewer.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/certificate_dialogs.h"
#include "chrome/browser/ui/constrained_window.h"
@@ -73,13 +72,11 @@ void CertificateViewerDialog::Show(WebContents* web_contents,
gfx::NativeWindow parent) {
// TODO(bshe): UI tweaks needed for Aura HTML Dialog, such as adding padding
// on the title for Aura ConstrainedWebDialogUI.
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
window_ = CreateConstrainedWebDialog(
- profile,
+ web_contents->GetBrowserContext(),
this,
NULL,
- web_contents)->window()->GetNativeWindow();
+ web_contents)->GetWindow()->GetNativeWindow();
}
ui::ModalType CertificateViewerDialog::GetDialogModalType() const {
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
index 310167b..ae5fd22 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
+++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
@@ -6,9 +6,7 @@
#include <string>
-#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/constrained_window.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
#include "content/public/browser/web_contents.h"
#include "ipc/ipc_message.h"
@@ -21,36 +19,36 @@ using ui::WebDialogDelegate;
using ui::WebDialogWebContentsDelegate;
ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase(
- Profile* profile,
+ content::BrowserContext* browser_context,
WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate)
- : WebDialogWebContentsDelegate(profile, new ChromeWebContentsHandler),
+ : WebDialogWebContentsDelegate(browser_context,
+ new ChromeWebContentsHandler),
web_dialog_delegate_(delegate),
window_(NULL),
closed_via_webui_(false),
- release_tab_on_close_(false) {
+ release_contents_on_close_(false) {
CHECK(delegate);
- WebContents* web_contents =
- WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL);
- tab_.reset(TabContents::Factory::CreateTabContents(web_contents));
+ web_contents_.reset(
+ WebContents::Create(browser_context, NULL, MSG_ROUTING_NONE, NULL));
if (tab_delegate) {
override_tab_delegate_.reset(tab_delegate);
- web_contents->SetDelegate(tab_delegate);
+ web_contents_->SetDelegate(tab_delegate);
} else {
- web_contents->SetDelegate(this);
+ web_contents_->SetDelegate(this);
}
// Set |this| as a delegate so the ConstrainedWebDialogUI can retrieve it.
- ConstrainedWebDialogUI::SetConstrainedDelegate(web_contents, this);
+ ConstrainedWebDialogUI::SetConstrainedDelegate(web_contents_.get(), this);
- web_contents->GetController().LoadURL(delegate->GetDialogContentURL(),
- content::Referrer(),
- content::PAGE_TRANSITION_AUTO_TOPLEVEL,
- std::string());
+ web_contents_->GetController().LoadURL(delegate->GetDialogContentURL(),
+ content::Referrer(),
+ content::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ std::string());
}
ConstrainedWebDialogDelegateBase::~ConstrainedWebDialogDelegateBase() {
- if (release_tab_on_close_)
- ignore_result(tab_.release());
+ if (release_contents_on_close_)
+ ignore_result(web_contents_.release());
}
const WebDialogDelegate*
@@ -81,16 +79,16 @@ bool ConstrainedWebDialogDelegateBase::closed_via_webui() const {
return closed_via_webui_;
}
-void ConstrainedWebDialogDelegateBase::ReleaseTabContentsOnDialogClose() {
- release_tab_on_close_ = true;
+void ConstrainedWebDialogDelegateBase::ReleaseWebContentsOnDialogClose() {
+ release_contents_on_close_ = true;
}
-ConstrainedWindow* ConstrainedWebDialogDelegateBase::window() {
+ConstrainedWindow* ConstrainedWebDialogDelegateBase::GetWindow() {
return window_;
}
-TabContents* ConstrainedWebDialogDelegateBase::tab() {
- return tab_.get();
+WebContents* ConstrainedWebDialogDelegateBase::GetWebContents() {
+ return web_contents_.get();
}
void ConstrainedWebDialogDelegateBase::HandleKeyboardEvent(
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
index 42826b5..c814c7d 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
+++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
@@ -6,11 +6,14 @@
#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_
#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "ui/web_dialogs/web_dialog_ui.h"
#include "ui/web_dialogs/web_dialog_web_contents_delegate.h"
+namespace content {
+class BrowserContext;
+}
+
namespace ui {
class WebDialogDelegate;
}
@@ -21,7 +24,7 @@ class ConstrainedWebDialogDelegateBase
public ui::WebDialogWebContentsDelegate {
public:
ConstrainedWebDialogDelegateBase(
- Profile* profile,
+ content::BrowserContext* browser_context,
ui::WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate);
virtual ~ConstrainedWebDialogDelegateBase();
@@ -34,9 +37,9 @@ class ConstrainedWebDialogDelegateBase
GetWebDialogDelegate() const OVERRIDE;
virtual ui::WebDialogDelegate* GetWebDialogDelegate() OVERRIDE;
virtual void OnDialogCloseFromWebUI() OVERRIDE;
- virtual void ReleaseTabContentsOnDialogClose() OVERRIDE;
- virtual ConstrainedWindow* window() OVERRIDE;
- virtual TabContents* tab() OVERRIDE;
+ virtual void ReleaseWebContentsOnDialogClose() OVERRIDE;
+ virtual ConstrainedWindow* GetWindow() OVERRIDE;
+ virtual content::WebContents* GetWebContents() OVERRIDE;
// WebDialogWebContentsDelegate interface.
virtual void HandleKeyboardEvent(
@@ -54,14 +57,14 @@ class ConstrainedWebDialogDelegateBase
ConstrainedWindow* window_;
// Holds the HTML to display in the constrained dialog.
- scoped_ptr<TabContents> tab_;
+ scoped_ptr<content::WebContents> web_contents_;
// Was the dialog closed from WebUI (in which case |web_dialog_delegate_|'s
// OnDialogClosed() method has already been called)?
bool closed_via_webui_;
- // If true, release |tab_| on close instead of destroying it.
- bool release_tab_on_close_;
+ // If true, release |web_contents_| on close instead of destroying it.
+ bool release_contents_on_close_;
scoped_ptr<WebDialogWebContentsDelegate> override_tab_delegate_;
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_ui.h b/chrome/browser/ui/webui/constrained_web_dialog_ui.h
index df21836..ea1e2ca 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_ui.h
+++ b/chrome/browser/ui/webui/constrained_web_dialog_ui.h
@@ -9,10 +9,9 @@
#include "content/public/browser/web_ui_controller.h"
class ConstrainedWindow;
-class Profile;
-class TabContents;
namespace content {
+class BrowserContext;
class RenderViewHost;
class WebContents;
}
@@ -31,18 +30,16 @@ class ConstrainedWebDialogDelegate {
// message from WebUI.
virtual void OnDialogCloseFromWebUI() = 0;
- // If called, on dialog closure, the dialog will release its TabContents
+ // If called, on dialog closure, the dialog will release its WebContents
// instead of destroying it. After which point, the caller will own the
- // released TabContents.
- virtual void ReleaseTabContentsOnDialogClose() = 0;
+ // released WebContents.
+ virtual void ReleaseWebContentsOnDialogClose() = 0;
// Returns the ConstrainedWindow.
- // TODO: fix this function name and the one below to conform to the style
- // guide (i.e. GetWindow, GetTab).
- virtual ConstrainedWindow* window() = 0;
+ virtual ConstrainedWindow* GetWindow() = 0;
- // Returns the TabContents owned by the constrained window.
- virtual TabContents* tab() = 0;
+ // Returns the WebContents owned by the constrained window.
+ virtual content::WebContents* GetWebContents() = 0;
protected:
virtual ~ConstrainedWebDialogDelegate() {}
@@ -85,7 +82,8 @@ class ConstrainedWebDialogUI
// Create a constrained HTML dialog. The actual object that gets created
// is a ConstrainedWebDialogDelegate, which later triggers construction of a
// ConstrainedWebDialogUI object.
-// |profile| is used to construct the constrained HTML dialog's WebContents.
+// |browser_context| is used to construct the constrained HTML dialog's
+// WebContents.
// |delegate| controls the behavior of the dialog.
// |tab_delegate| is optional, pass one in to use a custom
// WebDialogWebContentsDelegate with the dialog, or NULL to
@@ -93,7 +91,7 @@ class ConstrainedWebDialogUI
// |tab_delegate|.
// |overshadowed| is the tab being overshadowed by the dialog.
ConstrainedWebDialogDelegate* CreateConstrainedWebDialog(
- Profile* profile,
+ content::BrowserContext* browser_context,
ui::WebDialogDelegate* delegate,
ui::WebDialogWebContentsDelegate* tab_delegate,
content::WebContents* overshadowed);
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
index 27a0ea5..48cd411 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
@@ -5,10 +5,10 @@
#include "chrome/test/ui/ui_test.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/browser/ui/webui/test_web_dialog_delegate.h"
#include "chrome/common/url_constants.h"
@@ -27,18 +27,18 @@ class ConstrainedWebDialogBrowserTestObserver
public:
explicit ConstrainedWebDialogBrowserTestObserver(WebContents* contents)
: content::WebContentsObserver(contents),
- tab_destroyed_(false) {
+ contents_destroyed_(false) {
}
virtual ~ConstrainedWebDialogBrowserTestObserver() {}
- bool tab_destroyed() { return tab_destroyed_; }
+ bool contents_destroyed() { return contents_destroyed_; }
private:
virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE {
- tab_destroyed_ = true;
+ contents_destroyed_ = true;
}
- bool tab_destroyed_;
+ bool contents_destroyed_;
};
} // namespace
@@ -69,13 +69,13 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) {
NULL,
web_contents);
ASSERT_TRUE(dialog_delegate);
- EXPECT_TRUE(dialog_delegate->window());
+ EXPECT_TRUE(dialog_delegate->GetWindow());
EXPECT_EQ(1U, GetConstrainedWindowCount(web_contents));
}
-// Tests that ReleaseTabContentsOnDialogClose() works.
+// Tests that ReleaseWebContentsOnDialogClose() works.
IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
- ReleaseTabContentsOnDialogClose) {
+ ReleaseWebContentsOnDialogClose) {
// The delegate deletes itself.
WebDialogDelegate* delegate = new test::TestWebDialogDelegate(
GURL(chrome::kChromeUIConstrainedHTMLTestURL));
@@ -88,16 +88,16 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
NULL,
web_contents);
ASSERT_TRUE(dialog_delegate);
- scoped_ptr<TabContents> new_tab(dialog_delegate->tab());
+ scoped_ptr<WebContents> new_tab(dialog_delegate->GetWebContents());
ASSERT_TRUE(new_tab.get());
ASSERT_EQ(1U, GetConstrainedWindowCount(web_contents));
- ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents());
- dialog_delegate->ReleaseTabContentsOnDialogClose();
+ ConstrainedWebDialogBrowserTestObserver observer(new_tab.get());
+ dialog_delegate->ReleaseWebContentsOnDialogClose();
dialog_delegate->OnDialogCloseFromWebUI();
- ASSERT_FALSE(observer.tab_destroyed());
+ ASSERT_FALSE(observer.contents_destroyed());
EXPECT_EQ(0U, GetConstrainedWindowCount(web_contents));
new_tab.reset();
- EXPECT_TRUE(observer.tab_destroyed());
+ EXPECT_TRUE(observer.contents_destroyed());
}
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
index ee1a283..0631881 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
@@ -303,7 +303,7 @@ void PrintPreviewUI::OnHidePreviewTab() {
ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
if (!delegate)
return;
- delegate->ReleaseTabContentsOnDialogClose();
+ delegate->ReleaseWebContentsOnDialogClose();
background_printing_manager->OwnPrintPreviewTab(preview_tab);
OnClosePrintPreviewTab();
}
diff --git a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc
index 301c555..4ebf328 100644
--- a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc
+++ b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc
@@ -54,7 +54,7 @@ TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI(
constrained_web_dialog_delegate_ =
CreateConstrainedWebDialog(profile, this, NULL, web_contents);
- delegate_->set_window(constrained_web_dialog_delegate_->window());
+ delegate_->set_window(constrained_web_dialog_delegate_->GetWindow());
}
ui::ModalType TabModalConfirmDialogWebUI::GetDialogModalType() const {