| 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 CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 12 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 13 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 14 #include "ui/base/range/range.h" | |
| 15 #include "ui/base/window_open_disposition.h" | 14 #include "ui/base/window_open_disposition.h" |
| 15 #include "ui/gfx/range/range.h" |
| 16 #include "ui/views/controls/textfield/textfield.h" | 16 #include "ui/views/controls/textfield/textfield.h" |
| 17 #include "ui/views/controls/textfield/textfield_controller.h" | 17 #include "ui/views/controls/textfield/textfield_controller.h" |
| 18 | 18 |
| 19 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
| 20 #include "chromeos/ime/input_method_manager.h" | 20 #include "chromeos/ime/input_method_manager.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 class LocationBarView; | 23 class LocationBarView; |
| 24 class OmniboxPopupView; | 24 class OmniboxPopupView; |
| 25 class Profile; | 25 class Profile; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 // Return the number of characers in the current buffer. | 141 // Return the number of characers in the current buffer. |
| 142 virtual int GetOmniboxTextLength() const OVERRIDE; | 142 virtual int GetOmniboxTextLength() const OVERRIDE; |
| 143 | 143 |
| 144 // Try to parse the current text as a URL and colorize the components. | 144 // Try to parse the current text as a URL and colorize the components. |
| 145 virtual void EmphasizeURLComponents() OVERRIDE; | 145 virtual void EmphasizeURLComponents() OVERRIDE; |
| 146 | 146 |
| 147 // Update the field with |text| and set the selection. | 147 // Update the field with |text| and set the selection. |
| 148 void SetTextAndSelectedRange(const string16& text, | 148 void SetTextAndSelectedRange(const string16& text, |
| 149 const ui::Range& range); | 149 const gfx::Range& range); |
| 150 | 150 |
| 151 // Returns the selected text. | 151 // Returns the selected text. |
| 152 string16 GetSelectedText() const; | 152 string16 GetSelectedText() const; |
| 153 | 153 |
| 154 // Copy the URL instead of the text in the textfield into clipboard. | 154 // Copy the URL instead of the text in the textfield into clipboard. |
| 155 void CopyURL(); | 155 void CopyURL(); |
| 156 | 156 |
| 157 // Paste text from the clipboard into the omnibox. | 157 // Paste text from the clipboard into the omnibox. |
| 158 // Textfields implementation of Paste() pastes the contents of the clipboard | 158 // Textfields implementation of Paste() pastes the contents of the clipboard |
| 159 // as is. We want to strip whitespace and other things (see GetClipboardText() | 159 // as is. We want to strip whitespace and other things (see GetClipboardText() |
| 160 // for details). | 160 // for details). |
| 161 // It is assumed this is invoked after a call to OnBeforePossibleChange() and | 161 // It is assumed this is invoked after a call to OnBeforePossibleChange() and |
| 162 // that after invoking this OnAfterPossibleChange() is invoked. | 162 // that after invoking this OnAfterPossibleChange() is invoked. |
| 163 void OnPaste(); | 163 void OnPaste(); |
| 164 | 164 |
| 165 // When true, the location bar view is read only and also is has a slightly | 165 // When true, the location bar view is read only and also is has a slightly |
| 166 // different presentation (smaller font size). This is used for popups. | 166 // different presentation (smaller font size). This is used for popups. |
| 167 bool popup_window_mode_; | 167 bool popup_window_mode_; |
| 168 | 168 |
| 169 scoped_ptr<OmniboxPopupView> popup_view_; | 169 scoped_ptr<OmniboxPopupView> popup_view_; |
| 170 | 170 |
| 171 ToolbarModel::SecurityLevel security_level_; | 171 ToolbarModel::SecurityLevel security_level_; |
| 172 | 172 |
| 173 // Selection persisted across temporary text changes, like popup suggestions. | 173 // Selection persisted across temporary text changes, like popup suggestions. |
| 174 ui::Range saved_temporary_selection_; | 174 gfx::Range saved_temporary_selection_; |
| 175 | 175 |
| 176 // Tracking state before and after a possible change. | 176 // Tracking state before and after a possible change. |
| 177 string16 text_before_change_; | 177 string16 text_before_change_; |
| 178 ui::Range sel_before_change_; | 178 gfx::Range sel_before_change_; |
| 179 bool ime_composing_before_change_; | 179 bool ime_composing_before_change_; |
| 180 | 180 |
| 181 // Was the delete key pressed with an empty selection at the end of the edit? | 181 // Was the delete key pressed with an empty selection at the end of the edit? |
| 182 bool delete_at_end_pressed_; | 182 bool delete_at_end_pressed_; |
| 183 LocationBarView* location_bar_view_; | 183 LocationBarView* location_bar_view_; |
| 184 | 184 |
| 185 // True if the IME candidate window is open. When this is true, we want to | 185 // True if the IME candidate window is open. When this is true, we want to |
| 186 // avoid showing the popup. So far, the candidate window is detected only | 186 // avoid showing the popup. So far, the candidate window is detected only |
| 187 // on Chrome OS. | 187 // on Chrome OS. |
| 188 bool ime_candidate_window_open_; | 188 bool ime_candidate_window_open_; |
| 189 | 189 |
| 190 // Should we select all the text when we see the mouse button get released? | 190 // Should we select all the text when we see the mouse button get released? |
| 191 // We select in response to a click that focuses the omnibox, but we defer | 191 // We select in response to a click that focuses the omnibox, but we defer |
| 192 // until release, setting this variable back to false if we saw a drag, to | 192 // until release, setting this variable back to false if we saw a drag, to |
| 193 // allow the user to select just a portion of the text. | 193 // allow the user to select just a portion of the text. |
| 194 bool select_all_on_mouse_release_; | 194 bool select_all_on_mouse_release_; |
| 195 | 195 |
| 196 // Indicates if we want to select all text in the omnibox when we get a | 196 // Indicates if we want to select all text in the omnibox when we get a |
| 197 // GESTURE_TAP. We want to select all only when the textfield is not in focus | 197 // GESTURE_TAP. We want to select all only when the textfield is not in focus |
| 198 // and gets a tap. So we use this variable to remember focus state before tap. | 198 // and gets a tap. So we use this variable to remember focus state before tap. |
| 199 bool select_all_on_gesture_tap_; | 199 bool select_all_on_gesture_tap_; |
| 200 | 200 |
| 201 DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews); | 201 DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews); |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 204 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
| OLD | NEW |