diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 20:53:19 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 20:53:19 +0000 |
commit | 10f27fb06b2d231f8ab3bb0177439760d9a3b654 (patch) | |
tree | 7cce1bb2c90dc61e2228ea2e25edd88ef346d986 /chrome/browser/views/html_dialog_view.cc | |
parent | 72dc92dc4f37783ba4aedae7d2d9c1750fac999e (diff) | |
download | chromium_src-10f27fb06b2d231f8ab3bb0177439760d9a3b654.zip chromium_src-10f27fb06b2d231f8ab3bb0177439760d9a3b654.tar.gz chromium_src-10f27fb06b2d231f8ab3bb0177439760d9a3b654.tar.bz2 |
Undo part of brettw's WebContents refactor that removed TabContentsDelegate
code from HtmlDialogView.
BUG=http://code.google.com/p/chromium/issues/detail?id=9884
Review URL: http://codereview.chromium.org/99305
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15238 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/html_dialog_view.cc')
-rw-r--r-- | chrome/browser/views/html_dialog_view.cc | 83 |
1 files changed, 80 insertions, 3 deletions
diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc index 28f7bb1..4a30c10 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -12,12 +12,13 @@ //////////////////////////////////////////////////////////////////////////////// // HtmlDialogView, public: -HtmlDialogView::HtmlDialogView(Profile* profile, +HtmlDialogView::HtmlDialogView(Browser* parent_browser, HtmlDialogUIDelegate* delegate) : DOMView(), - profile_(profile), + parent_browser_(parent_browser), + profile_(parent_browser->profile()), delegate_(delegate) { - DCHECK(profile); + DCHECK(profile_); } HtmlDialogView::~HtmlDialogView() { @@ -93,12 +94,88 @@ void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { } //////////////////////////////////////////////////////////////////////////////// +// TabContentsDelegate implementation: + +void HtmlDialogView::OpenURLFromTab(TabContents* source, + const GURL& url, + const GURL& referrer, + WindowOpenDisposition disposition, + PageTransition::Type transition) { + // Force all links to open in a new window, ignoring the incoming + // disposition. This is a tabless, modal dialog so we can't just + // open it in the current frame. + static_cast<TabContentsDelegate*>(parent_browser_)->OpenURLFromTab( + source, url, referrer, NEW_WINDOW, transition); +} + +void HtmlDialogView::NavigationStateChanged(const TabContents* source, + unsigned changed_flags) { + // We shouldn't receive any NavigationStateChanged except the first + // one, which we ignore because we're a dialog box. +} + +void HtmlDialogView::ReplaceContents(TabContents* source, + TabContents* new_contents) { +} + +void HtmlDialogView::AddNewContents(TabContents* source, + TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) { + static_cast<TabContentsDelegate*>(parent_browser_)->AddNewContents( + source, new_contents, NEW_WINDOW, initial_pos, user_gesture); +} + +void HtmlDialogView::ActivateContents(TabContents* contents) { + // We don't do anything here because there's only one TabContents in + // this frame and we don't have a TabStripModel. +} + +void HtmlDialogView::LoadingStateChanged(TabContents* source) { + // We don't care about this notification. +} + +void HtmlDialogView::CloseContents(TabContents* source) { + // We receive this message but don't handle it because we really do the + // cleanup in OnDialogClosed(). +} + +void HtmlDialogView::MoveContents(TabContents* source, const gfx::Rect& pos) { + // The contained web page wishes to resize itself. We let it do this because + // if it's a dialog we know about, we trust it not to be mean to the user. + window()->SetBounds(pos); +} + +bool HtmlDialogView::IsPopup(TabContents* source) { + // This needs to return true so that we are allowed to be resized by our + // contents. + return true; +} + +void HtmlDialogView::ToolbarSizeChanged(TabContents* source, + bool is_animating) { + Layout(); +} + +void HtmlDialogView::URLStarredChanged(TabContents* source, bool starred) { + // We don't have a visible star to click in the window. + NOTREACHED(); +} + +void HtmlDialogView::UpdateTargetURL(TabContents* source, const GURL& url) { + // Ignored. +} + +//////////////////////////////////////////////////////////////////////////////// // HtmlDialogView: void HtmlDialogView::InitDialog() { // Now Init the DOMView. This view runs in its own process to render the html. DOMView::Init(profile_, NULL); + tab_contents_->set_delegate(this); + // Set the delegate. This must be done before loading the page. See // the comment above HtmlDialogUI in its header file for why. HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(), |