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

Side by Side Diff: chrome/browser/ui/views/autofill/password_generation_popup_view_views.cc

Issue 267183002: Password manager: Implement password generation UI for Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More implementation Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/autofill/password_generation_popup_view_views. h" 5 #include "chrome/browser/ui/views/autofill/password_generation_popup_view_views. h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h" 8 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/background.h" 10 #include "ui/views/background.h"
11 #include "ui/views/border.h" 11 #include "ui/views/border.h"
12 #include "ui/views/controls/label.h" 12 #include "ui/views/controls/label.h"
13 #include "ui/views/controls/styled_label.h" 13 #include "ui/views/controls/styled_label.h"
14 #include "ui/views/layout/box_layout.h" 14 #include "ui/views/layout/box_layout.h"
15 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
16 16
17 namespace autofill { 17 namespace autofill {
18 18
19 namespace { 19 namespace {
20 20
21 const SkColor kExplanatoryTextBackground = SkColorSetRGB(0xF5, 0xF5, 0xF5);
22 const SkColor kExplanatoryTextColor = SkColorSetRGB(0x66, 0x66, 0x66);
23 const SkColor kDividerColor = SkColorSetRGB(0xE9, 0xE9, 0xE9);
24 const SkColor kLinkColor = SkColorSetRGB(0x55, 0x59, 0xFE);
25
26 // The amount of whitespace that is present when there is no padding. Used 21 // The amount of whitespace that is present when there is no padding. Used
27 // to get the proper spacing in the help section. 22 // to get the proper spacing in the help section.
28 const int kHelpVerticalOffset = 3; 23 const int kHelpVerticalOffset = 3;
29 24
30 // Class that shows the password and the suggestion side-by-side. 25 // Class that shows the password and the suggestion side-by-side.
31 class PasswordRow : public views::View { 26 class PasswordRow : public views::View {
32 public: 27 public:
33 PasswordRow(const base::string16& password, 28 PasswordRow(const base::string16& password,
34 const base::string16& suggestion, 29 const base::string16& suggestion,
35 const gfx::FontList& font_list, 30 const gfx::FontList& font_list,
36 int horizontal_border) { 31 int horizontal_border) {
37 set_clip_insets(gfx::Insets( 32 set_clip_insets(gfx::Insets(
38 PasswordGenerationPopupView::kPasswordVerticalInset, 0, 33 PasswordGenerationPopupView::kPasswordVerticalInset, 0,
39 PasswordGenerationPopupView::kPasswordVerticalInset, 0)); 34 PasswordGenerationPopupView::kPasswordVerticalInset, 0));
40 views::BoxLayout* box_layout = new views::BoxLayout( 35 views::BoxLayout* box_layout = new views::BoxLayout(
41 views::BoxLayout::kHorizontal, horizontal_border, 0, 0); 36 views::BoxLayout::kHorizontal, horizontal_border, 0, 0);
42 box_layout->set_spread_blank_space(true); 37 box_layout->set_spread_blank_space(true);
43 SetLayoutManager(box_layout); 38 SetLayoutManager(box_layout);
44 39
45 password_label_ = new views::Label(password, font_list); 40 password_label_ = new views::Label(password, font_list);
46 password_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 41 password_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
47 AddChildView(password_label_); 42 AddChildView(password_label_);
48 43
49 suggestion_label_ = new views::Label(suggestion, font_list); 44 suggestion_label_ = new views::Label(suggestion, font_list);
50 suggestion_label_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); 45 suggestion_label_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
51 suggestion_label_->SetEnabledColor(kExplanatoryTextColor); 46 suggestion_label_->SetEnabledColor(
47 PasswordGenerationPopupView::GetExplanatoryTextColor());
52 AddChildView(suggestion_label_); 48 AddChildView(suggestion_label_);
53 } 49 }
54 virtual ~PasswordRow() {} 50 virtual ~PasswordRow() {}
55 51
56 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE { 52 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE {
57 // Have parent do event handling. 53 // Have parent do event handling.
58 return false; 54 return false;
59 } 55 }
60 56
61 private: 57 private:
(...skipping 11 matching lines...) Expand all
73 views::Widget* observing_widget) 69 views::Widget* observing_widget)
74 : AutofillPopupBaseView(controller, observing_widget), 70 : AutofillPopupBaseView(controller, observing_widget),
75 password_view_(NULL), 71 password_view_(NULL),
76 controller_(controller) { 72 controller_(controller) {
77 if (controller_->display_password()) 73 if (controller_->display_password())
78 CreatePasswordView(); 74 CreatePasswordView();
79 75
80 help_label_ = new views::StyledLabel(controller_->HelpText(), this); 76 help_label_ = new views::StyledLabel(controller_->HelpText(), this);
81 help_label_->SetBaseFontList(controller_->font_list()); 77 help_label_->SetBaseFontList(controller_->font_list());
82 views::StyledLabel::RangeStyleInfo default_style; 78 views::StyledLabel::RangeStyleInfo default_style;
83 default_style.color = kExplanatoryTextColor; 79 default_style.color = GetExplanatoryTextColor();
84 help_label_->SetDefaultStyle(default_style); 80 help_label_->SetDefaultStyle(default_style);
85 81
86 views::StyledLabel::RangeStyleInfo link_style = 82 views::StyledLabel::RangeStyleInfo link_style =
87 views::StyledLabel::RangeStyleInfo::CreateForLink(); 83 views::StyledLabel::RangeStyleInfo::CreateForLink();
88 link_style.color = kLinkColor; 84 link_style.color = PasswordGenerationPopupView::GetLinkColor();
89 help_label_->AddStyleRange(controller_->HelpTextLinkRange(), link_style); 85 help_label_->AddStyleRange(controller_->HelpTextLinkRange(), link_style);
90 86
91 help_label_->SetBoundsRect(controller_->help_bounds()); 87 help_label_->SetBoundsRect(controller_->help_bounds());
92 help_label_->set_background( 88 help_label_->set_background(
93 views::Background::CreateSolidBackground(kExplanatoryTextBackground)); 89 views::Background::CreateSolidBackground(
90 PasswordGenerationPopupView::GetExplanatoryTextBackgroundColor()));
94 help_label_->SetBorder(views::Border::CreateEmptyBorder( 91 help_label_->SetBorder(views::Border::CreateEmptyBorder(
95 controller_->kHelpVerticalPadding - kHelpVerticalOffset, 92 controller_->kHelpVerticalPadding - kHelpVerticalOffset,
96 controller_->kHorizontalPadding, 93 controller_->kHorizontalPadding,
97 0, 94 0,
98 controller_->kHorizontalPadding)); 95 controller_->kHorizontalPadding));
99 AddChildView(help_label_); 96 AddChildView(help_label_);
100 97
101 set_background(views::Background::CreateSolidBackground(kPopupBackground)); 98 set_background(views::Background::CreateSolidBackground(kPopupBackground));
102 } 99 }
103 100
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 void PasswordGenerationPopupViewViews::OnPaint(gfx::Canvas* canvas) { 153 void PasswordGenerationPopupViewViews::OnPaint(gfx::Canvas* canvas) {
157 if (!controller_) 154 if (!controller_)
158 return; 155 return;
159 156
160 // Draw border and background. 157 // Draw border and background.
161 views::View::OnPaint(canvas); 158 views::View::OnPaint(canvas);
162 159
163 // Divider line needs to be drawn after OnPaint() otherwise the background 160 // Divider line needs to be drawn after OnPaint() otherwise the background
164 // will overwrite the divider. 161 // will overwrite the divider.
165 if (password_view_) 162 if (password_view_)
166 canvas->FillRect(controller_->divider_bounds(), kDividerColor); 163 canvas->FillRect(controller_->divider_bounds(), GetDividerColor());
167 } 164 }
168 165
169 void PasswordGenerationPopupViewViews::StyledLabelLinkClicked( 166 void PasswordGenerationPopupViewViews::StyledLabelLinkClicked(
170 const gfx::Range& range, int event_flags) { 167 const gfx::Range& range, int event_flags) {
171 controller_->OnSavedPasswordsLinkClicked(); 168 controller_->OnSavedPasswordsLinkClicked();
172 } 169 }
173 170
174 PasswordGenerationPopupView* PasswordGenerationPopupView::Create( 171 PasswordGenerationPopupView* PasswordGenerationPopupView::Create(
175 PasswordGenerationPopupController* controller) { 172 PasswordGenerationPopupController* controller) {
176 views::Widget* observing_widget = 173 views::Widget* observing_widget =
177 views::Widget::GetTopLevelWidgetForNativeView( 174 views::Widget::GetTopLevelWidgetForNativeView(
178 controller->container_view()); 175 controller->container_view());
179 176
180 // If the top level widget can't be found, cancel the popup since we can't 177 // If the top level widget can't be found, cancel the popup since we can't
181 // fully set it up. 178 // fully set it up.
182 if (!observing_widget) 179 if (!observing_widget)
183 return NULL; 180 return NULL;
184 181
185 return new PasswordGenerationPopupViewViews(controller, observing_widget); 182 return new PasswordGenerationPopupViewViews(controller, observing_widget);
186 } 183 }
187 184
188 } // namespace autofill 185 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698