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

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

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/decorated_textfield.h" 5 #include "chrome/browser/ui/views/autofill/decorated_textfield.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" 9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
10 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" 10 #include "chrome/browser/ui/views/autofill/tooltip_icon.h"
(...skipping 23 matching lines...) Expand all
34 : invalid_(false), 34 : invalid_(false),
35 editable_(true) { 35 editable_(true) {
36 UpdateBackground(); 36 UpdateBackground();
37 UpdateBorder(); 37 UpdateBorder();
38 38
39 set_placeholder_text(placeholder); 39 set_placeholder_text(placeholder);
40 SetText(default_value); 40 SetText(default_value);
41 set_controller(controller); 41 set_controller(controller);
42 42
43 SetEventTargeter( 43 SetEventTargeter(
44 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); 44 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
45 } 45 }
46 46
47 DecoratedTextfield::~DecoratedTextfield() {} 47 DecoratedTextfield::~DecoratedTextfield() {}
48 48
49 void DecoratedTextfield::SetInvalid(bool invalid) { 49 void DecoratedTextfield::SetInvalid(bool invalid) {
50 if (invalid_ == invalid) 50 if (invalid_ == invalid)
51 return; 51 return;
52 52
53 invalid_ = invalid; 53 invalid_ = invalid;
54 UpdateBorder(); 54 UpdateBorder();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void DecoratedTextfield::UpdateBackground() { 142 void DecoratedTextfield::UpdateBackground() {
143 if (editable_) 143 if (editable_)
144 UseDefaultBackgroundColor(); 144 UseDefaultBackgroundColor();
145 else 145 else
146 SetBackgroundColor(SK_ColorTRANSPARENT); 146 SetBackgroundColor(SK_ColorTRANSPARENT);
147 set_background( 147 set_background(
148 views::Background::CreateSolidBackground(GetBackgroundColor())); 148 views::Background::CreateSolidBackground(GetBackgroundColor()));
149 } 149 }
150 150
151 void DecoratedTextfield::UpdateBorder() { 151 void DecoratedTextfield::UpdateBorder() {
152 scoped_ptr<views::FocusableBorder> border(new views::FocusableBorder()); 152 std::unique_ptr<views::FocusableBorder> border(new views::FocusableBorder());
153 if (invalid_) 153 if (invalid_)
154 border->SetColor(kWarningColor); 154 border->SetColor(kWarningColor);
155 else if (!editable_) 155 else if (!editable_)
156 border->SetColor(SK_ColorTRANSPARENT); 156 border->SetColor(SK_ColorTRANSPARENT);
157 157
158 // Adjust the border insets to include the icon and its padding. 158 // Adjust the border insets to include the icon and its padding.
159 if (icon_view_ && icon_view_->visible()) { 159 if (icon_view_ && icon_view_->visible()) {
160 int w = icon_view_->GetPreferredSize().width() + 2 * kTextfieldIconPadding; 160 int w = icon_view_->GetPreferredSize().width() + 2 * kTextfieldIconPadding;
161 gfx::Insets insets = border->GetInsets(); 161 gfx::Insets insets = border->GetInsets();
162 int left = insets.left() + (base::i18n::IsRTL() ? w : 0); 162 int left = insets.left() + (base::i18n::IsRTL() ? w : 0);
163 int right = insets.right() + (base::i18n::IsRTL() ? 0 : w); 163 int right = insets.right() + (base::i18n::IsRTL() ? 0 : w);
164 border->SetInsets(insets.top(), left, insets.bottom(), right); 164 border->SetInsets(insets.top(), left, insets.bottom(), right);
165 } 165 }
166 166
167 SetBorder(std::move(border)); 167 SetBorder(std::move(border));
168 } 168 }
169 169
170 void DecoratedTextfield::IconChanged() { 170 void DecoratedTextfield::IconChanged() {
171 // Don't show the icon if nothing else is showing. 171 // Don't show the icon if nothing else is showing.
172 icon_view_->SetVisible(editable_ || !text().empty()); 172 icon_view_->SetVisible(editable_ || !text().empty());
173 UpdateBorder(); 173 UpdateBorder();
174 Layout(); 174 Layout();
175 } 175 }
176 176
177 } // namespace autofill 177 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/decorated_textfield.h ('k') | chrome/browser/ui/views/autofill/info_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698