diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 23:18:47 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 23:18:47 +0000 |
commit | ef5a74baa839a9a826e37eea4f7750cd55758fc8 (patch) | |
tree | 529b2dbf24ea091843dba0f72f80baba5240f327 | |
parent | 65127279b152049393928bf9a520fc26d4ede77d (diff) | |
download | chromium_src-ef5a74baa839a9a826e37eea4f7750cd55758fc8.zip chromium_src-ef5a74baa839a9a826e37eea4f7750cd55758fc8.tar.gz chromium_src-ef5a74baa839a9a826e37eea4f7750cd55758fc8.tar.bz2 |
Adds link to flash settings on clear browser data panel.
BUG=none
TEST=bring up clear browsing data dialog and make sure it has a link
to flash storage settings.
Review URL: http://codereview.chromium.org/570030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38148 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/views/clear_browsing_data.cc | 38 | ||||
-rw-r--r-- | chrome/browser/views/clear_browsing_data.h | 8 | ||||
-rw-r--r-- | views/window/dialog_client_view.cc | 56 | ||||
-rw-r--r-- | views/window/dialog_client_view.h | 14 | ||||
-rw-r--r-- | views/window/dialog_delegate.h | 2 |
5 files changed, 99 insertions, 19 deletions
diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc index 8b94636..1d0450d 100644 --- a/chrome/browser/views/clear_browsing_data.cc +++ b/chrome/browser/views/clear_browsing_data.cc @@ -5,6 +5,8 @@ #include "chrome/browser/views/clear_browsing_data.h" #include "app/l10n_util.h" +#include "app/gfx/insets.h" +#include "chrome/browser/browser.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/common/pref_names.h" @@ -15,9 +17,12 @@ #include "views/background.h" #include "views/controls/button/checkbox.h" #include "views/controls/label.h" +#include "views/controls/separator.h" #include "views/controls/throbber.h" +#include "views/grid_layout.h" #include "views/standard_layout.h" #include "views/widget/widget.h" +#include "views/window/dialog_client_view.h" #include "views/window/window.h" // The combo box is vertically aligned to the 'time-period' label, which makes @@ -313,6 +318,32 @@ views::View* ClearBrowsingDataView::GetContentsView() { return this; } +views::ClientView* ClearBrowsingDataView::CreateClientView( + views::Window* window) { + using views::GridLayout; + + views::Link* flash_link = + new views::Link(l10n_util::GetString(IDS_FLASH_STORAGE_SETTINGS)); + flash_link->SetController(this); + + views::View* settings_view = new views::View(); + GridLayout* layout = new GridLayout(settings_view); + layout->SetInsets(gfx::Insets(0, kPanelHorizMargin, 0, kButtonHEdgeMargin)); + settings_view->SetLayoutManager(layout); + views::ColumnSet* column_set = layout->AddColumnSet(0); + column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, + GridLayout::USE_PREF, 0, 0); + layout->StartRow(0, 0); + layout->AddView(new views::Separator()); + layout->StartRowWithPadding(0, 0, 0, kRelatedControlVerticalSpacing); + layout->AddView(flash_link, 1, 1, GridLayout::LEADING, GridLayout::CENTER); + + views::DialogClientView* client_view = + new views::DialogClientView(window, GetContentsView()); + client_view->SetBottomView(settings_view); + return client_view; +} + //////////////////////////////////////////////////////////////////////////////// // ClearBrowsingDataView, ComboboxModel implementation: @@ -369,6 +400,13 @@ void ClearBrowsingDataView::ButtonPressed( GetDialogClientView()->UpdateDialogButtons(); } +void ClearBrowsingDataView::LinkActivated(views::Link* source, + int event_flags) { + Browser* browser = Browser::Create(profile_); + browser->OpenURL(GURL(l10n_util::GetStringUTF8(IDS_FLASH_STORAGE_URL)), + GURL(), NEW_WINDOW, PageTransition::LINK); +} + //////////////////////////////////////////////////////////////////////////////// // ClearBrowsingDataView, private: diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h index cf0df5f..1510f95 100644 --- a/chrome/browser/views/clear_browsing_data.h +++ b/chrome/browser/views/clear_browsing_data.h @@ -10,6 +10,7 @@ #include "views/controls/button/button.h" #include "views/controls/combobox/combobox.h" #include "views/controls/label.h" +#include "views/controls/link.h" #include "views/view.h" #include "views/window/dialog_delegate.h" @@ -35,7 +36,8 @@ class ClearBrowsingDataView : public views::View, public views::ButtonListener, public ComboboxModel, public views::Combobox::Listener, - public BrowsingDataRemover::Observer { + public BrowsingDataRemover::Observer, + public views::LinkController { public: explicit ClearBrowsingDataView(Profile* profile); virtual ~ClearBrowsingDataView(void); @@ -64,6 +66,7 @@ class ClearBrowsingDataView : public views::View, virtual std::wstring GetWindowTitle() const; virtual bool Accept(); virtual views::View* GetContentsView(); + views::ClientView* CreateClientView(views::Window* window); // Overridden from ComboboxModel: virtual int GetItemCount(); @@ -76,6 +79,9 @@ class ClearBrowsingDataView : public views::View, // Overridden from views::ButtonListener: virtual void ButtonPressed(views::Button* sender, const views::Event& event); + // Overriden from views::LinkController: + virtual void LinkActivated(views::Link* source, int event_flags); + private: // Adds a new check-box as a child to the view. views::Checkbox* AddCheckbox(const std::wstring& text, bool checked); diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index b25c6bc..7ea51f1 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -112,7 +112,8 @@ DialogClientView::DialogClientView(Window* owner, View* contents_view) extra_view_(NULL), accepted_(false), listening_to_focus_(false), - saved_focus_manager_(NULL) { + saved_focus_manager_(NULL), + bottom_view_(NULL) { InitClass(); } @@ -237,6 +238,16 @@ void DialogClientView::CancelWindow() { Close(); } +void DialogClientView::SetBottomView(View* bottom_view) { + if (bottom_view_) { + RemoveChildView(bottom_view_); + delete bottom_view_; + } + bottom_view_ = bottom_view; + if (bottom_view_) + AddChildView(bottom_view_); +} + /////////////////////////////////////////////////////////////////////////////// // DialogClientView, View overrides: @@ -304,6 +315,13 @@ void DialogClientView::PaintChildren(gfx::Canvas* canvas) { void DialogClientView::Layout() { if (has_dialog_buttons()) LayoutDialogButtons(); + if (bottom_view_) { + gfx::Rect bounds = GetLocalBounds(false); + gfx::Size pref = bottom_view_->GetPreferredSize(); + bottom_view_->SetBounds(bounds.x(), + bounds.bottom() - pref.height() - kButtonVEdgeMargin, + bounds.width(), pref.height()); + } LayoutContentsView(); } @@ -357,6 +375,10 @@ gfx::Size DialogClientView::GetPreferredSize() { prefsize.set_width(std::max(prefsize.width(), width)); } } + if (bottom_view_) { + gfx::Size bottom_pref = bottom_view_->GetPreferredSize(); + prefsize.Enlarge(0, bottom_pref.height() + kButtonVEdgeMargin); + } prefsize.Enlarge(0, button_height); return prefsize; } @@ -437,14 +459,19 @@ int DialogClientView::GetButtonsHeight() const { } void DialogClientView::LayoutDialogButtons() { + gfx::Rect lb = GetLocalBounds(false); gfx::Rect extra_bounds; + int bottom_y = lb.bottom() - kButtonVEdgeMargin; + if (bottom_view_) { + gfx::Size bottom_pref = bottom_view_->GetPreferredSize(); + bottom_y -= bottom_pref.height() + kButtonVEdgeMargin + kButtonVEdgeMargin; + } if (cancel_button_) { gfx::Size ps = cancel_button_->GetPreferredSize(); - gfx::Rect lb = GetLocalBounds(false); int button_width = std::max( GetButtonWidth(MessageBoxFlags::DIALOGBUTTON_CANCEL), ps.width()); int button_x = lb.right() - button_width - kButtonHEdgeMargin; - int button_y = lb.bottom() - ps.height() - kButtonVEdgeMargin; + int button_y = bottom_y - ps.height(); cancel_button_->SetBounds(button_x, button_y, button_width, ps.height()); // The extra view bounds are dependent on this button. extra_bounds.set_width(std::max(0, cancel_button_->x())); @@ -452,14 +479,13 @@ void DialogClientView::LayoutDialogButtons() { } if (ok_button_) { gfx::Size ps = ok_button_->GetPreferredSize(); - gfx::Rect lb = GetLocalBounds(false); int button_width = std::max( GetButtonWidth(MessageBoxFlags::DIALOGBUTTON_OK), ps.width()); int ok_button_right = lb.right() - kButtonHEdgeMargin; if (cancel_button_) ok_button_right = cancel_button_->x() - kRelatedButtonHSpacing; int button_x = ok_button_right - button_width; - int button_y = lb.bottom() - ps.height() - kButtonVEdgeMargin; + int button_y = bottom_y - ps.height(); ok_button_->SetBounds(button_x, button_y, ok_button_right - button_x, ps.height()); // The extra view bounds are dependent on this button. @@ -468,7 +494,6 @@ void DialogClientView::LayoutDialogButtons() { } if (extra_view_) { gfx::Size ps = extra_view_->GetPreferredSize(); - gfx::Rect lb = GetLocalBounds(false); extra_bounds.set_x(lb.x() + kButtonHEdgeMargin); extra_bounds.set_height(ps.height()); extra_view_->SetBounds(extra_bounds); @@ -497,16 +522,6 @@ DialogDelegate* DialogClientView::GetDialogDelegate() const { return dd; } -// static -void DialogClientView::InitClass() { - static bool initialized = false; - if (!initialized) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); - initialized = true; - } -} - void DialogClientView::Close() { window()->Close(); GetDialogDelegate()->OnClose(); @@ -534,5 +549,14 @@ void DialogClientView::UpdateFocusListener() { } } +// static +void DialogClientView::InitClass() { + static bool initialized = false; + if (!initialized) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); + initialized = true; + } +} } // namespace views diff --git a/views/window/dialog_client_view.h b/views/window/dialog_client_view.h index d7a5fb2..e23e346 100644 --- a/views/window/dialog_client_view.h +++ b/views/window/dialog_client_view.h @@ -25,6 +25,9 @@ class Window; // embedded contents view to provide extra UI to be shown in the row of // buttons. // +// DialogClientView also provides the ability to set an arbitrary view that is +// positioned beneath the buttons. +// class DialogClientView : public ClientView, public ButtonListener, public FocusChangeListener { @@ -50,6 +53,11 @@ class DialogClientView : public ClientView, NativeButton* ok_button() const { return ok_button_; } NativeButton* cancel_button() const { return cancel_button_; } + // Sets the view that is positioned along the bottom of the buttons. The + // bottom view is positioned beneath the buttons at the full width of the + // dialog. If there is an existing bottom view it is removed and deleted. + void SetBottomView(View* bottom_view); + // Overridden from View: virtual void NativeViewHierarchyChanged(bool attached, gfx::NativeView native_view, @@ -106,6 +114,8 @@ class DialogClientView : public ClientView, // Updates focus listener. void UpdateFocusListener(); + static void InitClass(); + // The dialog buttons. NativeButton* ok_button_; NativeButton* cancel_button_; @@ -128,8 +138,10 @@ class DialogClientView : public ClientView, // When ancestor gets changed focus manager gets changed as well. FocusManager* saved_focus_manager_; + // View positioned along the bottom, beneath the buttons. + View* bottom_view_; + // Static resource initialization - static void InitClass(); static gfx::Font* dialog_button_font_; DISALLOW_COPY_AND_ASSIGN(DialogClientView); diff --git a/views/window/dialog_delegate.h b/views/window/dialog_delegate.h index 0d66956..19c2a89 100644 --- a/views/window/dialog_delegate.h +++ b/views/window/dialog_delegate.h @@ -104,7 +104,7 @@ class DialogDelegate : public WindowDelegate { virtual ClientView* CreateClientView(Window* window); // Called when the window has been closed. - virtual void OnClose() {}; + virtual void OnClose() {} // A helper for accessing the DialogClientView object contained by this // delegate's Window. |