| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/passwords/account_chooser_dialog_view.h" | 5 #include "chrome/browser/ui/views/passwords/account_chooser_dialog_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser_dialogs.h" | 9 #include "chrome/browser/ui/browser_dialogs.h" |
| 10 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | 10 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 SINGLE_VIEW_COLUMN_SET, | 36 SINGLE_VIEW_COLUMN_SET, |
| 37 SINGLE_VIEW_COLUMN_SET_NO_PADDING, | 37 SINGLE_VIEW_COLUMN_SET_NO_PADDING, |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Construct a |type| ColumnSet and add it to |layout|. | 40 // Construct a |type| ColumnSet and add it to |layout|. |
| 41 void BuildColumnSet(ColumnSetType type, views::GridLayout* layout) { | 41 void BuildColumnSet(ColumnSetType type, views::GridLayout* layout) { |
| 42 views::ColumnSet* column_set = layout->AddColumnSet(type); | 42 views::ColumnSet* column_set = layout->AddColumnSet(type); |
| 43 const int horizontal_padding = | 43 const int horizontal_padding = |
| 44 type == SINGLE_VIEW_COLUMN_SET | 44 type == SINGLE_VIEW_COLUMN_SET |
| 45 ? ChromeLayoutProvider::Get()->GetDistanceMetric( | 45 ? ChromeLayoutProvider::Get()->GetDistanceMetric( |
| 46 DISTANCE_DIALOG_BUTTON_MARGIN) | 46 views::DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN) |
| 47 : 0; | 47 : 0; |
| 48 column_set->AddPaddingColumn(0, horizontal_padding); | 48 column_set->AddPaddingColumn(0, horizontal_padding); |
| 49 column_set->AddColumn(views::GridLayout::FILL, | 49 column_set->AddColumn(views::GridLayout::FILL, |
| 50 views::GridLayout::FILL, | 50 views::GridLayout::FILL, |
| 51 1, | 51 1, |
| 52 views::GridLayout::USE_PREF, | 52 views::GridLayout::USE_PREF, |
| 53 0, | 53 0, |
| 54 0); | 54 0); |
| 55 column_set->AddPaddingColumn(0, horizontal_padding); | 55 column_set->AddPaddingColumn(0, horizontal_padding); |
| 56 } | 56 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 78 int item_height = 0; | 78 int item_height = 0; |
| 79 for (const auto& form : forms) { | 79 for (const auto& form : forms) { |
| 80 std::pair<base::string16, base::string16> titles = | 80 std::pair<base::string16, base::string16> titles = |
| 81 GetCredentialLabelsForAccountChooser(*form); | 81 GetCredentialLabelsForAccountChooser(*form); |
| 82 CredentialsItemView* credential_view = new CredentialsItemView( | 82 CredentialsItemView* credential_view = new CredentialsItemView( |
| 83 button_listener, titles.first, titles.second, kButtonHoverColor, | 83 button_listener, titles.first, titles.second, kButtonHoverColor, |
| 84 form.get(), request_context); | 84 form.get(), request_context); |
| 85 credential_view->SetLowerLabelColor(kAutoSigninTextColor); | 85 credential_view->SetLowerLabelColor(kAutoSigninTextColor); |
| 86 ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); | 86 ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); |
| 87 gfx::Insets dialog_insets = | 87 gfx::Insets dialog_insets = |
| 88 layout_provider->GetInsetsMetric(views::INSETS_PANEL); | 88 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS); |
| 89 const int vertical_padding = layout_provider->GetDistanceMetric( | 89 const int vertical_padding = layout_provider->GetDistanceMetric( |
| 90 views::DISTANCE_RELATED_CONTROL_VERTICAL); | 90 views::DISTANCE_RELATED_CONTROL_VERTICAL); |
| 91 credential_view->SetBorder( | 91 credential_view->SetBorder( |
| 92 views::CreateEmptyBorder(vertical_padding, dialog_insets.left(), | 92 views::CreateEmptyBorder(vertical_padding, dialog_insets.left(), |
| 93 vertical_padding, dialog_insets.right())); | 93 vertical_padding, dialog_insets.right())); |
| 94 item_height = std::max(item_height, credential_view->GetPreferredHeight()); | 94 item_height = std::max(item_height, credential_view->GetPreferredHeight()); |
| 95 list_view->AddChildView(credential_view); | 95 list_view->AddChildView(credential_view); |
| 96 } | 96 } |
| 97 views::ScrollView* scroll_view = new views::ScrollView; | 97 views::ScrollView* scroll_view = new views::ScrollView; |
| 98 scroll_view->ClipHeightTo(0, kMaxHeightAccounts * item_height); | 98 scroll_view->ClipHeightTo(0, kMaxHeightAccounts * item_height); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 // Show the title. | 214 // Show the title. |
| 215 ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); | 215 ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); |
| 216 layout->StartRowWithPadding( | 216 layout->StartRowWithPadding( |
| 217 0, SINGLE_VIEW_COLUMN_SET, 0, | 217 0, SINGLE_VIEW_COLUMN_SET, 0, |
| 218 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_TITLE).top()); | 218 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_TITLE).top()); |
| 219 layout->AddView(title_label); | 219 layout->AddView(title_label); |
| 220 | 220 |
| 221 // Show credentials. | 221 // Show credentials. |
| 222 gfx::Insets dialog_insets = | 222 gfx::Insets dialog_insets = |
| 223 layout_provider->GetInsetsMetric(views::INSETS_PANEL); | 223 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS); |
| 224 BuildColumnSet(SINGLE_VIEW_COLUMN_SET_NO_PADDING, layout); | 224 BuildColumnSet(SINGLE_VIEW_COLUMN_SET_NO_PADDING, layout); |
| 225 layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET_NO_PADDING, 0, | 225 layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET_NO_PADDING, 0, |
| 226 dialog_insets.top()); | 226 dialog_insets.top()); |
| 227 layout->AddView(CreateCredentialsView( | 227 layout->AddView(CreateCredentialsView( |
| 228 controller_->GetLocalForms(), | 228 controller_->GetLocalForms(), |
| 229 this, | 229 this, |
| 230 GetProfileFromWebContents(web_contents_)->GetRequestContext())); | 230 GetProfileFromWebContents(web_contents_)->GetRequestContext())); |
| 231 layout->AddPaddingRow(0, dialog_insets.bottom()); | 231 layout->AddPaddingRow(0, dialog_insets.bottom()); |
| 232 } | 232 } |
| 233 | 233 |
| 234 AccountChooserPrompt* CreateAccountChooserPromptView( | 234 AccountChooserPrompt* CreateAccountChooserPromptView( |
| 235 PasswordDialogController* controller, content::WebContents* web_contents) { | 235 PasswordDialogController* controller, content::WebContents* web_contents) { |
| 236 return new AccountChooserDialogView(controller, web_contents); | 236 return new AccountChooserDialogView(controller, web_contents); |
| 237 } | 237 } |
| OLD | NEW |