1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.h" 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 7eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include <algorithm> 8eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h" 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/browser.h" 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/browser_dialogs.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/browser_navigator.h" 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/browser_window.h" 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/host_desktop.h" 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/views/constrained_window_views.h" 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/public/browser/web_contents.h" 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "google_apis/gaia/gaia_auth_util.h" 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "grit/chromium_strings.h" 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "grit/generated_resources.h" 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "third_party/skia/include/core/SkColor.h" 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h" 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/gfx/font.h" 23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/gfx/native_widget_types.h" 2458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "ui/gfx/range/range.h" 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/views/background.h" 26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ui/views/border.h" 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/views/controls/label.h" 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/views/controls/styled_label.h" 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/views/layout/box_layout.h" 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/views/layout/grid_layout.h" 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/views/layout/layout_constants.h" 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/views/widget/widget.h" 33eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "ui/views/window/dialog_client_view.h" 34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace chrome { 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Declared in browser_dialogs.h 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void ShowProfileSigninConfirmationDialog( 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Browser* browser, 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) content::WebContents* web_contents, 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Profile* profile, 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const std::string& username, 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ui::ProfileSigninConfirmationDelegate* delegate) { 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ProfileSigninConfirmationDialogViews::ShowDialog(browser, 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) profile, 45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) username, 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) delegate); 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace chrome 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)ProfileSigninConfirmationDialogViews::ProfileSigninConfirmationDialogViews( 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Browser* browser, 52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const std::string& username, 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ui::ProfileSigninConfirmationDelegate* delegate) 5446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) : browser_(browser), 5546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) username_(username), 5646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) delegate_(delegate), 5746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) prompt_for_new_profile_(true), 5846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) continue_signin_button_(NULL) { 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)ProfileSigninConfirmationDialogViews::~ProfileSigninConfirmationDialogViews() {} 62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// static 64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void ProfileSigninConfirmationDialogViews::ShowDialog( 65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Browser* browser, 66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Profile* profile, 67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const std::string& username, 68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ui::ProfileSigninConfirmationDelegate* delegate) { 69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ProfileSigninConfirmationDialogViews* dialog = 70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) new ProfileSigninConfirmationDialogViews( 710529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch browser, username, delegate); 72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ui::CheckShouldPromptForNewProfile( 73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) profile, 74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // This callback is guaranteed to be invoked, and once it is, the dialog 75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // owns itself. 76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::Bind(&ProfileSigninConfirmationDialogViews::Show, 77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::Unretained(dialog))); 78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 80868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void ProfileSigninConfirmationDialogViews::Show(bool prompt_for_new_profile) { 81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) prompt_for_new_profile_ = prompt_for_new_profile; 827d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) CreateBrowserModalDialogViews( 837d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) this, browser_->window()->GetNativeWindow())->Show(); 84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 86a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)base::string16 ProfileSigninConfirmationDialogViews::GetWindowTitle() const { 87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return l10n_util::GetStringUTF16( 88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ENTERPRISE_SIGNIN_TITLE_NEW_STYLE); 89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)base::string16 ProfileSigninConfirmationDialogViews::GetDialogButtonLabel( 92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ui::DialogButton button) const { 93eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (button == ui::DIALOG_BUTTON_OK) { 94eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // If we're giving the option to create a new profile, then OK is 95eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // "Create new profile". Otherwise it is "Continue signin". 96eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch return l10n_util::GetStringUTF16( 97eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch prompt_for_new_profile_ ? 98eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch IDS_ENTERPRISE_SIGNIN_CREATE_NEW_PROFILE_NEW_STYLE : 99eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch IDS_ENTERPRISE_SIGNIN_CONTINUE_NEW_STYLE); 100eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 101eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch return l10n_util::GetStringUTF16(IDS_ENTERPRISE_SIGNIN_CANCEL); 102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 103868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 104868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)int ProfileSigninConfirmationDialogViews::GetDefaultDialogButton() const { 105868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return ui::DIALOG_BUTTON_NONE; 106868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 108868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)views::View* ProfileSigninConfirmationDialogViews::CreateExtraView() { 109868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (prompt_for_new_profile_) { 110a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16 continue_signin_text = 111eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch l10n_util::GetStringUTF16(IDS_ENTERPRISE_SIGNIN_CONTINUE_NEW_STYLE); 112eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch continue_signin_button_ = 113eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch new views::LabelButton(this, continue_signin_text); 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) continue_signin_button_->SetStyle(views::Button::STYLE_BUTTON); 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) continue_signin_button_->SetFocusable(true); 116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 117eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch return continue_signin_button_; 118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 120868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)bool ProfileSigninConfirmationDialogViews::Accept() { 121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (delegate_) { 122eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (prompt_for_new_profile_) 123eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch delegate_->OnSigninWithNewProfile(); 124eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch else 125eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch delegate_->OnContinueSignin(); 126868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) delegate_ = NULL; 127868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 128868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return true; 129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 130868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 131868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)bool ProfileSigninConfirmationDialogViews::Cancel() { 132868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (delegate_) { 133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) delegate_->OnCancelSignin(); 134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) delegate_ = NULL; 135868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return true; 137868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 138868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 139a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)void ProfileSigninConfirmationDialogViews::OnClosed() { 140868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Cancel(); 141868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 142868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 143868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)ui::ModalType ProfileSigninConfirmationDialogViews::GetModalType() const { 14446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) return ui::MODAL_TYPE_CHILD; 145868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 146868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 147868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged( 148868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const ViewHierarchyChangedDetails& details) { 149868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (!details.is_add || details.child != this) 150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return; 151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 1527dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const SkColor kPromptBarBackgroundColor = 1537dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch ui::GetSigninConfirmationPromptBarColor( 1547dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch ui::kSigninConfirmationPromptBarBackgroundAlpha); 1557dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 156868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Create the prompt label. 157eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch size_t offset; 158a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16 domain = 1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::ASCIIToUTF16(gaia::ExtractDomainName(username_)); 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const base::string16 username = base::ASCIIToUTF16(username_); 161a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16 prompt_text = 162868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) l10n_util::GetStringFUTF16( 163868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ENTERPRISE_SIGNIN_ALERT_NEW_STYLE, 164eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch domain, &offset); 165868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) views::StyledLabel* prompt_label = new views::StyledLabel(prompt_text, this); 1667dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch prompt_label->SetDisplayedOnBackgroundColor(kPromptBarBackgroundColor); 1677dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 168868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) views::StyledLabel::RangeStyleInfo bold_style; 169868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bold_style.font_style = gfx::Font::BOLD; 170868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) prompt_label->AddStyleRange( 17158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Range(offset, offset + domain.size()), bold_style); 172868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 173eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Create the prompt bar. 174eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::View* prompt_bar = new views::View; 1755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prompt_bar->SetBorder(views::Border::CreateSolidSidedBorder( 1765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1, 1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 0, 1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1, 1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 0, 1805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::GetSigninConfirmationPromptBarColor( 1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::kSigninConfirmationPromptBarBorderAlpha))); 1827dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch prompt_bar->set_background(views::Background::CreateSolidBackground( 1837dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch kPromptBarBackgroundColor)); 184868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 185eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Create the explanation label. 186eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch std::vector<size_t> offsets; 187a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16 learn_more_text = 188868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) l10n_util::GetStringUTF16( 189868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_LEARN_MORE); 190a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16 signin_explanation_text = 191868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) l10n_util::GetStringFUTF16(prompt_for_new_profile_ ? 192868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION_NEW_STYLE : 193868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION_NEW_STYLE, 194868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) username, learn_more_text, &offsets); 195868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) explanation_label_ = new views::StyledLabel(signin_explanation_text, this); 196868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) explanation_label_->AddStyleRange( 19758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), 198ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch views::StyledLabel::RangeStyleInfo::CreateForLink()); 199868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 200eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Layout the components. 201eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout* dialog_layout = new views::GridLayout(this); 202eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch SetLayoutManager(dialog_layout); 203eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 204eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Use GridLayout inside the prompt bar because StyledLabel requires it. 205eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar); 206eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch prompt_bar->SetLayoutManager(prompt_layout); 207eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch prompt_layout->AddColumnSet(0)->AddColumn( 208eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout::FILL, views::GridLayout::CENTER, 100, 209eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout::USE_PREF, 0, 0); 210eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch prompt_layout->StartRow(0, 0); 211eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch prompt_layout->AddView(prompt_label); 212eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Use a column set with no padding. 213eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch dialog_layout->AddColumnSet(0)->AddColumn( 214eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout::FILL, views::GridLayout::FILL, 100, 215eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout::USE_PREF, 0, 0); 216eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch dialog_layout->StartRow(0, 0); 217eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch dialog_layout->AddView( 218eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch prompt_bar, 1, 1, 219eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout::FILL, views::GridLayout::FILL, 0, 0); 220eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 221eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Use a new column set for the explanation label so we can add padding. 222eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch dialog_layout->AddPaddingRow(0.0, views::kPanelVertMargin); 223eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1); 224eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); 225eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch explanation_columns->AddColumn( 226eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout::FILL, views::GridLayout::FILL, 100, 227eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout::USE_PREF, 0, 0); 228eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); 229eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch dialog_layout->StartRow(0, 1); 230eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const int kPreferredWidth = 440; 231eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch dialog_layout->AddView( 232eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch explanation_label_, 1, 1, 233eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::GridLayout::FILL, views::GridLayout::FILL, 234eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch kPreferredWidth, explanation_label_->GetHeightForWidth(kPreferredWidth)); 235868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 236868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 237868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void ProfileSigninConfirmationDialogViews::StyledLabelLinkClicked( 23858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) const gfx::Range& range, 239868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int event_flags) { 240868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chrome::NavigateParams params( 241868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) browser_, 242868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) GURL("http://support.google.com/chromeos/bin/answer.py?answer=1331549"), 243868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) content::PAGE_TRANSITION_LINK); 244868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) params.disposition = NEW_POPUP; 245868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) params.window_action = chrome::NavigateParams::SHOW_WINDOW; 246868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chrome::Navigate(¶ms); 247868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 248eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 249eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochvoid ProfileSigninConfirmationDialogViews::ButtonPressed( 250eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch views::Button* sender, 251eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const ui::Event& event) { 252eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch DCHECK(prompt_for_new_profile_); 253eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch DCHECK_EQ(continue_signin_button_, sender); 254eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (delegate_) { 255eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch delegate_->OnContinueSignin(); 256eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch delegate_ = NULL; 257eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 258eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch GetWidget()->Close(); 259eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} 260