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

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: Rebase. 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::kExplanatoryTextColor);
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 21 matching lines...) Expand all
83 default_style.color = kExplanatoryTextColor; 79 default_style.color = kExplanatoryTextColor;
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 = kLinkColor;
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 kExplanatoryTextBackgroundColor));
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/password_generation_popup_view_cocoa.mm ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698