| OLD | NEW |
| 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 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 bool read_only() const { return read_only_; } | 66 bool read_only() const { return read_only_; } |
| 67 void SetReadOnly(bool read_only); | 67 void SetReadOnly(bool read_only); |
| 68 | 68 |
| 69 // Sets the input type; displays only asterisks for TEXT_INPUT_TYPE_PASSWORD. | 69 // Sets the input type; displays only asterisks for TEXT_INPUT_TYPE_PASSWORD. |
| 70 void SetTextInputType(ui::TextInputType type); | 70 void SetTextInputType(ui::TextInputType type); |
| 71 | 71 |
| 72 // Sets the input flags so that the system input methods can turn on/off some | 72 // Sets the input flags so that the system input methods can turn on/off some |
| 73 // features. The flags is the bit map of ui::TextInputFlags. | 73 // features. The flags is the bit map of ui::TextInputFlags. |
| 74 void SetTextInputFlags(int flags); | 74 void SetTextInputFlags(int flags); |
| 75 | 75 |
| 76 // Gets the text currently displayed in the Textfield. | 76 // Gets the text for the Textfield. Call sites should take care to not reveal |
| 77 // the text for a password textfield. |
| 77 const base::string16& text() const { return model_->text(); } | 78 const base::string16& text() const { return model_->text(); } |
| 78 | 79 |
| 79 // Sets the text currently displayed in the Textfield. This doesn't | 80 // Sets the text currently displayed in the Textfield. This doesn't |
| 80 // change the cursor position if the current cursor is within the | 81 // change the cursor position if the current cursor is within the |
| 81 // new text's range, or moves the cursor to the end if the cursor is | 82 // new text's range, or moves the cursor to the end if the cursor is |
| 82 // out of the new text's range. | 83 // out of the new text's range. |
| 83 void SetText(const base::string16& new_text); | 84 void SetText(const base::string16& new_text); |
| 84 | 85 |
| 85 // Appends the given string to the previously-existing text in the field. | 86 // Appends the given string to the previously-existing text in the field. |
| 86 void AppendText(const base::string16& new_text); | 87 void AppendText(const base::string16& new_text); |
| 87 | 88 |
| 88 // Inserts |new_text| at the cursor position, replacing any selected text. | 89 // Inserts |new_text| at the cursor position, replacing any selected text. |
| 89 void InsertOrReplaceText(const base::string16& new_text); | 90 void InsertOrReplaceText(const base::string16& new_text); |
| 90 | 91 |
| 91 // Returns the text that is currently selected. | 92 // Returns the text that is currently selected. Call sites should take care to |
| 93 // not reveal the text for a password textfield. |
| 92 base::string16 GetSelectedText() const; | 94 base::string16 GetSelectedText() const; |
| 93 | 95 |
| 94 // Select the entire text range. If |reversed| is true, the range will end at | 96 // Select the entire text range. If |reversed| is true, the range will end at |
| 95 // the logical beginning of the text; this generally shows the leading portion | 97 // the logical beginning of the text; this generally shows the leading portion |
| 96 // of text that overflows its display area. | 98 // of text that overflows its display area. |
| 97 void SelectAll(bool reversed); | 99 void SelectAll(bool reversed); |
| 98 | 100 |
| 99 // A convenience method to select the word closest to |point|. | 101 // A convenience method to select the word closest to |point|. |
| 100 void SelectWordAt(const gfx::Point& point); | 102 void SelectWordAt(const gfx::Point& point); |
| 101 | 103 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 381 |
| 380 // Returns true if the current text input type allows access by the IME. | 382 // Returns true if the current text input type allows access by the IME. |
| 381 bool ImeEditingAllowed() const; | 383 bool ImeEditingAllowed() const; |
| 382 | 384 |
| 383 // Reveals the password character at |index| for a set duration. | 385 // Reveals the password character at |index| for a set duration. |
| 384 // If |index| is -1, the existing revealed character will be reset. | 386 // If |index| is -1, the existing revealed character will be reset. |
| 385 void RevealPasswordChar(int index); | 387 void RevealPasswordChar(int index); |
| 386 | 388 |
| 387 void CreateTouchSelectionControllerAndNotifyIt(); | 389 void CreateTouchSelectionControllerAndNotifyIt(); |
| 388 | 390 |
| 389 // Updates the selection clipboard to any non-empty text selection. | 391 // Updates the selection clipboard to any non-empty text selection for a non- |
| 392 // password textfield. |
| 390 void UpdateSelectionClipboard() const; | 393 void UpdateSelectionClipboard() const; |
| 391 | 394 |
| 392 // Pastes the selection clipboard for the specified mouse event. | 395 // Pastes the selection clipboard for the specified mouse event. |
| 393 void PasteSelectionClipboard(const ui::MouseEvent& event); | 396 void PasteSelectionClipboard(const ui::MouseEvent& event); |
| 394 | 397 |
| 395 // The text model. | 398 // The text model. |
| 396 std::unique_ptr<TextfieldModel> model_; | 399 std::unique_ptr<TextfieldModel> model_; |
| 397 | 400 |
| 398 // This is the current listener for events from this Textfield. | 401 // This is the current listener for events from this Textfield. |
| 399 TextfieldController* controller_; | 402 TextfieldController* controller_; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 491 |
| 489 // Used to bind callback functions to this object. | 492 // Used to bind callback functions to this object. |
| 490 base::WeakPtrFactory<Textfield> weak_ptr_factory_; | 493 base::WeakPtrFactory<Textfield> weak_ptr_factory_; |
| 491 | 494 |
| 492 DISALLOW_COPY_AND_ASSIGN(Textfield); | 495 DISALLOW_COPY_AND_ASSIGN(Textfield); |
| 493 }; | 496 }; |
| 494 | 497 |
| 495 } // namespace views | 498 } // namespace views |
| 496 | 499 |
| 497 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 500 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| OLD | NEW |