diff options
Diffstat (limited to 'chrome/browser')
20 files changed, 163 insertions, 44 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index ba8b63b..7c3e679 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -577,7 +577,7 @@ void Browser::CloseTabContents(TabContents* contents) { } void Browser::BrowserShowHtmlDialog(HtmlDialogUIDelegate* delegate, - void* parent_window) { + gfx::NativeWindow parent_window) { ShowHtmlDialog(delegate, parent_window); } @@ -1983,7 +1983,7 @@ gfx::Rect Browser::GetRootWindowResizerRect() const { } void Browser::ShowHtmlDialog(HtmlDialogUIDelegate* delegate, - void* parent_window) { + gfx::NativeWindow parent_window) { window_->ShowHTMLDialog(delegate, parent_window); } diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 92242f0..d1aca35 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -255,7 +255,7 @@ class Browser : public TabStripModelDelegate, // string input to use during initialization). |parent_window| is the window // that should be parent of the dialog, or NULL for the default. void BrowserShowHtmlDialog(HtmlDialogUIDelegate* delegate, - void* parent_window); + gfx::NativeWindow parent_window); // Called when a popup select is about to be displayed. void BrowserRenderWidgetShowing(); @@ -491,7 +491,7 @@ class Browser : public TabStripModelDelegate, bool* proceed_to_fire_unload); virtual gfx::Rect GetRootWindowResizerRect() const; virtual void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, - void* parent_window); + gfx::NativeWindow parent_window); virtual void SetFocusToLocationBar(); virtual void RenderWidgetShowing(); virtual ExtensionFunctionDispatcher *CreateExtensionFunctionDispatcher( diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index d804bc1..3ce7097 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -174,7 +174,7 @@ class BrowserWindow { // the window the dialog should be opened modal to and is a native window // handle. virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, - void* parent_window) = 0; + gfx::NativeWindow parent_window) = 0; // BrowserThemeProvider calls this when a user has changed his or her theme, // indicating that it's time to redraw everything. diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 2b99a0d2..2e1e919 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -65,7 +65,7 @@ class BrowserWindowCocoa : public BrowserWindow, virtual void ShowNewProfileDialog(); virtual void ConfirmBrowserCloseWithPendingDownloads(); virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, - void* parent_window); + gfx::NativeWindow parent_window); virtual void UserChangedTheme(); virtual int GetExtraRenderViewHeight() const; diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index fd62753..0e471fc 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -220,7 +220,7 @@ void BrowserWindowCocoa::ConfirmBrowserCloseWithPendingDownloads() { } void BrowserWindowCocoa::ShowHTMLDialog(HtmlDialogUIDelegate* delegate, - void* parent_window) { + gfx::NativeWindow parent_window) { NOTIMPLEMENTED(); } diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 6d1701d..34e42f0 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -595,7 +595,7 @@ void BrowserWindowGtk::ShowNewProfileDialog() { } void BrowserWindowGtk::ShowHTMLDialog(HtmlDialogUIDelegate* delegate, - void* parent_window) { + gfx::NativeWindow parent_window) { NOTIMPLEMENTED(); } diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index 8516c35..9982f35 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -77,7 +77,7 @@ class BrowserWindowGtk : public BrowserWindow, virtual void ShowNewProfileDialog(); virtual void ConfirmBrowserCloseWithPendingDownloads(); virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, - void* parent_window); + gfx::NativeWindow parent_window); virtual void UserChangedTheme(); virtual int GetExtraRenderViewHeight() const; diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index 4ba9553..e937fec 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_ #include "base/basictypes.h" +#include "base/gfx/native_widget_types.h" #include "base/gfx/rect.h" #include "chrome/common/page_transition_types.h" #include "webkit/glue/window_open_disposition.h" @@ -120,7 +121,7 @@ class TabContentsDelegate { // string input to use during initialization). |parent_window| is the window // that should be parent of the dialog, or NULL for the default. virtual void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, - void* parent_window) { } + gfx::NativeWindow parent_window) { } // Tells us that we've finished firing this tab's beforeunload event. // The proceed bool tells us whether the user chose to proceed closing the diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 9565ad8..a9cca4f 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -26,6 +26,7 @@ #include "views/controls/text_field.h" #include "views/controls/throbber.h" #include "views/standard_layout.h" +#include "views/widget/widget.h" #include "views/window/window.h" #include "webkit/glue/webkit_glue.h" @@ -62,6 +63,17 @@ std::wstring StringSubRange(const std::wstring& text, size_t start, } // namespace +namespace browser { + +// Declared in browser_dialogs.h so that others don't need to depend on our .h. +void ShowAboutChromeView(views::Widget* parent, + Profile* profile) { + views::Window::CreateChromeWindow(parent->GetNativeView(), gfx::Rect(), + new AboutChromeView(profile))->Show(); +} + +} // namespace browser + //////////////////////////////////////////////////////////////////////////////// // AboutChromeView, public: diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc index 94eea8b..d6f0a99 100644 --- a/chrome/browser/views/bookmark_bubble_view.cc +++ b/chrome/browser/views/bookmark_bubble_view.cc @@ -47,6 +47,30 @@ static const size_t kMaxMRUFolders = 5; // Bubble close image. static SkBitmap* kCloseImage = NULL; +// Declared in browser_dialogs.h so callers don't have to depend on our header. + +namespace browser { + +void ShowBookmarkBubbleView(views::Window* parent, + const gfx::Rect& bounds, + InfoBubbleDelegate* delegate, + Profile* profile, + const GURL& url, + bool newly_bookmarked) { + BookmarkBubbleView::Show(parent, bounds, delegate, profile, url, + newly_bookmarked); +} + +void HideBookmarkBubbleView() { + BookmarkBubbleView::Hide(); +} + +bool IsBookmarkBubbleViewShowing() { + return BookmarkBubbleView::IsShowing(); +} + +} // namespace browser + // RecentlyUsedFoldersModel --------------------------------------------------- BookmarkBubbleView::RecentlyUsedFoldersModel::RecentlyUsedFoldersModel( diff --git a/chrome/browser/views/browser_dialogs.h b/chrome/browser/views/browser_dialogs.h index 47221fe..7884719 100644 --- a/chrome/browser/views/browser_dialogs.h +++ b/chrome/browser/views/browser_dialogs.h @@ -5,21 +5,65 @@ #ifndef CHROME_BROWSER_VIEWS_BROWSER_DIALOGS_H_ #define CHROME_BROWSER_VIEWS_BROWSER_DIALOGS_H_ +#include "base/gfx/native_widget_types.h" + // This file contains functions for running a variety of browser dialogs and // popups. The dialogs here are the ones that the caller does not need to // access the class of the popup. It allows us to break dependencies by // allowing the callers to not depend on the classes implementing the dialogs. +class Browser; +class GURL; +class HtmlDialogUIDelegate; +class InfoBubbleDelegate; class Profile; class TabContents; +namespace gfx { +class Rect; +} // namespace gfx + namespace views { class Widget; +class Window; } // namespace views +namespace browser { + // Shows the "Report a problem with this page" dialog box. See BugReportView. void ShowBugReportView(views::Widget* parent, Profile* profile, TabContents* tab); +// Shows the "Clear browsing data" dialog box. See ClearBrowsingDataView. +void ShowClearBrowsingDataView(views::Widget* parent, + Profile* profile); + +// Shows the "Select profile" dialog. See SelectProfileDialog. +void ShowSelectProfileDialog(); + +// Shows the "Importer" dialog. See ImporterView. +void ShowImporterView(views::Widget* parent, + Profile* profile); + +// Shows or hides the global bookmark bubble for the star button. +void ShowBookmarkBubbleView(views::Window* parent, + const gfx::Rect& bounds, + InfoBubbleDelegate* delegate, + Profile* profile, + const GURL& url, + bool newly_bookmarked); +void HideBookmarkBubbleView(); +bool IsBookmarkBubbleViewShowing(); + +// Shows the about dialog. See AboutChromeView. +void ShowAboutChromeView(views::Widget* parent, + Profile* profile); + +// Shows an HTML dialog. See HtmlDialogView. +void ShowHtmlDialogView(gfx::NativeWindow parent, Browser* browser, + HtmlDialogUIDelegate* delegate); + +} // namespace browser + #endif // CHROME_BROWSER_VIEWS_BROWSER_DIALOGS_H_ diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj index e76d85f..f36a0072 100644 --- a/chrome/browser/views/browser_views.vcproj +++ b/chrome/browser/views/browser_views.vcproj @@ -512,6 +512,10 @@ > </File> <File + RelativePath=".\browser_dialogs.h" + > + </File> + <File RelativePath=".\bug_report_view.cc" > </File> diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc index 1c91753..a349b31 100644 --- a/chrome/browser/views/bug_report_view.cc +++ b/chrome/browser/views/bug_report_view.cc @@ -113,6 +113,8 @@ class BugReportView::PostCleanup : public URLFetcher::Delegate { DISALLOW_COPY_AND_ASSIGN(PostCleanup); }; +namespace browser { + // Global "display this dialog" function declared in browser_dialogs.h. void ShowBugReportView(views::Widget* parent, Profile* profile, @@ -132,6 +134,8 @@ void ShowBugReportView(views::Widget* parent, view)->Show(); } +} // namespace browser + BugReportView::PostCleanup::PostCleanup() { } diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc index 865ba21..43692e1 100644 --- a/chrome/browser/views/clear_browsing_data.cc +++ b/chrome/browser/views/clear_browsing_data.cc @@ -17,6 +17,7 @@ #include "views/controls/label.h" #include "views/controls/throbber.h" #include "views/standard_layout.h" +#include "views/widget/widget.h" #include "views/window/window.h" // The combo box is vertically aligned to the 'time-period' label, which makes @@ -25,6 +26,18 @@ // the label, giving it a little breathing space. static const int kExtraMarginForTimePeriodLabel = 3; +namespace browser { + +// Defined in browser_dialogs.h for creation of the view. +void ShowClearBrowsingDataView(views::Widget* parent, + Profile* profile) { + views::Window::CreateChromeWindow( + parent->GetNativeView(), gfx::Rect(), + new ClearBrowsingDataView(profile))->Show(); +} + +} // namespace browser + //////////////////////////////////////////////////////////////////////////////// // ClearBrowsingDataView, public: diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 0f850c1..bb213ac 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -23,24 +23,19 @@ #include "chrome/browser/view_ids.h" #include "chrome/browser/views/about_chrome_view.h" #include "chrome/browser/views/bookmark_bar_view.h" -#include "chrome/browser/views/bookmark_bubble_view.h" #include "chrome/browser/views/bookmark_manager_view.h" #include "chrome/browser/views/browser_bubble.h" #include "chrome/browser/views/browser_dialogs.h" #include "chrome/browser/views/bug_report_view.h" #include "chrome/browser/views/chrome_views_delegate.h" -#include "chrome/browser/views/clear_browsing_data.h" #include "chrome/browser/views/download_shelf_view.h" #include "chrome/browser/views/find_bar_win.h" #include "chrome/browser/views/frame/browser_frame.h" #include "chrome/browser/views/fullscreen_exit_bubble.h" -#include "chrome/browser/views/html_dialog_view.h" -#include "chrome/browser/views/importer_view.h" #include "chrome/browser/views/infobars/infobar_container.h" #include "chrome/browser/views/keyword_editor_view.h" #include "chrome/browser/views/new_profile_dialog.h" #include "chrome/browser/views/options/passwords_exceptions_window_view.h" -#include "chrome/browser/views/select_profile_dialog.h" #include "chrome/browser/views/status_bubble_views.h" #include "chrome/browser/views/tab_contents_container_view.h" #include "chrome/browser/views/tabs/tab_strip.h" @@ -338,7 +333,7 @@ void BrowserView::WindowMoved() { (*bubble)->BrowserWindowMoved(); } - BookmarkBubbleView::Hide(); + browser::HideBookmarkBubbleView(); // Close the omnibox popup, if any. if (toolbar_->GetLocationBarView()) @@ -796,9 +791,7 @@ void BrowserView::ToggleBookmarkBar() { } void BrowserView::ShowAboutChromeDialog() { - views::Window::CreateChromeWindow( - GetWidget()->GetNativeView(), gfx::Rect(), - new AboutChromeView(browser_->profile()))->Show(); + browser::ShowAboutChromeView(GetWidget(), browser_->profile()); } void BrowserView::ShowBookmarkManager() { @@ -814,19 +807,15 @@ void BrowserView::ShowReportBugDialog() { TabContents* current_tab = browser_->GetSelectedTabContents(); if (!current_tab) return; - ShowBugReportView(GetWidget(), browser_->profile(), current_tab); + browser::ShowBugReportView(GetWidget(), browser_->profile(), current_tab); } void BrowserView::ShowClearBrowsingDataDialog() { - views::Window::CreateChromeWindow( - GetWidget()->GetNativeView(), gfx::Rect(), - new ClearBrowsingDataView(browser_->profile()))->Show(); + browser::ShowClearBrowsingDataView(GetWidget(), browser_->profile()); } void BrowserView::ShowImportDialog() { - views::Window::CreateChromeWindow( - GetWidget()->GetNativeView(), gfx::Rect(), - new ImporterView(browser_->profile()))->Show(); + browser::ShowImporterView(GetWidget(), browser_->profile()); } void BrowserView::ShowSearchEnginesDialog() { @@ -838,7 +827,7 @@ void BrowserView::ShowPasswordManager() { } void BrowserView::ShowSelectProfileDialog() { - SelectProfileDialog::RunDialog(); + ShowSelectProfileDialog(); } void BrowserView::ShowNewProfileDialog() { @@ -853,17 +842,11 @@ void BrowserView::ConfirmBrowserCloseWithPendingDownloads() { } void BrowserView::ShowHTMLDialog(HtmlDialogUIDelegate* delegate, - void* parent_window) { -#if defined(OS_WIN) - HWND parent_hwnd = reinterpret_cast<HWND>(parent_window); - parent_hwnd = parent_hwnd ? parent_hwnd : GetWidget()->GetNativeView(); - HtmlDialogView* html_view = new HtmlDialogView(browser_.get(), delegate); - views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), html_view); - html_view->InitDialog(); - html_view->window()->Show(); -#else - NOTIMPLEMENTED(); -#endif + gfx::NativeWindow parent_window) { + // Default to using our window as the parent if the argument is not specified. + gfx::NativeWindow parent = parent_window ? parent_window + : GetWidget()->GetNativeView(); + browser::ShowHtmlDialogView(parent_window, browser_.get(), delegate); } void BrowserView::UserChangedTheme() { diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 2bbbc5c..64294fe 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -219,7 +219,7 @@ class BrowserView : public BrowserWindow, virtual void ShowNewProfileDialog(); virtual void ConfirmBrowserCloseWithPendingDownloads(); virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, - void* parent_window); + gfx::NativeWindow parent_window); virtual void UserChangedTheme(); virtual int GetExtraRenderViewHeight() const; diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc index 1e9569c..4be7870 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -9,6 +9,19 @@ #include "views/widget/root_view.h" #include "views/window/window.h" +namespace browser { + +// Declared in browser_dialogs.h so that others don't need to depend on our .h. +void ShowHtmlDialogView(gfx::NativeWindow parent, Browser* browser, + HtmlDialogUIDelegate* delegate) { + HtmlDialogView* html_view = new HtmlDialogView(browser, delegate); + views::Window::CreateChromeWindow(parent, gfx::Rect(), html_view); + html_view->InitDialog(); + html_view->window()->Show(); +} + +} // namespace browser + //////////////////////////////////////////////////////////////////////////////// // HtmlDialogView, public: diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc index 4bee708..604b668 100644 --- a/chrome/browser/views/importer_view.cc +++ b/chrome/browser/views/importer_view.cc @@ -12,11 +12,23 @@ #include "views/controls/label.h" #include "views/grid_layout.h" #include "views/standard_layout.h" +#include "views/widget/widget.h" #include "views/window/window.h" using views::ColumnSet; using views::GridLayout; +namespace browser { + +// Declared in browser_dialogs.h so caller's don't have to depend on our header. +void ShowImporterView(views::Widget* parent, + Profile* profile) { + views::Window::CreateChromeWindow(parent->GetNativeView(), gfx::Rect(), + new ImporterView(profile))->Show(); +} + +} // namespace browser + ImporterView::ImporterView(Profile* profile) : import_from_label_(NULL), profile_combobox_(NULL), diff --git a/chrome/browser/views/select_profile_dialog.cc b/chrome/browser/views/select_profile_dialog.cc index faa4a04..81ebbfb 100644 --- a/chrome/browser/views/select_profile_dialog.cc +++ b/chrome/browser/views/select_profile_dialog.cc @@ -25,6 +25,15 @@ using views::ColumnSet; using views::GridLayout; +namespace browser { + +// Defined in browser_dialogs so callers don't have to depend on our header. +void ShowSelectProfileDialog() { + SelectProfileDialog::RunDialog(); +} + +} // namespace browser + // static void SelectProfileDialog::RunDialog() { // When the window closes, it will delete itself. diff --git a/chrome/browser/views/toolbar_star_toggle.cc b/chrome/browser/views/toolbar_star_toggle.cc index e9440e4..252cc83 100644 --- a/chrome/browser/views/toolbar_star_toggle.cc +++ b/chrome/browser/views/toolbar_star_toggle.cc @@ -7,7 +7,7 @@ #include "app/resource_bundle.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser.h" -#include "chrome/browser/views/bookmark_bubble_view.h" +#include "chrome/browser/views/browser_dialogs.h" #include "chrome/browser/views/toolbar_view.h" #include "googleurl/src/gurl.h" #include "grit/theme_resources.h" @@ -42,8 +42,8 @@ void ToolbarStarToggle::ShowStarBubble(const GURL& url, bool newly_bookmarked) { // of the star. gfx::Rect star_bounds(star_location.x() + 1, star_location.y(), width(), height()); - BookmarkBubbleView::Show(host_->GetWindow(), star_bounds, this, - host_->profile(), url, newly_bookmarked); + browser::ShowBookmarkBubbleView(host_->GetWindow(), star_bounds, this, + host_->profile(), url, newly_bookmarked); } bool ToolbarStarToggle::OnMousePressed(const views::MouseEvent& e) { @@ -64,12 +64,12 @@ void ToolbarStarToggle::OnDragDone() { } void ToolbarStarToggle::NotifyClick(int mouse_event_flags) { - if (!ignore_click_ && !BookmarkBubbleView::IsShowing()) + if (!ignore_click_ && !browser::IsBookmarkBubbleViewShowing()) ToggleImageButton::NotifyClick(mouse_event_flags); } SkBitmap ToolbarStarToggle::GetImageToPaint() { - if (BookmarkBubbleView::IsShowing()) { + if (browser::IsBookmarkBubbleViewShowing()) { ResourceBundle &rb = ResourceBundle::GetSharedInstance(); return *rb.GetBitmapNamed(IDR_STARRED_P); } |