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

Side by Side Diff: ui/views/controls/textfield/textfield_views_model.cc

Issue 9117012: Rename visual style "password" to "obscured" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 8 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/textfield/textfield_views_model.h" 5 #include "ui/views/controls/textfield/textfield_views_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 ///////////////////////////////////////////////////////////////// 275 /////////////////////////////////////////////////////////////////
276 // TextfieldViewsModel: public 276 // TextfieldViewsModel: public
277 277
278 TextfieldViewsModel::Delegate::~Delegate() { 278 TextfieldViewsModel::Delegate::~Delegate() {
279 } 279 }
280 280
281 TextfieldViewsModel::TextfieldViewsModel(Delegate* delegate) 281 TextfieldViewsModel::TextfieldViewsModel(Delegate* delegate)
282 : delegate_(delegate), 282 : delegate_(delegate),
283 render_text_(gfx::RenderText::CreateRenderText()), 283 render_text_(gfx::RenderText::CreateRenderText()),
284 is_password_(false), 284 is_obscured_(false),
285 current_edit_(edit_history_.end()) { 285 current_edit_(edit_history_.end()) {
286 } 286 }
287 287
288 TextfieldViewsModel::~TextfieldViewsModel() { 288 TextfieldViewsModel::~TextfieldViewsModel() {
289 ClearEditHistory(); 289 ClearEditHistory();
290 ClearComposition(); 290 ClearComposition();
291 } 291 }
292 292
293 const string16& TextfieldViewsModel::GetText() const { 293 const string16& TextfieldViewsModel::GetText() const {
294 return render_text_->text(); 294 return render_text_->text();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 633
634 bool TextfieldViewsModel::HasCompositionText() const { 634 bool TextfieldViewsModel::HasCompositionText() const {
635 return !render_text_->GetCompositionRange().is_empty(); 635 return !render_text_->GetCompositionRange().is_empty();
636 } 636 }
637 637
638 ///////////////////////////////////////////////////////////////// 638 /////////////////////////////////////////////////////////////////
639 // TextfieldViewsModel: private 639 // TextfieldViewsModel: private
640 640
641 string16 TextfieldViewsModel::GetVisibleText(size_t begin, size_t end) const { 641 string16 TextfieldViewsModel::GetVisibleText(size_t begin, size_t end) const {
642 DCHECK(end >= begin); 642 DCHECK(end >= begin);
643 if (is_password_) 643 if (is_obscured_)
644 return string16(end - begin, '*'); 644 return string16(end - begin, '*');
645 return GetText().substr(begin, end - begin); 645 return GetText().substr(begin, end - begin);
646 } 646 }
647 647
648 void TextfieldViewsModel::InsertTextInternal(const string16& text, 648 void TextfieldViewsModel::InsertTextInternal(const string16& text,
649 bool mergeable) { 649 bool mergeable) {
650 if (HasCompositionText()) { 650 if (HasCompositionText()) {
651 CancelCompositionText(); 651 CancelCompositionText();
652 ExecuteAndRecordInsert(text, mergeable); 652 ExecuteAndRecordInsert(text, mergeable);
653 } else if (HasSelection()) { 653 } else if (HasSelection()) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 if (delete_from != delete_to) 786 if (delete_from != delete_to)
787 render_text_->SetText(text.erase(delete_from, delete_to - delete_from)); 787 render_text_->SetText(text.erase(delete_from, delete_to - delete_from));
788 if (!new_text.empty()) 788 if (!new_text.empty())
789 render_text_->SetText(text.insert(new_text_insert_at, new_text)); 789 render_text_->SetText(text.insert(new_text_insert_at, new_text));
790 render_text_->SetCursorPosition(new_cursor_pos); 790 render_text_->SetCursorPosition(new_cursor_pos);
791 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't). 791 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't).
792 // This looks fine feature and we may want to do the same. 792 // This looks fine feature and we may want to do the same.
793 } 793 }
794 794
795 } // namespace views 795 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield_views_model.h ('k') | ui/views/controls/textfield/textfield_views_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698