diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 04:12:18 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 04:12:18 +0000 |
commit | 0f2f4b60511540e292e085ba5e1985be6bf93908 (patch) | |
tree | 6d6bb042fe78bb23c4eca3cf4a4222a3dab38e74 /chrome/browser/views | |
parent | aaeb9dc745d49afa66c1b613daa5a3123f309955 (diff) | |
download | chromium_src-0f2f4b60511540e292e085ba5e1985be6bf93908.zip chromium_src-0f2f4b60511540e292e085ba5e1985be6bf93908.tar.gz chromium_src-0f2f4b60511540e292e085ba5e1985be6bf93908.tar.bz2 |
Window Delegate Improvements:
- Windows now must have a Delegate. Just construct the default WindowDelegate
if
you don't want to have to write one in testing.
- Windows now obtain their contents view by asking the delegate via
WindowDelegate::GetContentsView.
- Contents views no longer need to manually store a pointer to the Window that
contains them, WindowDelegate does this automatically via its window()
accessor.
Reviewer notes:
- review window_delegate.h first, then
- window.h/cc
- custom frame window.h/cc
- constrained_window_impl.h/cc
- then everything else (just updating all call sites)
B=1280060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
44 files changed, 297 insertions, 279 deletions
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 157ccc6..4ad5908 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -54,8 +54,7 @@ // AboutChromeView, public: AboutChromeView::AboutChromeView(Profile* profile) - : dialog_(NULL), - profile_(profile), + : profile_(profile), about_dlg_background_(NULL), about_title_label_(NULL), version_label_(NULL), @@ -372,6 +371,10 @@ bool AboutChromeView::Accept() { return false; // We never allow this button to close the window. } +ChromeViews::View* AboutChromeView::GetContentsView() { + return this; +} + //////////////////////////////////////////////////////////////////////////////// // AboutChromeView, GoogleUpdateStatusListener implementation: @@ -456,7 +459,7 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, l10n_util::GetString(IDS_PRODUCT_NAME), new_version_available_)); show_success_indicator = true; - RestartMessageBox::ShowMessageBox(dialog_->GetHWND()); + RestartMessageBox::ShowMessageBox(window()->GetHWND()); break; case UPGRADE_ERROR: UserMetrics::RecordAction(L"UpgradeCheck_Error", profile_); @@ -484,7 +487,7 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, parent->Layout(); // Check button may have appeared/disappeared. We cannot call this during - // ViewHierarchyChanged because the |dialog_| pointer hasn't been set yet. - if (dialog_) - dialog_->UpdateDialogButtons(); + // ViewHierarchyChanged because the |window()| pointer hasn't been set yet. + if (window()) + window()->UpdateDialogButtons(); } diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h index b304218..a46a741 100644 --- a/chrome/browser/views/about_chrome_view.h +++ b/chrome/browser/views/about_chrome_view.h @@ -61,8 +61,6 @@ class AboutChromeView : public ChromeViews::View, // Initialize the controls on the dialog. void Init(); - void SetDialog(ChromeViews::Window* dialog) { dialog_ = dialog; } - // Overridden from ChromeViews::View: virtual void GetPreferredSize(CSize *out); virtual void Layout(); @@ -82,6 +80,7 @@ class AboutChromeView : public ChromeViews::View, virtual bool IsModal() const; virtual std::wstring GetWindowTitle() const; virtual bool Accept(); + virtual ChromeViews::View* GetContentsView(); // Overridden from GoogleUpdateStatusListener: virtual void OnReportResults(GoogleUpdateUpgradeResult result, @@ -100,8 +99,6 @@ class AboutChromeView : public ChromeViews::View, void UpdateStatus(GoogleUpdateUpgradeResult result, GoogleUpdateErrorCode error_code); - ChromeViews::Window* dialog_; - Profile* profile_; // UI elements on the dialog. diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc index e7a834a..da5a92d 100644 --- a/chrome/browser/views/bookmark_editor_view.cc +++ b/chrome/browser/views/bookmark_editor_view.cc @@ -79,7 +79,6 @@ BookmarkEditorView::BookmarkEditorView(Profile* profile, #pragma warning(suppress: 4355) // Okay to pass "this" here. new_group_button_( l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON)), - dialog_(NULL), url_(url), title_(title), running_menu_for_root_(false) { @@ -122,6 +121,10 @@ bool BookmarkEditorView::AreAcceleratorsEnabled(DialogButton button) { return !tree_view_.GetEditingNode(); } +ChromeViews::View* BookmarkEditorView::GetContentsView() { + return this; +} + void BookmarkEditorView::Layout() { // Let the grid layout manager lay out most of the dialog... GetLayoutManager()->Layout(this); @@ -205,12 +208,11 @@ bool BookmarkEditorView::IsCommandEnabled(int id) const { } void BookmarkEditorView::Show(HWND parent_hwnd) { - dialog_ = ChromeViews::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), - this, this); + ChromeViews::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), this); UserInputChanged(); if (bb_model_->IsLoaded()) ExpandAndSelect(); - dialog_->Show(); + window()->Show(); // Select all the text in the name textfield. title_tf_.SelectAll(); // Give focus to the name textfield. @@ -218,8 +220,8 @@ void BookmarkEditorView::Show(HWND parent_hwnd) { } void BookmarkEditorView::Close() { - DCHECK(dialog_); - dialog_->Close(); + DCHECK(window()); + window()->Close(); } void BookmarkEditorView::ShowContextMenu(View* source, @@ -389,7 +391,7 @@ void BookmarkEditorView::UserInputChanged() { url_tf_.SetBackgroundColor(kErrorColor); else url_tf_.SetDefaultBackgroundColor(); - dialog_->UpdateDialogButtons(); + window()->UpdateDialogButtons(); } void BookmarkEditorView::NewGroup() { diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h index c12abeb..5a2b9d6 100644 --- a/chrome/browser/views/bookmark_editor_view.h +++ b/chrome/browser/views/bookmark_editor_view.h @@ -83,6 +83,7 @@ class BookmarkEditorView : public ChromeViews::View, virtual std::wstring GetWindowTitle() const; virtual bool Accept(); virtual bool AreAcceleratorsEnabled(DialogButton button); + virtual ChromeViews::View* GetContentsView(); // View methods. virtual void Layout(); @@ -244,9 +245,6 @@ class BookmarkEditorView : public ChromeViews::View, // Used for editing the title. ChromeViews::TextField title_tf_; - // Dialog we're contained in. - ChromeViews::Window* dialog_; - // URL we were created with. const GURL url_; diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc index 2977409..45023e5 100644 --- a/chrome/browser/views/bug_report_view.cc +++ b/chrome/browser/views/bug_report_view.cc @@ -154,8 +154,7 @@ void BugReportView::PostCleanup::OnURLFetchComplete( // This is separate from crash reporting, which is handled by Breakpad. // BugReportView::BugReportView(Profile* profile, TabContents* tab) - : dialog_(NULL), - include_page_source_checkbox_(NULL), + : include_page_source_checkbox_(NULL), include_page_image_checkbox_(NULL), profile_(profile), post_url_(l10n_util::GetString(IDS_BUGREPORT_POST_URL)), @@ -279,7 +278,7 @@ void BugReportView::ItemChanged(ChromeViews::ComboBox* combo_box, include_page_image_checkbox_->SetEnabled(!is_phishing_report); include_page_image_checkbox_->SetIsSelected(!is_phishing_report); - dialog_->UpdateDialogButtons(); + window()->UpdateDialogButtons(); } void BugReportView::ContentsChanged(ChromeViews::TextField* sender, @@ -340,6 +339,10 @@ bool BugReportView::Accept() { return true; } +ChromeViews::View* BugReportView::GetContentsView() { + return this; +} + void BugReportView::SetUrl(const GURL& url) { page_url_text_->SetText(UTF8ToWide(url.spec())); } diff --git a/chrome/browser/views/bug_report_view.h b/chrome/browser/views/bug_report_view.h index f50e63c..07919d3 100644 --- a/chrome/browser/views/bug_report_view.h +++ b/chrome/browser/views/bug_report_view.h @@ -67,7 +67,6 @@ class BugReportView : public ChromeViews::View, explicit BugReportView(Profile* profile, TabContents* tab); virtual ~BugReportView(); - void set_dialog(ChromeViews::Window* dialog) { dialog_ = dialog; } void set_version(const std::wstring& version) { version_ = version; } // NOTE: set_png_data takes ownership of the vector void set_png_data(std::vector<unsigned char> *png_data) { @@ -98,6 +97,7 @@ class BugReportView : public ChromeViews::View, virtual bool IsModal() const; virtual std::wstring GetWindowTitle() const; virtual bool Accept(); + virtual ChromeViews::View* GetContentsView(); void SetUrl(const GURL& url); @@ -129,7 +129,6 @@ class BugReportView : public ChromeViews::View, ChromeViews::CheckBox* include_page_image_checkbox_; scoped_ptr<BugReportComboBoxModel> bug_type_model_; - ChromeViews::Window* dialog_; Profile* profile_; diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc index 17341cd..b3721ab 100644 --- a/chrome/browser/views/clear_browsing_data.cc +++ b/chrome/browser/views/clear_browsing_data.cc @@ -54,8 +54,7 @@ static const int kExtraMarginForTimePeriodLabel = 3; // ClearBrowsingDataView, public: ClearBrowsingDataView::ClearBrowsingDataView(Profile* profile) - : dialog_(NULL), - del_history_checkbox_(NULL), + : del_history_checkbox_(NULL), del_downloads_checkbox_(NULL), del_cache_checkbox_(NULL), del_cookies_checkbox_(NULL), @@ -292,6 +291,10 @@ bool ClearBrowsingDataView::Accept() { return false; // We close the dialog in OnDeletionDone(). } +ChromeViews::View* ClearBrowsingDataView::GetContentsView() { + return this; +} + //////////////////////////////////////////////////////////////////////////////// // ClearBrowsingDataView, ChromeViews::ComboBox::Model implementation: @@ -319,7 +322,7 @@ std::wstring ClearBrowsingDataView::GetItemAt(ChromeViews::ComboBox* source, void ClearBrowsingDataView::ButtonPressed(ChromeViews::NativeButton* sender) { // When no checkbox is checked we should not have the action button enabled. // This forces the button to evaluate what state they should be in. - dialog_->UpdateDialogButtons(); + window()->UpdateDialogButtons(); } //////////////////////////////////////////////////////////////////////////////// @@ -335,7 +338,7 @@ ChromeViews::CheckBox* ClearBrowsingDataView::AddCheckbox( } void ClearBrowsingDataView::UpdateControlEnabledState() { - dialog_->EnableClose(!delete_in_progress_); + window()->EnableClose(!delete_in_progress_); del_history_checkbox_->SetEnabled(!delete_in_progress_); del_downloads_checkbox_->SetEnabled(!delete_in_progress_); @@ -352,7 +355,7 @@ void ClearBrowsingDataView::UpdateControlEnabledState() { throbber_->Stop(); // Make sure to update the state for OK and Cancel buttons. - dialog_->UpdateDialogButtons(); + window()->UpdateDialogButtons(); } // Convenience method that returns true if the supplied checkbox is selected @@ -399,5 +402,5 @@ void ClearBrowsingDataView::OnDelete() { } void ClearBrowsingDataView::OnBrowsingDataRemoverDone() { - dialog_->Close(); + window()->Close(); } diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h index bb41ef5..87cbc91 100644 --- a/chrome/browser/views/clear_browsing_data.h +++ b/chrome/browser/views/clear_browsing_data.h @@ -67,8 +67,6 @@ class ClearBrowsingDataView : public ChromeViews::View, // Initialize the controls on the dialog. void Init(); - void SetDialog(ChromeViews::Window* dialog) { dialog_ = dialog; } - // Overridden from ChromeViews::View: virtual void GetPreferredSize(CSize *out); virtual void Layout(); @@ -86,6 +84,7 @@ class ClearBrowsingDataView : public ChromeViews::View, virtual bool IsModal() const; virtual std::wstring GetWindowTitle() const; virtual bool Accept(); + virtual ChromeViews::View* GetContentsView(); // Overridden from ChromeViews::ComboBox::Model: virtual int GetItemCount(ChromeViews::ComboBox* source); @@ -125,8 +124,6 @@ class ClearBrowsingDataView : public ChromeViews::View, // Used to signal enabled/disabled state for controls in the UI. bool delete_in_progress_; - ChromeViews::Window* dialog_; - Profile* profile_; DISALLOW_EVIL_CONSTRUCTORS(ClearBrowsingDataView); diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index 2e7f837..d61e1dc 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -449,8 +449,8 @@ void ConstrainedWindowNonClientView::UpdateLocationBar() { if (ShouldDisplayURLField()) { std::wstring url_spec; TabContents* tab = container_->constrained_contents(); - url_spec = gfx::ElideUrl(tab->GetURL(), - ChromeFont(), + url_spec = gfx::ElideUrl(tab->GetURL(), + ChromeFont(), 0, tab->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); std::wstring ev_text, ev_tooltip_text; @@ -727,7 +727,7 @@ void ConstrainedWindowNonClientView::Layout() { client_bounds_ = CalculateClientAreaBounds(GetWidth(), GetHeight()); if (should_display_url_field) { location_bar_->SetBounds(client_bounds_.x() - kLocationBarOffset, - client_bounds_.y() - location_bar_height - + client_bounds_.y() - location_bar_height - kLocationBarSpacing, client_bounds_.width() + kLocationBarOffset * 2, location_bar_height); @@ -914,9 +914,13 @@ void ConstrainedWindowNonClientView::InitClass() { class ConstrainedTabContentsWindowDelegate : public ChromeViews::WindowDelegate { public: - explicit ConstrainedTabContentsWindowDelegate( - ConstrainedWindowImpl* window) - : window_(window) { + explicit ConstrainedTabContentsWindowDelegate(TabContents* contents) + : contents_(contents), + contents_view_(NULL) { + } + + void set_contents_view(ChromeViews::View* contents_view) { + contents_view_ = contents_view; } // ChromeViews::WindowDelegate implementation: @@ -924,25 +928,21 @@ class ConstrainedTabContentsWindowDelegate return true; } virtual std::wstring GetWindowTitle() const { - TabContents* constrained_contents = window_->constrained_contents(); - if (constrained_contents) - return constrained_contents->GetTitle(); - - return std::wstring(); + return contents_->GetTitle(); } virtual bool ShouldShowWindowIcon() const { return true; } virtual SkBitmap GetWindowIcon() { - TabContents* constrained_contents = window_->constrained_contents(); - if (constrained_contents) - return constrained_contents->GetFavIcon(); - - return SkBitmap(); + return contents_->GetFavIcon(); + } + virtual ChromeViews::View* GetContentsView() { + return contents_view_; } private: - ConstrainedWindowImpl* window_; + TabContents* contents_; + ChromeViews::View* contents_view_; DISALLOW_EVIL_CONSTRUCTORS(ConstrainedTabContentsWindowDelegate); }; @@ -955,19 +955,6 @@ class ConstrainedTabContentsWindowDelegate static const int kPopupRepositionOffset = 5; static const int kConstrainedWindowEdgePadding = 10; -ConstrainedWindowImpl::ConstrainedWindowImpl(TabContents* owner) - : CustomFrameWindow(new ConstrainedWindowNonClientView(this, owner)), - owner_(owner), - constrained_contents_(NULL), - focus_restoration_disabled_(false), - is_dialog_(false), - titlebar_visibility_(0.0), - contents_container_(NULL) { - set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | - WS_THICKFRAME | WS_SYSMENU); - set_focus_on_creation(false); -} - ConstrainedWindowImpl::~ConstrainedWindowImpl() { } @@ -1120,6 +1107,7 @@ void ConstrainedWindowImpl::OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, PageTransition::Type transition) { + // We ignore source right now. owner_->OpenURL(this, url, disposition, transition); } @@ -1165,15 +1153,46 @@ TabContents* ConstrainedWindowImpl::GetConstrainingContents( return owner_; } -void ConstrainedWindowImpl::ToolbarSizeChanged(TabContents* source, +void ConstrainedWindowImpl::ToolbarSizeChanged(TabContents* source, bool finished) { - // We don't control the layout of anything that could be animating, + // We don't control the layout of anything that could be animating, // so do nothing. } //////////////////////////////////////////////////////////////////////////////// // ConstrainedWindowImpl, private: +ConstrainedWindowImpl::ConstrainedWindowImpl( + TabContents* owner, + ChromeViews::WindowDelegate* window_delegate, + TabContents* constrained_contents) + : CustomFrameWindow(window_delegate, + new ConstrainedWindowNonClientView(this, owner)), + contents_window_delegate_(window_delegate), + constrained_contents_(constrained_contents), + titlebar_visibility_(0.0) { + Init(owner); +} + +ConstrainedWindowImpl::ConstrainedWindowImpl( + TabContents* owner, + ChromeViews::WindowDelegate* window_delegate) + : CustomFrameWindow(window_delegate, + new ConstrainedWindowNonClientView(this, owner)), + constrained_contents_(NULL) { + Init(owner); +} + +void ConstrainedWindowImpl::Init(TabContents* owner) { + owner_ = owner; + focus_restoration_disabled_ = false; + is_dialog_ = false; + contents_container_ = NULL; + set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | + WS_THICKFRAME | WS_SYSMENU); + set_focus_on_creation(false); +} + void ConstrainedWindowImpl::ResizeConstrainedTitlebar() { DCHECK(constrained_contents_) << "ResizeConstrainedTitlebar() is only valid for web popups"; @@ -1196,32 +1215,26 @@ void ConstrainedWindowImpl::ResizeConstrainedTitlebar() { SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW); } -void ConstrainedWindowImpl::InitAsDialog( - const gfx::Rect& initial_bounds, - ChromeViews::View* contents_view, - ChromeViews::WindowDelegate* window_delegate) { +void ConstrainedWindowImpl::InitAsDialog(const gfx::Rect& initial_bounds) { is_dialog_ = true; - non_client_view()->set_window_delegate(window_delegate); - CustomFrameWindow::Init(owner_->GetContainerHWND(), initial_bounds, - contents_view, window_delegate); + non_client_view()->set_window_delegate(window_delegate()); + CustomFrameWindow::Init(owner_->GetContainerHWND(), initial_bounds); ActivateConstrainedWindow(); } void ConstrainedWindowImpl::InitWindowForContents( - TabContents* constrained_contents) { + TabContents* constrained_contents, + ConstrainedTabContentsWindowDelegate* delegate) { constrained_contents_ = constrained_contents; constrained_contents_->set_delegate(this); contents_container_ = new ChromeViews::HWNDView; - contents_window_delegate_.reset( - new ConstrainedTabContentsWindowDelegate(this)); - + delegate->set_contents_view(contents_container_); non_client_view()->set_window_delegate(contents_window_delegate_.get()); } void ConstrainedWindowImpl::InitSizeForContents( const gfx::Rect& initial_bounds) { - CustomFrameWindow::Init(owner_->GetContainerHWND(), initial_bounds, - contents_container_, contents_window_delegate_.get()); + CustomFrameWindow::Init(owner_->GetContainerHWND(), initial_bounds); contents_container_->Attach(constrained_contents_->GetContainerHWND()); constrained_contents_->SizeContents( @@ -1412,7 +1425,7 @@ void ConstrainedWindow::GenerateInitialBounds( // behvaiors below interact. std::wstring app_name; - if (parent->delegate() && parent->delegate()->IsApplication() && + if (parent->delegate() && parent->delegate()->IsApplication() && parent->AsWebContents() && parent->AsWebContents()->web_app()) { app_name = parent->AsWebContents()->web_app()->name(); } @@ -1460,8 +1473,9 @@ ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( const gfx::Rect& initial_bounds, ChromeViews::View* contents_view, ChromeViews::WindowDelegate* window_delegate) { - ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent); - window->InitAsDialog(initial_bounds, contents_view, window_delegate); + ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent, + window_delegate); + window->InitAsDialog(initial_bounds); return window; } @@ -1470,9 +1484,11 @@ ConstrainedWindow* ConstrainedWindow::CreateConstrainedPopup( TabContents* parent, const gfx::Rect& initial_bounds, TabContents* constrained_contents) { + ConstrainedTabContentsWindowDelegate* d = + new ConstrainedTabContentsWindowDelegate(constrained_contents); ConstrainedWindowImpl* window = - new ConstrainedWindowImpl(parent); - window->InitWindowForContents(constrained_contents); + new ConstrainedWindowImpl(parent, d, constrained_contents); + window->InitWindowForContents(constrained_contents, d); gfx::Rect window_bounds; if (initial_bounds.width() == 0 || initial_bounds.height() == 0) { diff --git a/chrome/browser/views/constrained_window_impl.h b/chrome/browser/views/constrained_window_impl.h index f3916ab..9e8c0b3 100644 --- a/chrome/browser/views/constrained_window_impl.h +++ b/chrome/browser/views/constrained_window_impl.h @@ -73,11 +73,13 @@ class ConstrainedWindowImpl : public ConstrainedWindow, virtual void UpdateWindowTitle(); virtual const gfx::Rect& GetCurrentBounds() const; - // Overridden from TabContentsDelegate: + // Overridden from PageNavigator (TabContentsDelegate's base interface): virtual void OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, PageTransition::Type transition); + + // Overridden from TabContentsDelegate: virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags); virtual void ReplaceContents(TabContents* source, @@ -123,7 +125,12 @@ class ConstrainedWindowImpl : public ConstrainedWindow, private: // Use the static factory methods on ConstrainedWindow to construct a // ConstrainedWindow. - ConstrainedWindowImpl(TabContents* owner); + ConstrainedWindowImpl(TabContents* owner, + ChromeViews::WindowDelegate* window_delegate, + TabContents* constrained_contents); + ConstrainedWindowImpl(TabContents* owner, + ChromeViews::WindowDelegate* window_delegate); + void Init(TabContents* owner); friend class ConstrainedWindow; @@ -136,9 +143,7 @@ class ConstrainedWindowImpl : public ConstrainedWindow, // Initialize the Constrained Window as a Constrained Dialog containing a // ChromeViews::View client area. - void InitAsDialog(const gfx::Rect& initial_bounds, - ChromeViews::View* contents_view, - ChromeViews::WindowDelegate* window_delegate); + void InitAsDialog(const gfx::Rect& initial_bounds); // Builds the underlying HWND and window delegates for a newly // created popup window. @@ -148,7 +153,8 @@ class ConstrainedWindowImpl : public ConstrainedWindow, // so that when we query for desired size, we get accurate data. If // we didn't do this, windows will initialize to being smaller then // the desired content size plus room for browser chrome. - void InitWindowForContents(TabContents* constrained_contents); + void InitWindowForContents(TabContents* constrained_contents, + ConstrainedTabContentsWindowDelegate* delegate); // Sets the initial bounds for a newly created popup window. // @@ -183,7 +189,7 @@ class ConstrainedWindowImpl : public ConstrainedWindow, // A default ChromeViews::WindowDelegate implementation for this window when // a TabContents is being constrained. (For the Constrained Dialog case, the // caller is required to provide the WindowDelegate). - scoped_ptr<ConstrainedTabContentsWindowDelegate> contents_window_delegate_; + scoped_ptr<ChromeViews::WindowDelegate> contents_window_delegate_; // We keep a reference on the HWNDView so we can properly detach the tab // contents when detaching. diff --git a/chrome/browser/views/edit_keyword_controller.cc b/chrome/browser/views/edit_keyword_controller.cc index 413f91c..8fe9b00 100644 --- a/chrome/browser/views/edit_keyword_controller.cc +++ b/chrome/browser/views/edit_keyword_controller.cc @@ -78,13 +78,10 @@ EditKeywordController::EditKeywordController( void EditKeywordController::Show() { // Window interprets an empty rectangle as needing to query the content for // the size as well as centering relative to the parent. - window_ = ChromeViews::Window::CreateChromeWindow( - ::IsWindow(parent_) ? parent_ : NULL, - gfx::Rect(), - view_, - this); - window_->Show(); - window_->UpdateDialogButtons(); + ChromeViews::Window::CreateChromeWindow(::IsWindow(parent_) ? parent_ : NULL, + gfx::Rect(), this); + window()->Show(); + window()->UpdateDialogButtons(); title_tf_->SelectAll(); title_tf_->RequestFocus(); } @@ -180,9 +177,13 @@ bool EditKeywordController::Accept() { return true; } +ChromeViews::View* EditKeywordController::GetContentsView() { + return view_; +} + void EditKeywordController::ContentsChanged(TextField* sender, const std::wstring& new_contents) { - window_->UpdateDialogButtons(); + window()->UpdateDialogButtons(); UpdateImageViews(); } diff --git a/chrome/browser/views/edit_keyword_controller.h b/chrome/browser/views/edit_keyword_controller.h index c7e362e..1050d99 100644 --- a/chrome/browser/views/edit_keyword_controller.h +++ b/chrome/browser/views/edit_keyword_controller.h @@ -74,6 +74,7 @@ class EditKeywordController : public ChromeViews::TextField::Controller, virtual void WindowClosing(); virtual bool Cancel(); virtual bool Accept(); + virtual ChromeViews::View* GetContentsView(); // ChromeViews::TextField::Controller overrides. Updates whether the user can // accept the dialog as well as updating image views showing whether value is @@ -142,9 +143,6 @@ class EditKeywordController : public ChromeViews::TextField::Controller, // Profile whose TemplateURLModel we're modifying. Profile* profile_; - // Container for displaying the contents. - ChromeViews::Window* window_; - // Text fields. ChromeViews::TextField* title_tf_; ChromeViews::TextField* keyword_tf_; diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc index 6b8263a..88c824c 100644 --- a/chrome/browser/views/first_run_customize_view.cc +++ b/chrome/browser/views/first_run_customize_view.cc @@ -48,7 +48,8 @@ #include "generated_resources.h" FirstRunCustomizeView::FirstRunCustomizeView(Profile* profile, - ImporterHost* importer_host) + ImporterHost* importer_host, + CustomizeViewObserver* observer) : FirstRunViewBase(profile), main_label_(NULL), import_cbox_(NULL), @@ -57,7 +58,7 @@ FirstRunCustomizeView::FirstRunCustomizeView(Profile* profile, shortcuts_label_(NULL), desktop_shortcut_cbox_(NULL), quick_shortcut_cbox_(NULL), - customize_observer_(NULL) { + customize_observer_(observer) { importer_host_ = importer_host; DCHECK(importer_host_); SetupControls(); @@ -202,6 +203,10 @@ std::wstring FirstRunCustomizeView::GetWindowTitle() const { return l10n_util::GetString(IDS_FR_CUSTOMIZE_DLG_TITLE); } +ChromeViews::View* FirstRunCustomizeView::GetContentsView() { + return this; +} + bool FirstRunCustomizeView::Accept() { if (!IsDialogButtonEnabled(DIALOGBUTTON_OK)) return false; @@ -226,7 +231,7 @@ bool FirstRunCustomizeView::Accept() { } else { int browser_selected = import_from_combo_->GetSelectedItem(); FirstRun::ImportSettings(profile_, browser_selected, - GetDefaultImportItems(), dialog_->GetHWND()); + GetDefaultImportItems(), window()->GetHWND()); } if (default_browser_cbox_->IsSelected()) { UserMetrics::RecordAction(L"FirstRunCustom_Do_DefBrowser", profile_); diff --git a/chrome/browser/views/first_run_customize_view.h b/chrome/browser/views/first_run_customize_view.h index 4a22cb6..69cf46e 100644 --- a/chrome/browser/views/first_run_customize_view.h +++ b/chrome/browser/views/first_run_customize_view.h @@ -63,16 +63,11 @@ class FirstRunCustomizeView : public FirstRunViewBase, virtual void CustomizeCanceled() = 0; }; - FirstRunCustomizeView(Profile* profile, ImporterHost* importer_host); + FirstRunCustomizeView(Profile* profile, + ImporterHost* importer_host, + CustomizeViewObserver* observer); virtual ~FirstRunCustomizeView(); - void set_dialog(ChromeViews::Window* dialog) { dialog_ = dialog; } - - // Sets the object that receives UserAccept and UserCancel notifications. - void set_observer(CustomizeViewObserver* observer) { - customize_observer_ = observer; - }; - // Overridden from ChromeViews::View. virtual void GetPreferredSize(CSize *out); virtual void Layout(); @@ -90,13 +85,11 @@ class FirstRunCustomizeView : public FirstRunViewBase, // Overridden from ChromeViews::WindowDelegate. virtual std::wstring GetWindowTitle() const; - + virtual ChromeViews::View* GetContentsView(); // Yes, we're modal. // NOTE: if you change this you'll need to make sure it isn't possible to // close the window while importing. - virtual bool IsModal() const { - return true; - } + virtual bool IsModal() const { return true; } private: // Initializes the controls on the dialog. diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc index 1beed44..d230efa 100644 --- a/chrome/browser/views/first_run_view.cc +++ b/chrome/browser/views/first_run_view.cc @@ -180,16 +180,10 @@ std::wstring FirstRunView::GetDialogButtonLabel(DialogButton button) const { void FirstRunView::OpenCustomizeDialog() { // The customize dialog now owns the importer host object. - FirstRunCustomizeView* customize_view = - new FirstRunCustomizeView(profile_, importer_host_); - - ChromeViews::Window* customize_dialog = - ChromeViews::Window::CreateChromeWindow(dialog_->GetHWND(), - gfx::Rect(), customize_view, - customize_view); - customize_dialog->Show(); - customize_view->set_dialog(customize_dialog); - customize_view->set_observer(this); + ChromeViews::Window::CreateChromeWindow( + window()->GetHWND(), + gfx::Rect(), + new FirstRunCustomizeView(profile_, importer_host_, this))->Show(); } void FirstRunView::LinkActivated(ChromeViews::Link* source, int event_flags) { @@ -200,6 +194,10 @@ std::wstring FirstRunView::GetWindowTitle() const { return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE); } +ChromeViews::View* FirstRunView::GetContentsView() { + return this; +} + bool FirstRunView::Accept() { if (!IsDialogButtonEnabled(DIALOGBUTTON_OK)) return false; @@ -210,7 +208,7 @@ bool FirstRunView::Accept() { CreateQuickLaunchShortcut(); // Index 0 is the default browser. FirstRun::ImportSettings(profile_, 0, GetDefaultImportItems(), - dialog_->GetHWND()); + window()->GetHWND()); UserMetrics::RecordAction(L"FirstRunDef_Accept", profile_); return true; @@ -224,7 +222,7 @@ bool FirstRunView::Cancel() { // Notification from the customize dialog that the user accepted. Since all // the work is done there we got nothing else to do. void FirstRunView::CustomizeAccepted() { - dialog_->Close(); + window()->Close(); } // Notification from the customize dialog that the user cancelled. diff --git a/chrome/browser/views/first_run_view.h b/chrome/browser/views/first_run_view.h index 47e3645..728ac96 100644 --- a/chrome/browser/views/first_run_view.h +++ b/chrome/browser/views/first_run_view.h @@ -66,6 +66,7 @@ class FirstRunView : public FirstRunViewBase, // Overridden from ChromeViews::WindowDelegate: virtual std::wstring GetWindowTitle() const; + virtual ChromeViews::View* GetContentsView(); // Overridden from ChromeViews::LinkActivated: virtual void LinkActivated(ChromeViews::Link* source, int event_flags); diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc index b9c04fe..4ee8aceb 100644 --- a/chrome/browser/views/first_run_view_base.cc +++ b/chrome/browser/views/first_run_view_base.cc @@ -54,8 +54,7 @@ #include "generated_resources.h" FirstRunViewBase::FirstRunViewBase(Profile* profile) - : dialog_(NULL), - preferred_width_(0), + : preferred_width_(0), background_image_(NULL), separator_1_(NULL), separator_2_(NULL), @@ -148,9 +147,7 @@ void FirstRunViewBase::Layout() { background_image_->GetHeight() - 2; separator_1_->GetPreferredSize(&pref_size); - separator_1_->SetBounds(0, next_v_space, - canvas.cx + 1, - pref_size.cy); + separator_1_->SetBounds(0 , next_v_space, canvas.cx + 1, pref_size.cy); next_v_space = canvas.cy - kPanelSubVerticalSpacing; separator_2_->GetPreferredSize(&pref_size); @@ -182,7 +179,7 @@ int FirstRunViewBase::GetDefaultImportItems() const { }; void FirstRunViewBase::DisableButtons() { - dialog_->EnableClose(false); + window()->EnableClose(false); ChromeViews::ClientView* cv = reinterpret_cast<ChromeViews::ClientView*>(GetParent()); if (cv) { diff --git a/chrome/browser/views/first_run_view_base.h b/chrome/browser/views/first_run_view_base.h index 9266ce8..e18fd7b 100644 --- a/chrome/browser/views/first_run_view_base.h +++ b/chrome/browser/views/first_run_view_base.h @@ -54,9 +54,6 @@ class FirstRunViewBase : public ChromeViews::View, explicit FirstRunViewBase(Profile* profile); virtual ~FirstRunViewBase(); - // Sets the dialog window that host the view. - void set_dialog(ChromeViews::Window* dialog) { dialog_ = dialog; } - // Overridden from ChromeViews::View. virtual void Layout(); @@ -78,7 +75,7 @@ class FirstRunViewBase : public ChromeViews::View, // Modifies the chrome configuration so that the first-run dialogs are not // shown again. bool FirstRunComplete(); - + // Disables the standard buttons of the dialog. Useful when importing. void DisableButtons(); // Computes a tight dialog width given a contained UI element. @@ -99,7 +96,6 @@ class FirstRunViewBase : public ChromeViews::View, scoped_refptr<ImporterHost> importer_host_; Profile* profile_; - ChromeViews::Window* dialog_; private: // Initializes the controls on the dialog. diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc index 1be835f..cdf48e8 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -39,7 +39,6 @@ HtmlDialogView::HtmlDialogView(Browser* parent_browser, Profile* profile, HtmlDialogContentsDelegate* delegate) : DOMView(delegate->GetDialogContentURL()), - dialog_(NULL), parent_browser_(parent_browser), profile_(profile), delegate_(delegate) { @@ -80,6 +79,10 @@ void HtmlDialogView::WindowClosing() { OnDialogClosed(""); } +ChromeViews::View* HtmlDialogView::GetContentsView() { + return this; +} + //////////////////////////////////////////////////////////////////////////////// // HtmlDialogContentsDelegate implementation: @@ -98,7 +101,7 @@ std::string HtmlDialogView::GetDialogArgs() const { void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { delegate_->OnDialogClosed(json_retval); delegate_ = NULL; // We will not communicate further with the delegate. - dialog_->Close(); + window()->Close(); } //////////////////////////////////////////////////////////////////////////////// @@ -155,14 +158,14 @@ void HtmlDialogView::MoveContents(TabContents* source, const gfx::Rect& pos) { // Determine the size the window containing the dialog at its requested size. gfx::Size window_size = - dialog_->CalculateWindowSizeForClientSize(pos.size()); + window()->CalculateWindowSizeForClientSize(pos.size()); // Actually size the window. CRect vc_bounds; GetViewContainer()->GetBounds(&vc_bounds, true); gfx::Rect bounds(vc_bounds.left, vc_bounds.top, window_size.width(), window_size.height()); - dialog_->SetBounds(bounds); + window()->SetBounds(bounds); } bool HtmlDialogView::IsPopup(TabContents* source) { @@ -187,9 +190,7 @@ void HtmlDialogView::UpdateTargetURL(TabContents* source, const GURL& url) { //////////////////////////////////////////////////////////////////////////////// // HtmlDialogView: -void HtmlDialogView::InitDialog(ChromeViews::Window* dialog) { - dialog_ = dialog; - +void HtmlDialogView::InitDialog() { // Now Init the DOMView. This view runs in its own process to render the html. DOMView::Init(profile_, NULL); diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h index 54f8f15..a07e5e3 100644 --- a/chrome/browser/views/html_dialog_view.h +++ b/chrome/browser/views/html_dialog_view.h @@ -60,7 +60,7 @@ class HtmlDialogView virtual ~HtmlDialogView(); // Initializes the contents of the dialog (the DOMView and the callbacks). - void InitDialog(ChromeViews::Window* dialog); + void InitDialog(); // Overridden from ChromeViews::View: virtual void GetPreferredSize(CSize *out); @@ -70,6 +70,7 @@ class HtmlDialogView virtual bool IsModal() const; virtual std::wstring GetWindowTitle() const; virtual void WindowClosing(); + virtual ChromeViews::View* GetContentsView(); // Overridden from HtmlDialogContentsDelegate: virtual GURL GetDialogContentURL() const; @@ -101,9 +102,6 @@ class HtmlDialogView virtual void UpdateTargetURL(TabContents* source, const GURL& url); private: - // The dialog this view is displayed in. - ChromeViews::Window* dialog_; - // The Browser object which created this html dialog; we send all // window opening/navigations to this object. Browser* parent_browser_; diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc index 645c6df..2434118 100644 --- a/chrome/browser/views/hung_renderer_view.cc +++ b/chrome/browser/views/hung_renderer_view.cc @@ -140,8 +140,6 @@ class HungRendererWarningView : public ChromeViews::View, void ShowForWebContents(WebContents* contents); void EndForWebContents(WebContents* contents); - void set_window(ChromeViews::Window* window) { window_ = window; } - // ChromeViews::WindowDelegate overrides: virtual std::wstring GetWindowTitle() const; virtual void WindowClosing(); @@ -150,7 +148,8 @@ class HungRendererWarningView : public ChromeViews::View, ChromeViews::DialogDelegate::DialogButton button) const; virtual ChromeViews::View* GetExtraView(); virtual bool Accept(bool window_closing); - + virtual ChromeViews::View* GetContentsView(); + // ChromeViews::NativeButton::Listener overrides: virtual void ButtonPressed(ChromeViews::NativeButton* sender); @@ -193,9 +192,6 @@ class HungRendererWarningView : public ChromeViews::View, }; ButtonContainer* kill_button_container_; - // The Window that contains this view. - ChromeViews::Window* window_; - // The model that provides the contents of the table that shows a list of // pages affected by the hang. scoped_ptr<HungPagesTableModel> hung_pages_table_model_; @@ -233,7 +229,6 @@ HungRendererWarningView::HungRendererWarningView() hung_pages_table_(NULL), kill_button_(NULL), kill_button_container_(NULL), - window_(NULL), contents_(NULL), initialized_(false) { InitClass(); @@ -244,7 +239,7 @@ HungRendererWarningView::~HungRendererWarningView() { } void HungRendererWarningView::ShowForWebContents(WebContents* contents) { - DCHECK(contents && window_); + DCHECK(contents && window()); contents_ = contents; // Don't show the warning unless the foreground window is the frame, or this @@ -253,13 +248,13 @@ void HungRendererWarningView::ShowForWebContents(WebContents* contents) { HWND frame_hwnd = GetAncestor(contents->GetContainerHWND(), GA_ROOT); HWND foreground_window = GetForegroundWindow(); if (foreground_window != frame_hwnd && - foreground_window != window_->GetHWND()) { + foreground_window != window()->GetHWND()) { return; } - if (!window_->IsActive()) { + if (!window()->IsActive()) { gfx::Rect bounds = GetDisplayBounds(contents); - window_->SetBounds(bounds, frame_hwnd); + window()->SetBounds(bounds, frame_hwnd); // We only do this if the window isn't active (i.e. hasn't been shown yet, // or is currently shown but deactivated for another WebContents). This is @@ -268,14 +263,14 @@ void HungRendererWarningView::ShowForWebContents(WebContents* contents) { // the list of hung pages for a potentially unrelated renderer while this // one is showing. hung_pages_table_model_->InitForWebContents(contents); - window_->Show(); + window()->Show(); } } void HungRendererWarningView::EndForWebContents(WebContents* contents) { DCHECK(contents); if (contents_ && contents_->process() == contents->process()) { - window_->Close(); + window()->Close(); // Since we're closing, we no longer need this WebContents. contents_ = NULL; } @@ -326,6 +321,13 @@ bool HungRendererWarningView::Accept(bool window_closing) { return true; } +ChromeViews::View* HungRendererWarningView::GetContentsView() { + return this; +} + +/////////////////////////////////////////////////////////////////////////////// +// HungRendererWarningView, ChromeViews::NativeButton::Listener implementation: + void HungRendererWarningView::ButtonPressed( ChromeViews::NativeButton* sender) { if (sender == kill_button_) { @@ -401,7 +403,7 @@ void HungRendererWarningView::CreateKillButtonView() { kill_button_->SetListener(this); kill_button_container_ = new ButtonContainer; - + using ChromeViews::GridLayout; using ChromeViews::ColumnSet; @@ -426,7 +428,7 @@ gfx::Rect HungRendererWarningView::GetDisplayBounds( GetWindowRect(contents_hwnd, &contents_bounds); CRect window_bounds; - window_->GetBounds(&window_bounds, true); + window()->GetBounds(&window_bounds, true); int window_x = contents_bounds.left + (contents_bounds.Width() - window_bounds.Width()) / 2; @@ -453,9 +455,7 @@ HungRendererWarningView* HungRendererWarning::instance_ = NULL; static HungRendererWarningView* CreateHungRendererWarningView() { HungRendererWarningView* cv = new HungRendererWarningView; - ChromeViews::Window* window = - ChromeViews::Window::CreateChromeWindow(NULL, gfx::Rect(), cv, cv); - cv->set_window(window); + ChromeViews::Window::CreateChromeWindow(NULL, gfx::Rect(), cv); return cv; } diff --git a/chrome/browser/views/importer_lock_view.cc b/chrome/browser/views/importer_lock_view.cc index 9e4b00e..c48df4c 100644 --- a/chrome/browser/views/importer_lock_view.cc +++ b/chrome/browser/views/importer_lock_view.cc @@ -44,8 +44,7 @@ static const int kDefaultWindowWidth = 320; static const int kDefaultWindowHeight = 100; ImporterLockView::ImporterLockView(ImporterHost* host) - : dialog_(NULL), - description_label_(NULL), + : description_label_(NULL), importer_host_(host) { description_label_ = new ChromeViews::Label( l10n_util::GetString(IDS_IMPORTER_LOCK_TEXT)); @@ -97,3 +96,7 @@ bool ImporterLockView::Cancel() { importer_host_, &ImporterHost::OnLockViewEnd, false)); return true; } + +ChromeViews::View* ImporterLockView::GetContentsView() { + return this; +} diff --git a/chrome/browser/views/importer_lock_view.h b/chrome/browser/views/importer_lock_view.h index 876560a..4714656 100644 --- a/chrome/browser/views/importer_lock_view.h +++ b/chrome/browser/views/importer_lock_view.h @@ -50,10 +50,6 @@ class ImporterLockView : public ChromeViews::View, explicit ImporterLockView(ImporterHost* host); virtual ~ImporterLockView(); - void set_dialog(ChromeViews::Window* dialog) { - dialog_ = dialog; - } - // Overridden from ChromeViews::View. virtual void GetPreferredSize(CSize *out); virtual void Layout(); @@ -64,12 +60,11 @@ class ImporterLockView : public ChromeViews::View, virtual std::wstring GetWindowTitle() const; virtual bool Accept(); virtual bool Cancel(); + virtual ChromeViews::View* GetContentsView(); private: ChromeViews::Label* description_label_; - ChromeViews::Window* dialog_; - ImporterHost* importer_host_; DISALLOW_EVIL_CONSTRUCTORS(ImporterLockView); diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc index bd71637..cd875ea 100644 --- a/chrome/browser/views/importer_view.cc +++ b/chrome/browser/views/importer_view.cc @@ -44,8 +44,7 @@ using ChromeViews::ColumnSet; using ChromeViews::GridLayout; ImporterView::ImporterView(Profile* profile) - : dialog_(NULL), - import_from_label_(NULL), + : import_from_label_(NULL), profile_combobox_(NULL), import_items_label_(NULL), history_checkbox_(NULL), @@ -169,6 +168,10 @@ bool ImporterView::Accept() { return false; } +ChromeViews::View* ImporterView::GetContentsView() { + return this; +} + int ImporterView::GetItemCount(ChromeViews::ComboBox* source) { DCHECK(source == profile_combobox_); DCHECK(importer_host_.get()); @@ -188,7 +191,7 @@ void ImporterView::ImportCanceled() { void ImporterView::ImportComplete() { // Now close this window since the import completed or was canceled. - dialog_->Close(); + window()->Close(); } ChromeViews::CheckBox* ImporterView::InitCheckbox( diff --git a/chrome/browser/views/importer_view.h b/chrome/browser/views/importer_view.h index fe9ab11..cbfd2df 100644 --- a/chrome/browser/views/importer_view.h +++ b/chrome/browser/views/importer_view.h @@ -58,8 +58,6 @@ class ImporterView : public ChromeViews::View, explicit ImporterView(Profile* profile); virtual ~ImporterView(); - void set_dialog(ChromeViews::Window* dialog) { dialog_ = dialog; } - // Overridden from ChromeViews::View. virtual void GetPreferredSize(CSize *out); virtual void Layout(); @@ -69,6 +67,7 @@ class ImporterView : public ChromeViews::View, virtual bool IsModal() const; virtual std::wstring GetWindowTitle() const; virtual bool Accept(); + virtual ChromeViews::View* GetContentsView(); // Overridden from ChromeViews::ComboBox::Model. virtual int GetItemCount(ChromeViews::ComboBox* source); @@ -93,8 +92,6 @@ class ImporterView : public ChromeViews::View, ChromeViews::CheckBox* passwords_checkbox_; ChromeViews::CheckBox* search_engines_checkbox_; - ChromeViews::Window* dialog_; - scoped_refptr<ImporterHost> importer_host_; Profile* profile_; diff --git a/chrome/browser/views/importing_progress_view.cc b/chrome/browser/views/importing_progress_view.cc index aa99455..60953b3 100644 --- a/chrome/browser/views/importing_progress_view.cc +++ b/chrome/browser/views/importing_progress_view.cc @@ -63,7 +63,6 @@ ImportingProgressView::ImportingProgressView(const std::wstring& source_name, l10n_util::GetString(IDS_IMPORT_PROGRESS_STATUS_HISTORY))), label_cookies_(new ChromeViews::Label( l10n_util::GetString(IDS_IMPORT_PROGRESS_STATUS_COOKIES))), - window_(NULL), parent_window_(parent_window), coordinator_(coordinator), import_observer_(observer), @@ -167,7 +166,7 @@ void ImportingProgressView::ImportEnded() { // In every case, we need to close the UI now. importing_ = false; coordinator_->SetObserver(NULL); - window_->Close(); + window()->Close(); if (import_observer_) import_observer_->ImportComplete(); } @@ -220,6 +219,10 @@ bool ImportingProgressView::Cancel() { return false; } +ChromeViews::View* ImportingProgressView::GetContentsView() { + return this; +} + //////////////////////////////////////////////////////////////////////////////// // ImportingProgressView, private: @@ -296,10 +299,8 @@ void StartImportingWithUI(HWND parent_window, DCHECK(items != 0); ImportingProgressView* v = new ImportingProgressView( source_profile.description, items, coordinator, observer, parent_window); - ChromeViews::Window* window = ChromeViews::Window::CreateChromeWindow( - parent_window, gfx::Rect(), v, v); - v->set_window(window); - window->Show(); + ChromeViews::Window::CreateChromeWindow(parent_window, gfx::Rect(), + v)->Show(); coordinator->StartImportSettings(source_profile, items, new ProfileWriter(target_profile), first_run); diff --git a/chrome/browser/views/importing_progress_view.h b/chrome/browser/views/importing_progress_view.h index c3a560d..643868f 100644 --- a/chrome/browser/views/importing_progress_view.h +++ b/chrome/browser/views/importing_progress_view.h @@ -51,8 +51,6 @@ class ImportingProgressView : public ChromeViews::View, HWND parent_window); virtual ~ImportingProgressView(); - void set_window(ChromeViews::Window* window) { window_ = window; } - protected: // Overridden from ImporterHost::Observer: virtual void ImportItemStarted(ImportItem item); @@ -66,6 +64,7 @@ class ImportingProgressView : public ChromeViews::View, virtual bool IsModal() const; virtual std::wstring GetWindowTitle() const; virtual bool Cancel(); + virtual ChromeViews::View* GetContentsView(); // Overridden from ChromeViews::View: virtual void GetPreferredSize(CSize *out); @@ -90,9 +89,6 @@ class ImportingProgressView : public ChromeViews::View, scoped_ptr<ChromeViews::Label> label_history_; scoped_ptr<ChromeViews::Label> label_cookies_; - // The window that contains us. - ChromeViews::Window* window_; - // The native window that we are parented to. Can be NULL. HWND parent_window_; diff --git a/chrome/browser/views/input_window.cc b/chrome/browser/views/input_window.cc index 058e29d..f4c560e 100644 --- a/chrome/browser/views/input_window.cc +++ b/chrome/browser/views/input_window.cc @@ -51,13 +51,10 @@ class ContentView : public ChromeViews::View, public: explicit ContentView(InputWindowDelegate* delegate) : delegate_(delegate), - window_(NULL), focus_grabber_factory_(this) { DCHECK(delegate_); } - void set_window(ChromeViews::Window* window) { window_ = window; } - // ChromeViews::DialogDelegate overrides: virtual bool IsDialogButtonEnabled(DialogButton button) const; virtual bool Accept(); @@ -65,6 +62,7 @@ class ContentView : public ChromeViews::View, virtual void WindowClosing(); virtual std::wstring GetWindowTitle() const; virtual bool IsModal() const { return true; } + virtual ChromeViews::View* GetContentsView(); // ChromeViews::TextField::Controller overrides: virtual void ContentsChanged(ChromeViews::TextField* sender, @@ -91,9 +89,6 @@ class ContentView : public ChromeViews::View, // caller. InputWindowDelegate* delegate_; - // The Window that owns this view. - ChromeViews::Window* window_; - // Helps us set focus to the first TextField in the window. ScopedRunnableMethodFactory<ContentView> focus_grabber_factory_; @@ -127,12 +122,16 @@ std::wstring ContentView::GetWindowTitle() const { return delegate_->GetWindowTitle(); } +ChromeViews::View* ContentView::GetContentsView() { + return this; +} + /////////////////////////////////////////////////////////////////////////////// // ContentView, ChromeViews::TextField::Controller implementation: void ContentView::ContentsChanged(ChromeViews::TextField* sender, const std::wstring& new_contents) { - window_->UpdateDialogButtons(); + window()->UpdateDialogButtons(); } /////////////////////////////////////////////////////////////////////////////// @@ -185,10 +184,9 @@ void ContentView::FocusFirstFocusableControl() { ChromeViews::Window* CreateInputWindow(HWND parent_hwnd, InputWindowDelegate* delegate) { - ContentView* cv = new ContentView(delegate); - ChromeViews::Window* window = ChromeViews::Window::CreateChromeWindow( - parent_hwnd, gfx::Rect(), cv, cv); - cv->set_window(window); + ChromeViews::Window* window = + ChromeViews::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), + new ContentView(delegate)); window->UpdateDialogButtons(); return window; } diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc index 04acd38..799d2e2 100644 --- a/chrome/browser/views/keyword_editor_view.cc +++ b/chrome/browser/views/keyword_editor_view.cc @@ -362,7 +362,7 @@ void KeywordEditorView::Show(Profile* profile) { // Initialize the UI. By passing in an empty rect KeywordEditorView is // queried for its preferred size. open_window = ChromeViews::Window::CreateChromeWindow( - NULL, gfx::Rect(), keyword_editor, keyword_editor); + NULL, gfx::Rect(), keyword_editor); open_window->Show(); } @@ -480,6 +480,10 @@ bool KeywordEditorView::Cancel() { return true; } +ChromeViews::View* KeywordEditorView::GetContentsView() { + return this; +} + void KeywordEditorView::Init() { DCHECK(!table_model_.get()); diff --git a/chrome/browser/views/keyword_editor_view.h b/chrome/browser/views/keyword_editor_view.h index 3512648..4d9fa3e 100644 --- a/chrome/browser/views/keyword_editor_view.h +++ b/chrome/browser/views/keyword_editor_view.h @@ -178,6 +178,7 @@ class KeywordEditorView : public ChromeViews::View, virtual int GetDialogButtons() const; virtual bool Accept(); virtual bool Cancel(); + virtual ChromeViews::View* GetContentsView(); // Returns the TemplateURLModel we're using. TemplateURLModel* template_url_model() const { return url_model_; } diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc index f47e5a6..37c6936 100644 --- a/chrome/browser/views/options/advanced_page_view.cc +++ b/chrome/browser/views/options/advanced_page_view.cc @@ -84,22 +84,24 @@ class ResetDefaultsConfirmBox : public ChromeViews::DialogDelegate { // ChromeViews::WindowDelegate virtual void WindowClosing() { delete this; } virtual bool IsModal() const { return true; } + virtual ChromeViews::View* GetContentsView() { return message_box_view_; } private: ResetDefaultsConfirmBox(HWND parent_hwnd, AdvancedPageView* page_view) : advanced_page_view_(page_view) { const int kDialogWidth = 400; // Also deleted when the window closes. - MessageBoxView* message_box_view = new MessageBoxView( + message_box_view_ = new MessageBoxView( MessageBoxView::kFlagHasMessage | MessageBoxView::kFlagHasOKButton, l10n_util::GetString(IDS_OPTIONS_RESET_MESSAGE).c_str(), std::wstring(), kDialogWidth); ChromeViews::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), - message_box_view, this)->Show(); + this)->Show(); } virtual ~ResetDefaultsConfirmBox() { } + MessageBoxView* message_box_view_; AdvancedPageView* advanced_page_view_; DISALLOW_EVIL_CONSTRUCTORS(ResetDefaultsConfirmBox); diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc index 6ed056f..8814986 100644 --- a/chrome/browser/views/options/content_page_view.cc +++ b/chrome/browser/views/options/content_page_view.cc @@ -249,11 +249,10 @@ void ContentPageView::ButtonPressed(ChromeViews::NativeButton* sender) { UserMetricsRecordAction(L"Options_ShowPasswordManager", NULL); PasswordManagerView::Show(profile()); } else if (sender == change_content_fonts_button_) { - FontsLanguagesWindowView* flwv = new FontsLanguagesWindowView(profile()); - ChromeViews::Window* w = - ChromeViews::Window::CreateChromeWindow(GetRootWindow(), gfx::Rect(), - flwv, flwv); - w->Show(); + ChromeViews::Window::CreateChromeWindow( + GetRootWindow(), + gfx::Rect(), + new FontsLanguagesWindowView(profile()))->Show(); } } diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc index 3b59198..bd5424d 100644 --- a/chrome/browser/views/options/cookies_view.cc +++ b/chrome/browser/views/options/cookies_view.cc @@ -561,7 +561,7 @@ void CookiesView::ShowCookiesWindow(Profile* profile) { if (!instance_) { CookiesView* cookies_view = new CookiesView(profile); instance_ = ChromeViews::Window::CreateChromeWindow( - NULL, gfx::Rect(), cookies_view, cookies_view); + NULL, gfx::Rect(), cookies_view); } if (!instance_->IsVisible()) { instance_->Show(); @@ -649,6 +649,10 @@ void CookiesView::WindowClosing() { instance_ = NULL; } +ChromeViews::View* CookiesView::GetContentsView() { + return this; +} + /////////////////////////////////////////////////////////////////////////////// // CookiesView, ChromeViews::View overrides: diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h index 9547acc..1f72a5c 100644 --- a/chrome/browser/views/options/cookies_view.h +++ b/chrome/browser/views/options/cookies_view.h @@ -81,6 +81,7 @@ class CookiesView : public ChromeViews::View, virtual bool CanResize() const { return true; } virtual std::wstring GetWindowTitle() const; virtual void WindowClosing(); + virtual ChromeViews::View* GetContentsView(); // ChromeViews::View overrides: virtual void Layout(); diff --git a/chrome/browser/views/options/fonts_languages_window_view.cc b/chrome/browser/views/options/fonts_languages_window_view.cc index 7b7788d..a6d9948 100644 --- a/chrome/browser/views/options/fonts_languages_window_view.cc +++ b/chrome/browser/views/options/fonts_languages_window_view.cc @@ -63,15 +63,22 @@ FontsLanguagesWindowView::~FontsLanguagesWindowView() { /////////////////////////////////////////////////////////////////////////////// // FontsLanguagesWindowView, ChromeViews::DialogDelegate implementation: +bool FontsLanguagesWindowView::Accept() { + fonts_page_->SaveChanges(); + languages_page_->SaveChanges(); + return true; +} + +/////////////////////////////////////////////////////////////////////////////// +// FontsLanguagesWindowView, ChromeViews::WindowDelegate implementation: + std::wstring FontsLanguagesWindowView::GetWindowTitle() const { return l10n_util::GetStringF(IDS_FONT_LANGUAGE_SETTING_WINDOWS_TITLE, l10n_util::GetString(IDS_PRODUCT_NAME)); } -bool FontsLanguagesWindowView::Accept() { - fonts_page_->SaveChanges(); - languages_page_->SaveChanges(); - return true; +ChromeViews::View* FontsLanguagesWindowView::GetContentsView() { + return this; } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/options/fonts_languages_window_view.h b/chrome/browser/views/options/fonts_languages_window_view.h index bdae5ea..c3e6a40 100644 --- a/chrome/browser/views/options/fonts_languages_window_view.h +++ b/chrome/browser/views/options/fonts_languages_window_view.h @@ -50,17 +50,13 @@ class FontsLanguagesWindowView : public ChromeViews::View, explicit FontsLanguagesWindowView(Profile* profile); virtual ~FontsLanguagesWindowView(); - ChromeViews::Window* container() const { return container_; } - void set_container(ChromeViews::Window* container) { - container_ = container; - } - // ChromeViews::DialogDelegate implementation: virtual bool Accept(); - virtual std::wstring GetWindowTitle() const; // ChromeViews::WindowDelegate Methods: virtual bool IsModal() const { return true; } + virtual std::wstring GetWindowTitle() const; + virtual ChromeViews::View* GetContentsView(); // ChromeViews::View overrides: virtual void Layout(); @@ -78,9 +74,6 @@ class FontsLanguagesWindowView : public ChromeViews::View, // The Tab view that contains all of the options pages. ChromeViews::TabbedPane* tabs_; - // The Options dialog window. - ChromeViews::Window* container_; - // Fonts Page View handle remembered so that prefs is updated only when // OK is pressed. FontsPageView* fonts_page_; diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc index 2c9ef19..fb449fc 100644 --- a/chrome/browser/views/options/languages_page_view.cc +++ b/chrome/browser/views/options/languages_page_view.cc @@ -243,6 +243,7 @@ class AddLanguageWindowView : public ChromeViews::View, // ChromeViews::WindowDelegate method. virtual bool IsModal() const { return true; } + virtual ChromeViews::View* GetContentsView() { return this; } // ChromeViews::ComboBox::Listener implementation: virtual void ItemChanged(ChromeViews::ComboBox* combo_box, @@ -525,12 +526,10 @@ void LanguagesPageView::ButtonPressed(ChromeViews::NativeButton* sender) { OnRemoveLanguage(); language_table_edited_ = true; } else if (sender == add_button_) { - AddLanguageWindowView* instance = new AddLanguageWindowView(this, profile()); - HWND parent_hwnd = GetViewContainer()->GetHWND(); - ChromeViews::Window* w = - ChromeViews::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), - instance, instance); - w->Show(); + ChromeViews::Window::CreateChromeWindow( + GetViewContainer()->GetHWND(), + gfx::Rect(), + new AddLanguageWindowView(this, profile()))->Show(); language_table_edited_ = true; } } diff --git a/chrome/browser/views/options/options_window_view.cc b/chrome/browser/views/options/options_window_view.cc index 72c7029..5b29fdb 100644 --- a/chrome/browser/views/options/options_window_view.cc +++ b/chrome/browser/views/options/options_window_view.cc @@ -60,11 +60,6 @@ class OptionsWindowView : public ChromeViews::View, explicit OptionsWindowView(Profile* profile); virtual ~OptionsWindowView(); - ChromeViews::Window* container() const { return container_; } - void set_container(ChromeViews::Window* container) { - container_ = container; - } - // Shows the Tab corresponding to the specified OptionsPage. void ShowOptionsPage(OptionsPage page, OptionsGroup highlight_group); @@ -73,6 +68,7 @@ class OptionsWindowView : public ChromeViews::View, virtual std::wstring GetWindowTitle() const; virtual void WindowClosing(); virtual bool Cancel(); + virtual ChromeViews::View* GetContentsView(); // ChromeViews::TabbedPane::Listener implementation: virtual void TabSelectedAt(int index); @@ -96,9 +92,6 @@ class OptionsWindowView : public ChromeViews::View, // The Tab view that contains all of the options pages. ChromeViews::TabbedPane* tabs_; - // The Options dialog window. - ChromeViews::Window* container_; - // The Profile associated with these options. Profile* profile_; @@ -135,10 +128,10 @@ void OptionsWindowView::ShowOptionsPage(OptionsPage page, OptionsGroup highlight_group) { // If the window is not yet visible, we need to show it (it will become // active), otherwise just bring it to the front. - if (!container_->IsVisible()) { - container_->Show(); + if (!window()->IsVisible()) { + window()->Show(); } else { - container_->Activate(); + window()->Activate(); } if (page == OPTIONS_PAGE_DEFAULT) { @@ -171,6 +164,10 @@ bool OptionsWindowView::Cancel() { return GetCurrentOptionsPageView()->CanClose(); } +ChromeViews::View* OptionsWindowView::GetContentsView() { + return this; +} + /////////////////////////////////////////////////////////////////////////////// // OptionsWindowView, ChromeViews::TabbedPane::Listener implementation: @@ -246,8 +243,7 @@ void ShowOptionsWindow(OptionsPage page, // about this case this will have to be fixed. if (!instance_) { instance_ = new OptionsWindowView(profile); - instance_->set_container(ChromeViews::Window::CreateChromeWindow( - NULL, gfx::Rect(), instance_, instance_)); + ChromeViews::Window::CreateChromeWindow(NULL, gfx::Rect(), instance_); // The window is alive by itself now... } instance_->ShowOptionsPage(page, highlight_group); diff --git a/chrome/browser/views/password_manager_view.cc b/chrome/browser/views/password_manager_view.cc index cf5eb50..86c6434 100644 --- a/chrome/browser/views/password_manager_view.cc +++ b/chrome/browser/views/password_manager_view.cc @@ -185,15 +185,12 @@ void PasswordManagerView::Show(Profile* profile) { instance_ = new PasswordManagerView(profile); // manager is owned by the dialog window, so Close() will delete it. - instance_->dialog_ = ChromeViews::Window::CreateChromeWindow(NULL, - gfx::Rect(), - instance_, - instance_); + ChromeViews::Window::CreateChromeWindow(NULL, gfx::Rect(), instance_); } - if (!instance_->dialog_->IsVisible()) { - instance_->dialog_->Show(); + if (!instance_->window()->IsVisible()) { + instance_->window()->Show(); } else { - instance_->dialog_->Activate(); + instance_->window()->Activate(); } } @@ -358,7 +355,7 @@ std::wstring PasswordManagerView::GetWindowTitle() const { } void PasswordManagerView::ButtonPressed(ChromeViews::NativeButton* sender) { - DCHECK(dialog_); + DCHECK(window()); // Close will result in our destruction. if (sender == &remove_all_button_) { table_model_.ForgetAndRemoveAllSignons(); @@ -397,3 +394,7 @@ void PasswordManagerView::WindowClosing() { // instance is created. instance_ = NULL; } + +ChromeViews::View* PasswordManagerView::GetContentsView() { + return this; +} diff --git a/chrome/browser/views/password_manager_view.h b/chrome/browser/views/password_manager_view.h index 19c92ad..a9eeb39 100644 --- a/chrome/browser/views/password_manager_view.h +++ b/chrome/browser/views/password_manager_view.h @@ -140,6 +140,7 @@ class PasswordManagerView : public ChromeViews::View, virtual bool HasAlwaysOnTopMenu() const; virtual std::wstring GetWindowTitle() const; virtual void WindowClosing(); + virtual ChromeViews::View* GetContentsView(); private: // Wire up buttons, the model, and the table view, and query the DB for @@ -162,9 +163,6 @@ class PasswordManagerView : public ChromeViews::View, ChromeViews::NativeButton remove_all_button_; ChromeViews::Label password_label_; - // The window containing this view. - ChromeViews::Window* dialog_; - DISALLOW_EVIL_CONSTRUCTORS(PasswordManagerView); }; #endif // CHROME_BROWSER_PASSWORD_MANAGER_VIEW_H__ diff --git a/chrome/browser/views/restart_message_box.cc b/chrome/browser/views/restart_message_box.cc index 3d940ab..d3f52cd 100644 --- a/chrome/browser/views/restart_message_box.cc +++ b/chrome/browser/views/restart_message_box.cc @@ -65,19 +65,23 @@ bool RestartMessageBox::IsModal() const { return true; } +ChromeViews::View* RestartMessageBox::GetContentsView() { + return message_box_view_; +} + //////////////////////////////////////////////////////////////////////////////// // RestartMessageBox, private: RestartMessageBox::RestartMessageBox(HWND parent_hwnd) { const int kDialogWidth = 400; // Also deleted when the window closes. - MessageBoxView* message_box_view = new MessageBoxView( + message_box_view_ = new MessageBoxView( MessageBoxView::kFlagHasMessage | MessageBoxView::kFlagHasOKButton, l10n_util::GetString(IDS_OPTIONS_RESTART_REQUIRED).c_str(), std::wstring(), kDialogWidth); ChromeViews::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), - message_box_view, this)->Show(); + this)->Show(); } RestartMessageBox::~RestartMessageBox() { diff --git a/chrome/browser/views/restart_message_box.h b/chrome/browser/views/restart_message_box.h index 5a5da45..3ae42dd 100644 --- a/chrome/browser/views/restart_message_box.h +++ b/chrome/browser/views/restart_message_box.h @@ -33,6 +33,8 @@ #include "base/basictypes.h" #include "chrome/views/dialog_delegate.h" +class MessageBoxView; + // A dialog box that tells the user that s/he needs to restart Chrome // for a change to take effect. class RestartMessageBox : public ChromeViews::DialogDelegate { @@ -49,11 +51,14 @@ class RestartMessageBox : public ChromeViews::DialogDelegate { // ChromeViews::WindowDelegate: virtual void WindowClosing(); virtual bool IsModal() const; + virtual ChromeViews::View* GetContentsView(); private: explicit RestartMessageBox(HWND parent_hwnd); virtual ~RestartMessageBox(); + MessageBoxView* message_box_view_; + DISALLOW_EVIL_CONSTRUCTORS(RestartMessageBox); }; diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc index bbec8e9..670453a 100644 --- a/chrome/browser/views/shelf_item_dialog.cc +++ b/chrome/browser/views/shelf_item_dialog.cc @@ -242,8 +242,7 @@ class PossibleURLModel : public ChromeViews::TableModel { ShelfItemDialog::ShelfItemDialog(ShelfItemDialogDelegate* delegate, Profile* profile, bool show_title) - : dialog_(NULL), - profile_(profile), + : profile_(profile), expected_title_handle_(0), delegate_(delegate) { DCHECK(profile_); @@ -338,10 +337,8 @@ ShelfItemDialog::~ShelfItemDialog() { } void ShelfItemDialog::Show(HWND parent) { - DCHECK(!dialog_); - dialog_ = - ChromeViews::Window::CreateChromeWindow(parent, gfx::Rect(), this, this); - dialog_->Show(); + DCHECK(!window()); + ChromeViews::Window::CreateChromeWindow(parent, gfx::Rect(), this)->Show(); if (title_field_) { title_field_->SetText(l10n_util::GetString(IDS_ASI_DEFAULT_TITLE)); title_field_->SelectAll(); @@ -354,8 +351,8 @@ void ShelfItemDialog::Show(HWND parent) { } void ShelfItemDialog::Close() { - DCHECK(dialog_); - dialog_->Close(); + DCHECK(window()); + window()->Close(); } std::wstring ShelfItemDialog::GetWindowTitle() const { @@ -416,7 +413,7 @@ void ShelfItemDialog::ContentsChanged(ChromeViews::TextField* sender, // so we reset the expected handle to an impossible value. if (sender == title_field_) expected_title_handle_ = 0; - dialog_->UpdateDialogButtons(); + window()->UpdateDialogButtons(); } bool ShelfItemDialog::Accept() { @@ -437,6 +434,10 @@ bool ShelfItemDialog::IsDialogButtonEnabled(DialogButton button) const { return true; } +ChromeViews::View* ShelfItemDialog::GetContentsView() { + return this; +} + void ShelfItemDialog::PerformModelChange() { DCHECK(delegate_); GURL url(GetInputURL()); @@ -455,7 +456,7 @@ void ShelfItemDialog::GetPreferredSize(CSize *out) { bool ShelfItemDialog::AcceleratorPressed( const ChromeViews::Accelerator& accelerator) { if (accelerator.GetKeyCode() == VK_ESCAPE) { - dialog_->Close(); + window()->Close(); } else if (accelerator.GetKeyCode() == VK_RETURN) { ChromeViews::FocusManager* fm = ChromeViews::FocusManager::GetFocusManager( GetViewContainer()->GetHWND()); @@ -467,8 +468,8 @@ bool ShelfItemDialog::AcceleratorPressed( // is invalid, focus is left on the url field. if (GetInputURL().is_valid()) { PerformModelChange(); - if (dialog_) - dialog_->Close(); + if (window()) + window()->Close(); } else { url_field_->SelectAll(); } @@ -492,7 +493,7 @@ void ShelfItemDialog::OnSelectionChanged() { UTF8ToWide(url_table_model_->GetURL(selection).spec())); if (title_field_) title_field_->SetText(url_table_model_->GetTitle(selection)); - dialog_->UpdateDialogButtons(); + window()->UpdateDialogButtons(); } } @@ -501,8 +502,8 @@ void ShelfItemDialog::OnDoubleClick() { if (selection >= 0 && selection < url_table_model_->RowCount()) { OnSelectionChanged(); PerformModelChange(); - if (dialog_) - dialog_->Close(); + if (window()) + window()->Close(); } } diff --git a/chrome/browser/views/shelf_item_dialog.h b/chrome/browser/views/shelf_item_dialog.h index e5c0b7d..e7f9161 100644 --- a/chrome/browser/views/shelf_item_dialog.h +++ b/chrome/browser/views/shelf_item_dialog.h @@ -88,6 +88,7 @@ class ShelfItemDialog : public ChromeViews::View, virtual std::wstring GetDialogButtonLabel(DialogButton button) const; virtual bool Accept(); virtual bool IsDialogButtonEnabled(DialogButton button) const; + virtual ChromeViews::View* GetContentsView(); // TextField::Controller. virtual void ContentsChanged(ChromeViews::TextField* sender, @@ -122,9 +123,6 @@ class ShelfItemDialog : public ChromeViews::View, // Returns the URL the user has typed. GURL GetInputURL() const; - // The dialog controller for our current dialog. - ChromeViews::Window* dialog_; - // Profile. Profile* profile_; |