Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: chrome/browser/ui/views/login_view.cc

Issue 1466473003: Do not show untrustworthy strings in the basic auth dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle Mac and Android, and respond to comments. Re-add proxy string. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/login_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/login_view.h" 5 #include "chrome/browser/ui/views/login_view.h"
6 6
7 #include "chrome/grit/generated_resources.h" 7 #include "chrome/grit/generated_resources.h"
8 #include "ui/base/l10n/l10n_util.h" 8 #include "ui/base/l10n/l10n_util.h"
9 #include "ui/views/controls/label.h" 9 #include "ui/views/controls/label.h"
10 #include "ui/views/controls/textfield/textfield.h" 10 #include "ui/views/controls/textfield/textfield.h"
11 #include "ui/views/layout/grid_layout.h" 11 #include "ui/views/layout/grid_layout.h"
12 #include "ui/views/layout/layout_constants.h" 12 #include "ui/views/layout/layout_constants.h"
13 13
14 static const int kMessageWidth = 320; 14 static const int kMessageWidth = 320;
15 static const int kTextfieldStackHorizontalSpacing = 30; 15 static const int kTextfieldStackHorizontalSpacing = 30;
16 16
17 using password_manager::LoginModel; 17 using password_manager::LoginModel;
18 using views::GridLayout; 18 using views::GridLayout;
19 19
20 /////////////////////////////////////////////////////////////////////////////// 20 ///////////////////////////////////////////////////////////////////////////////
21 // LoginView, public: 21 // LoginView, public:
22 22
23 LoginView::LoginView(const base::string16& explanation, 23 LoginView::LoginView(const base::string16& authority,
24 const base::string16& explanation,
24 LoginHandler::LoginModelData* login_model_data) 25 LoginHandler::LoginModelData* login_model_data)
25 : username_field_(new views::Textfield()), 26 : username_field_(new views::Textfield()),
26 password_field_(new views::Textfield()), 27 password_field_(new views::Textfield()),
27 username_label_(new views::Label( 28 username_label_(new views::Label(
28 l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_USERNAME_FIELD))), 29 l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_USERNAME_FIELD))),
29 password_label_(new views::Label( 30 password_label_(new views::Label(
30 l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_PASSWORD_FIELD))), 31 l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_PASSWORD_FIELD))),
32 authority_label_(new views::Label(authority)),
31 message_label_(new views::Label(explanation)), 33 message_label_(new views::Label(explanation)),
meacer 2015/11/20 01:36:14 Looks like this leaks message_label_ if explanatio
palmer 2015/11/20 02:23:31 Done.
32 login_model_(login_model_data ? login_model_data->model : nullptr) { 34 login_model_(login_model_data ? login_model_data->model : nullptr) {
33 password_field_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 35 password_field_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
36
37 authority_label_->SetMultiLine(true);
38 authority_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
39 authority_label_->SetAllowCharacterBreak(true);
40
34 message_label_->SetMultiLine(true); 41 message_label_->SetMultiLine(true);
35 message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 42 message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
36 message_label_->SetAllowCharacterBreak(true); 43 message_label_->SetAllowCharacterBreak(true);
37 44
38 // Initialize the Grid Layout Manager used for this dialog box. 45 // Initialize the Grid Layout Manager used for this dialog box.
39 GridLayout* layout = GridLayout::CreatePanel(this); 46 GridLayout* layout = GridLayout::CreatePanel(this);
40 SetLayoutManager(layout); 47 SetLayoutManager(layout);
41 48
42 // Add the column set for the information message at the top of the dialog 49 // Add the column set for the information message at the top of the dialog
43 // box. 50 // box.
44 const int single_column_view_set_id = 0; 51 const int single_column_view_set_id = 0;
45 views::ColumnSet* column_set = 52 views::ColumnSet* column_set =
46 layout->AddColumnSet(single_column_view_set_id); 53 layout->AddColumnSet(single_column_view_set_id);
47 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 54 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
48 GridLayout::FIXED, kMessageWidth, 0); 55 GridLayout::FIXED, kMessageWidth, 0);
49 56
50 // Add the column set for the user name and password fields and labels. 57 // Add the column set for the user name and password fields and labels.
51 const int labels_column_set_id = 1; 58 const int labels_column_set_id = 1;
52 column_set = layout->AddColumnSet(labels_column_set_id); 59 column_set = layout->AddColumnSet(labels_column_set_id);
53 column_set->AddPaddingColumn(0, kTextfieldStackHorizontalSpacing); 60 column_set->AddPaddingColumn(0, kTextfieldStackHorizontalSpacing);
54 column_set->AddColumn(views::kControlLabelGridAlignment, GridLayout::CENTER, 61 column_set->AddColumn(views::kControlLabelGridAlignment, GridLayout::CENTER,
55 0, GridLayout::USE_PREF, 0, 0); 62 0, GridLayout::USE_PREF, 0, 0);
56 column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 63 column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
57 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, 64 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
58 GridLayout::USE_PREF, 0, 0); 65 GridLayout::USE_PREF, 0, 0);
59 column_set->AddPaddingColumn(0, kTextfieldStackHorizontalSpacing); 66 column_set->AddPaddingColumn(0, kTextfieldStackHorizontalSpacing);
60 67
61 layout->StartRow(0, single_column_view_set_id); 68 layout->StartRow(0, single_column_view_set_id);
62 layout->AddView(message_label_); 69 layout->AddView(authority_label_);
70 if (!explanation.empty()) {
71 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
72 layout->StartRow(0, single_column_view_set_id);
73 layout->AddView(message_label_);
74 }
63 75
64 layout->AddPaddingRow(0, views::kUnrelatedControlLargeVerticalSpacing); 76 layout->AddPaddingRow(0, views::kUnrelatedControlLargeVerticalSpacing);
65 77
66 layout->StartRow(0, labels_column_set_id); 78 layout->StartRow(0, labels_column_set_id);
67 layout->AddView(username_label_); 79 layout->AddView(username_label_);
68 layout->AddView(username_field_); 80 layout->AddView(username_field_);
69 81
70 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 82 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
71 83
72 layout->StartRow(0, labels_column_set_id); 84 layout->StartRow(0, labels_column_set_id);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 125
114 void LoginView::OnLoginModelDestroying() { 126 void LoginView::OnLoginModelDestroying() {
115 login_model_->RemoveObserver(this); 127 login_model_->RemoveObserver(this);
116 login_model_ = NULL; 128 login_model_ = NULL;
117 } 129 }
118 130
119 const char* LoginView::GetClassName() const { 131 const char* LoginView::GetClassName() const {
120 return "LoginView"; 132 return "LoginView";
121 } 133 }
122 134
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/login_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698