Chromium Code Reviews| Index: chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| index f61db462d9c4d91c3faf440c3da8055a1d874684..23ffdee2fe02acdeac2ec18e8b5ad0c51340f6bb 100644 |
| --- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| +++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| @@ -67,6 +67,7 @@ |
| #include "ui/views/controls/styled_label.h" |
| #include "ui/views/controls/textfield/textfield.h" |
| #include "ui/views/controls/webview/webview.h" |
| +#include "ui/views/layout/fill_layout.h" |
| #include "ui/views/layout/grid_layout.h" |
| #include "ui/views/layout/layout_constants.h" |
| #include "ui/views/widget/widget.h" |
| @@ -77,14 +78,18 @@ namespace { |
| const int kFixedMenuWidth = 250; |
| const int kButtonHeight = 32; |
| -const int kFixedGaiaViewHeight = 440; |
| -const int kFixedGaiaViewWidth = 360; |
| +const int kOldFixedGaiaViewHeight = 440; |
| +const int kOldFixedGaiaViewWidth = 360; |
| +const int kFixedGaiaViewHeight = 512; |
| +const int kFixedGaiaViewWidth = 448; |
| const int kFixedAccountRemovalViewWidth = 280; |
| const int kFixedSwitchUserViewWidth = 320; |
| const int kLargeImageSide = 88; |
| const int kVerticalSpacing = 16; |
| +const int kTitleViewNativeWidgetOffset = 8; |
| + |
| bool IsProfileChooser(profiles::BubbleViewMode mode) { |
| return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
| mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
| @@ -181,6 +186,62 @@ class SizedContainer : public views::View { |
| gfx::Size preferred_size_; |
| }; |
| +// A view to host the GAIA webview overlapped with a back button. This class |
| +// is needed to reparent the back button inside a native view so that on |
| +// windows, user input can be be properly routed to the button. |
| +class HostView : public views::View { |
| + public: |
| + HostView() : title_view_(nullptr), title_widget_(nullptr) {} |
| + ~HostView() override; |
| + |
| + void Initialize(views::View* title_view, views::View* main_view); |
| + |
| + private: |
| + // views::View: |
| + void ViewHierarchyChanged( |
| + const ViewHierarchyChangedDetails& details) override; |
| + |
| + // The title itself and the overlaped widget that contains it. |
| + views::View* title_view_; |
| + scoped_ptr<views::Widget> title_widget_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HostView); |
| +}; |
| + |
| +HostView::~HostView() {} |
| + |
| +void HostView::Initialize(views::View* title_view, views::View* main_view) { |
| + title_view_ = title_view; |
| + title_view_->set_owned_by_client(); |
| + AddChildView(main_view); |
| + SetLayoutManager(new views::FillLayout()); |
| +} |
| + |
| +void HostView::ViewHierarchyChanged( |
| + const ViewHierarchyChangedDetails& details) { |
| + if (!details.is_add || details.child != this) |
| + return; |
| + |
| + if (title_widget_ != nullptr) |
| + return; |
| + |
| + // The title view must be placed within its own widget so that it can |
| + // properly receive user input when overlapped on another view. |
| + views::Widget::InitParams params( |
| + views::Widget::InitParams::TYPE_CONTROL); |
| + params.parent = GetWidget()->GetNativeView(); |
| + params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + title_widget_.reset(new views::Widget); |
| + title_widget_->Init(params); |
| + title_widget_->SetContentsView(title_view_); |
| + |
| + gfx::Rect bounds(title_view_->GetPreferredSize()); |
| + title_view_->SetBoundsRect(bounds); |
| + bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); |
| + title_widget_->SetBounds(bounds); |
| +} |
| + |
| } // namespace |
| // RightAlignedIconLabelButton ------------------------------------------------- |
| @@ -400,23 +461,12 @@ class TitleCard : public views::View { |
| public: |
| TitleCard(const base::string16& message, views::ButtonListener* listener, |
| views::ImageButton** back_button) { |
| - back_button_ = new views::ImageButton(listener); |
| - back_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| - views::ImageButton::ALIGN_MIDDLE); |
| - ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| - back_button_->SetImage(views::ImageButton::STATE_NORMAL, |
| - rb->GetImageSkiaNamed(IDR_BACK)); |
| - back_button_->SetImage(views::ImageButton::STATE_HOVERED, |
| - rb->GetImageSkiaNamed(IDR_BACK_H)); |
| - back_button_->SetImage(views::ImageButton::STATE_PRESSED, |
| - rb->GetImageSkiaNamed(IDR_BACK_P)); |
| - back_button_->SetImage(views::ImageButton::STATE_DISABLED, |
| - rb->GetImageSkiaNamed(IDR_BACK_D)); |
| - back_button_->SetFocusable(true); |
| + back_button_ = CreateBackButton(listener); |
| *back_button = back_button_; |
| title_label_ = new views::Label(message); |
| title_label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| + ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| const gfx::FontList& medium_font_list = |
| rb->GetFontList(ui::ResourceBundle::MediumFont); |
| title_label_->SetFontList(medium_font_list); |
| @@ -425,6 +475,23 @@ class TitleCard : public views::View { |
| AddChildView(title_label_); |
| } |
| + static views::ImageButton* CreateBackButton(views::ButtonListener* listener) { |
| + views::ImageButton* back_button = new views::ImageButton(listener); |
| + back_button->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| + views::ImageButton::ALIGN_MIDDLE); |
| + ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| + back_button->SetImage(views::ImageButton::STATE_NORMAL, |
| + rb->GetImageSkiaNamed(IDR_BACK)); |
| + back_button->SetImage(views::ImageButton::STATE_HOVERED, |
| + rb->GetImageSkiaNamed(IDR_BACK_H)); |
| + back_button->SetImage(views::ImageButton::STATE_PRESSED, |
| + rb->GetImageSkiaNamed(IDR_BACK_P)); |
| + back_button->SetImage(views::ImageButton::STATE_DISABLED, |
| + rb->GetImageSkiaNamed(IDR_BACK_D)); |
| + back_button->SetFocusable(true); |
| + return back_button; |
| + } |
| + |
| // Creates a new view that has the |title_card| with horizontal padding at the |
| // top, an edge-to-edge separator below, and the specified |view| at the |
| // bottom. |
| @@ -723,10 +790,13 @@ void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
| switch (view_mode_) { |
| case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
| case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
| - case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: |
| - layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); |
| + case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { |
| + int width = switches::UseNewGaiaFlow() |
| + ? kFixedGaiaViewWidth : kOldFixedGaiaViewWidth; |
| + layout = CreateSingleColumnLayout(this, width); |
| sub_view = CreateGaiaSigninView(&view_to_focus); |
| break; |
| + } |
| case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
| layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); |
| sub_view = CreateAccountRemovalView(); |
| @@ -1584,24 +1654,35 @@ views::View* ProfileChooserView::CreateGaiaSigninView( |
| return NULL; |
| } |
| - // Adds Gaia signin webview |
| + // Adds Gaia signin webview. |
| + gfx::Size pref_size = switches::UseNewGaiaFlow() |
|
anthonyvd
2015/09/15 18:13:47
Maybe move this before the switch and use pref_siz
Roger Tawa OOO till Jul 10th
2015/09/16 19:27:29
Line 796 is in another function. Maybe I'm missin
anthonyvd
2015/09/16 19:55:32
That's entirely my bad, the lines in between were
|
| + ? gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight) |
| + : gfx::Size(kOldFixedGaiaViewWidth, kOldFixedGaiaViewHeight); |
| Profile* profile = browser_->profile(); |
| views::WebView* web_view = new views::WebView(profile); |
| web_view->LoadInitialURL(url); |
| web_view->GetWebContents()->SetDelegate(this); |
| - web_view->SetPreferredSize( |
| - gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight)); |
| + web_view->SetPreferredSize(pref_size); |
| content::RenderWidgetHostView* rwhv = |
| web_view->GetWebContents()->GetRenderWidgetHostView(); |
| if (rwhv) |
| rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); |
| + |
| + if (signin_content_view) |
| + *signin_content_view = web_view; |
| + |
| + if (switches::UseNewGaiaFlow()) { |
| + gaia_signin_cancel_button_ = TitleCard::CreateBackButton(this); |
| + HostView* host = new HostView(); |
| + host->Initialize(gaia_signin_cancel_button_, web_view); |
| + return host; |
| + } |
| + |
| TitleCard* title_card = new TitleCard(l10n_util::GetStringUTF16(message_id), |
| this, |
| &gaia_signin_cancel_button_); |
| - if (signin_content_view) |
| - *signin_content_view = web_view; |
| return TitleCard::AddPaddedTitleCard( |
| - web_view, title_card, kFixedGaiaViewWidth); |
| + web_view, title_card, kOldFixedGaiaViewWidth); |
| } |
| views::View* ProfileChooserView::CreateAccountRemovalView() { |