| OLD | NEW |
| 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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 PasswordGenerationPopupViewViews::PasswordGenerationPopupViewViews( | 34 PasswordGenerationPopupViewViews::PasswordGenerationPopupViewViews( |
| 35 PasswordGenerationPopupController* controller, | 35 PasswordGenerationPopupController* controller, |
| 36 views::Widget* observing_widget) | 36 views::Widget* observing_widget) |
| 37 : AutofillPopupBaseView(controller, observing_widget), | 37 : AutofillPopupBaseView(controller, observing_widget), |
| 38 controller_(controller) { | 38 controller_(controller) { |
| 39 password_label_ = new views::Label(controller->password()); | 39 password_label_ = new views::Label(controller->password()); |
| 40 password_label_->SetBoundsRect(controller->password_bounds()); | 40 password_label_->SetBoundsRect(controller->password_bounds()); |
| 41 password_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 41 password_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 42 password_label_->set_clip_insets(gfx::Insets( | 42 password_label_->set_clip_insets(gfx::Insets( |
| 43 kPasswordVerticalInset, 0, kPasswordVerticalInset, 0)); | 43 kPasswordVerticalInset, 0, kPasswordVerticalInset, 0)); |
| 44 password_label_->set_border(views::Border::CreateEmptyBorder( | 44 password_label_->SetBorder(views::Border::CreateEmptyBorder( |
| 45 0, controller_->kHorizontalPadding, 0, controller_->kHorizontalPadding)); | 45 0, controller_->kHorizontalPadding, 0, controller_->kHorizontalPadding)); |
| 46 AddChildView(password_label_); | 46 AddChildView(password_label_); |
| 47 | 47 |
| 48 base::string16 help_text = controller->HelpText(); | 48 base::string16 help_text = controller->HelpText(); |
| 49 base::string16 learn_more_link_text = controller->LearnMoreLink(); | 49 base::string16 learn_more_link_text = controller->LearnMoreLink(); |
| 50 views::StyledLabel* help_label = | 50 views::StyledLabel* help_label = |
| 51 new views::StyledLabel(help_text + learn_more_link_text, this); | 51 new views::StyledLabel(help_text + learn_more_link_text, this); |
| 52 views::StyledLabel::RangeStyleInfo default_style; | 52 views::StyledLabel::RangeStyleInfo default_style; |
| 53 default_style.color = kExplanatoryTextColor; | 53 default_style.color = kExplanatoryTextColor; |
| 54 help_label->SetDefaultStyle(default_style); | 54 help_label->SetDefaultStyle(default_style); |
| 55 help_label->AddStyleRange( | 55 help_label->AddStyleRange( |
| 56 gfx::Range(help_text.size(), | 56 gfx::Range(help_text.size(), |
| 57 help_text.size() + learn_more_link_text.size()), | 57 help_text.size() + learn_more_link_text.size()), |
| 58 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 58 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
| 59 help_label->SetBoundsRect(controller->help_bounds()); | 59 help_label->SetBoundsRect(controller->help_bounds()); |
| 60 help_label->set_background( | 60 help_label->set_background( |
| 61 views::Background::CreateSolidBackground(kExplanatoryTextBackground)); | 61 views::Background::CreateSolidBackground(kExplanatoryTextBackground)); |
| 62 help_label->set_border(views::Border::CreateEmptyBorder( | 62 help_label->SetBorder(views::Border::CreateEmptyBorder( |
| 63 controller_->kHelpVerticalPadding - kHelpVerticalOffset, | 63 controller_->kHelpVerticalPadding - kHelpVerticalOffset, |
| 64 controller_->kHorizontalPadding, | 64 controller_->kHorizontalPadding, |
| 65 0, | 65 0, |
| 66 controller_->kHorizontalPadding)); | 66 controller_->kHorizontalPadding)); |
| 67 AddChildView(help_label); | 67 AddChildView(help_label); |
| 68 | 68 |
| 69 set_background(views::Background::CreateSolidBackground(kPopupBackground)); | 69 set_background(views::Background::CreateSolidBackground(kPopupBackground)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 PasswordGenerationPopupViewViews::~PasswordGenerationPopupViewViews() {} | 72 PasswordGenerationPopupViewViews::~PasswordGenerationPopupViewViews() {} |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 // If the top level widget can't be found, cancel the popup since we can't | 120 // If the top level widget can't be found, cancel the popup since we can't |
| 121 // fully set it up. | 121 // fully set it up. |
| 122 if (!observing_widget) | 122 if (!observing_widget) |
| 123 return NULL; | 123 return NULL; |
| 124 | 124 |
| 125 return new PasswordGenerationPopupViewViews(controller, observing_widget); | 125 return new PasswordGenerationPopupViewViews(controller, observing_widget); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace autofill | 128 } // namespace autofill |
| OLD | NEW |