| 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 a4f6b0d9c2cc4fa6e626459b31bd9c049150c126..7338cbccf2da1d9fda40de9836f9eb935f37d0ab 100644
|
| --- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc
|
| +++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
|
| @@ -68,6 +68,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"
|
| @@ -78,14 +79,18 @@ namespace {
|
|
|
| const int kFixedMenuWidth = 250;
|
| const int kButtonHeight = 32;
|
| -const int kFixedGaiaViewHeight = 440;
|
| -const int kFixedGaiaViewWidth = 360;
|
| +const int kPasswordCombinedFixedGaiaViewHeight = 440;
|
| +const int kPasswordCombinedFixedGaiaViewWidth = 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;
|
| @@ -134,6 +139,23 @@ std::string GetAuthErrorAccountId(Profile* profile) {
|
| return error->error_account_id();
|
| }
|
|
|
| +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;
|
| +}
|
| +
|
| // BackgroundColorHoverButton -------------------------------------------------
|
|
|
| // A custom button that allows for setting a background color when hovered over.
|
| @@ -182,6 +204,55 @@ 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() {}
|
| +
|
| + 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_ = nullptr; // Not owned.
|
| + scoped_ptr<views::Widget> title_widget_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(HostView);
|
| +};
|
| +
|
| +void HostView::Initialize(views::View* title_view, views::View* main_view) {
|
| + title_view_ = title_view;
|
| + AddChildView(main_view);
|
| + SetLayoutManager(new views::FillLayout());
|
| +}
|
| +
|
| +void HostView::ViewHierarchyChanged(
|
| + const ViewHierarchyChangedDetails& details) {
|
| + if (title_widget_ != nullptr || GetWidget() == 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 -------------------------------------------------
|
| @@ -401,23 +472,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);
|
| @@ -724,10 +784,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: {
|
| + const int width = switches::UsePasswordSeparatedSigninFlow()
|
| + ? kFixedGaiaViewWidth : kPasswordCombinedFixedGaiaViewWidth;
|
| + 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();
|
| @@ -1579,24 +1642,36 @@ views::View* ProfileChooserView::CreateGaiaSigninView(
|
| return NULL;
|
| }
|
|
|
| - // Adds Gaia signin webview
|
| + // Adds Gaia signin webview.
|
| + const gfx::Size pref_size = switches::UsePasswordSeparatedSigninFlow()
|
| + ? gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight)
|
| + : gfx::Size(kPasswordCombinedFixedGaiaViewWidth,
|
| + kPasswordCombinedFixedGaiaViewHeight);
|
| 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::UsePasswordSeparatedSigninFlow()) {
|
| + gaia_signin_cancel_button_ = 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, kPasswordCombinedFixedGaiaViewWidth);
|
| }
|
|
|
| views::View* ProfileChooserView::CreateAccountRemovalView() {
|
|
|