| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" | |
| 10 #include "ui/gfx/canvas.h" | |
| 11 #include "ui/gfx/color_palette.h" | |
| 12 #include "ui/views/background.h" | |
| 13 #include "ui/views/controls/button/label_button.h" | |
| 14 #include "ui/views/controls/focusable_border.h" | |
| 15 #include "ui/views/controls/textfield/textfield_controller.h" | |
| 16 #include "ui/views/view_targeter.h" | |
| 17 | |
| 18 namespace autofill { | |
| 19 | |
| 20 // static | |
| 21 const char DecoratedTextfield::kViewClassName[] = "autofill/DecoratedTextfield"; | |
| 22 | |
| 23 DecoratedTextfield::DecoratedTextfield( | |
| 24 const base::string16& default_value, | |
| 25 const base::string16& placeholder, | |
| 26 views::TextfieldController* controller) | |
| 27 : invalid_(false) { | |
| 28 UpdateBorder(); | |
| 29 | |
| 30 set_placeholder_text(placeholder); | |
| 31 SetText(default_value); | |
| 32 set_controller(controller); | |
| 33 } | |
| 34 | |
| 35 DecoratedTextfield::~DecoratedTextfield() {} | |
| 36 | |
| 37 void DecoratedTextfield::SetInvalid(bool invalid) { | |
| 38 if (invalid_ == invalid) | |
| 39 return; | |
| 40 | |
| 41 invalid_ = invalid; | |
| 42 UpdateBorder(); | |
| 43 SchedulePaint(); | |
| 44 } | |
| 45 | |
| 46 const char* DecoratedTextfield::GetClassName() const { | |
| 47 return kViewClassName; | |
| 48 } | |
| 49 | |
| 50 void DecoratedTextfield::UpdateBorder() { | |
| 51 std::unique_ptr<views::FocusableBorder> border(new views::FocusableBorder()); | |
| 52 if (invalid_) | |
| 53 border->SetColor(gfx::kGoogleRed700); | |
| 54 | |
| 55 SetBorder(std::move(border)); | |
| 56 } | |
| 57 | |
| 58 } // namespace autofill | |
| OLD | NEW |