| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/autocomplete/autocomplete.h" | 9 #include "chrome/browser/autocomplete/autocomplete.h" |
| 10 #include "chrome/common/notification_observer.h" | 10 #include "chrome/common/notification_observer.h" |
| 11 #include "chrome/common/notification_registrar.h" | 11 #include "chrome/common/notification_registrar.h" |
| 12 #include "chrome/common/page_transition_types.h" | 12 #include "chrome/common/page_transition_types.h" |
| 13 #include "gfx/native_widget_types.h" | 13 #include "gfx/native_widget_types.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "webkit/glue/window_open_disposition.h" | 15 #include "webkit/glue/window_open_disposition.h" |
| 16 | 16 |
| 17 class AutocompletePopupModel; | 17 class AutocompletePopupModel; |
| 18 class Profile; | 18 class Profile; |
| 19 class SkBitmap; | 19 class SkBitmap; |
| 20 | 20 |
| 21 class AutocompleteEditController; | 21 class AutocompleteEditController; |
| 22 class AutocompleteEditModel; | 22 class AutocompleteEditModel; |
| 23 class AutocompleteEditView; | 23 class AutocompleteEditView; |
| 24 | 24 |
| 25 namespace gfx { |
| 26 class Rect; |
| 27 } |
| 28 |
| 25 // TODO(pkasting): The names and contents of the classes in | 29 // TODO(pkasting): The names and contents of the classes in |
| 26 // this file are temporary. I am in hack-and-slash mode right now. | 30 // this file are temporary. I am in hack-and-slash mode right now. |
| 27 // http://code.google.com/p/chromium/issues/detail?id=6772 | 31 // http://code.google.com/p/chromium/issues/detail?id=6772 |
| 28 | 32 |
| 29 // Embedders of an AutocompleteEdit widget must implement this class. | 33 // Embedders of an AutocompleteEdit widget must implement this class. |
| 30 class AutocompleteEditController { | 34 class AutocompleteEditController { |
| 31 public: | 35 public: |
| 32 #if defined(TOOLKIT_VIEWS) | 36 #if defined(TOOLKIT_VIEWS) |
| 33 // Sent when the autocomplete popup is about to close. | 37 // Sent when the autocomplete popup is about to close. |
| 34 virtual void OnAutocompleteWillClosePopup() = 0; | 38 virtual void OnAutocompleteWillClosePopup() = 0; |
| 35 | 39 |
| 36 // Sent when the edit is losing focus. |view_gaining_focus| is the view | 40 // Sent when the edit is losing focus. |view_gaining_focus| is the view |
| 37 // gaining focus and may be null. | 41 // gaining focus and may be null. |
| 38 virtual void OnAutocompleteLosingFocus( | 42 virtual void OnAutocompleteLosingFocus( |
| 39 gfx::NativeView view_gaining_focus) = 0; | 43 gfx::NativeView view_gaining_focus) = 0; |
| 40 | 44 |
| 41 // Sent prior to OnAutoCompleteAccept and before the model has been reverted. | 45 // Sent prior to OnAutoCompleteAccept and before the model has been reverted. |
| 42 virtual void OnAutocompleteWillAccept() = 0; | 46 virtual void OnAutocompleteWillAccept() = 0; |
| 47 |
| 48 // Invoked when the popup is going to change its bounds to |bounds|. |
| 49 virtual void OnPopupBoundsChanged(const gfx::Rect& bounds) = 0; |
| 43 #else | 50 #else |
| 44 // TODO: port. | 51 // TODO: port. |
| 45 #endif | 52 #endif |
| 46 | 53 |
| 47 // When the user presses enter or selects a line with the mouse, this | 54 // When the user presses enter or selects a line with the mouse, this |
| 48 // function will get called synchronously with the url to open and | 55 // function will get called synchronously with the url to open and |
| 49 // disposition and transition to use when opening it. | 56 // disposition and transition to use when opening it. |
| 50 // | 57 // |
| 51 // |alternate_nav_url|, if non-empty, contains the alternate navigation URL | 58 // |alternate_nav_url|, if non-empty, contains the alternate navigation URL |
| 52 // for |url|, which the controller can check for existence. See comments on | 59 // for |url|, which the controller can check for existence. See comments on |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 308 |
| 302 // Called by the AutocompleteEditView after something changes, with details | 309 // Called by the AutocompleteEditView after something changes, with details |
| 303 // about what state changes occured. Updates internal state, updates the | 310 // about what state changes occured. Updates internal state, updates the |
| 304 // popup if necessary, and returns true if any significant changes occurred. | 311 // popup if necessary, and returns true if any significant changes occurred. |
| 305 bool OnAfterPossibleChange(const std::wstring& new_text, | 312 bool OnAfterPossibleChange(const std::wstring& new_text, |
| 306 bool selection_differs, | 313 bool selection_differs, |
| 307 bool text_differs, | 314 bool text_differs, |
| 308 bool just_deleted_text, | 315 bool just_deleted_text, |
| 309 bool at_end_of_edit); | 316 bool at_end_of_edit); |
| 310 | 317 |
| 318 // Invoked when the popup is going to change its bounds to |bounds|. |
| 319 void PopupBoundsChangedTo(const gfx::Rect& bounds); |
| 320 |
| 311 private: | 321 private: |
| 312 enum PasteState { | 322 enum PasteState { |
| 313 NONE, // Most recent edit was not a paste that replaced all text. | 323 NONE, // Most recent edit was not a paste that replaced all text. |
| 314 REPLACED_ALL, // Most recent edit was a paste that replaced all text. | 324 REPLACED_ALL, // Most recent edit was a paste that replaced all text. |
| 315 REPLACING_ALL, // In the middle of doing a paste that replaces all | 325 REPLACING_ALL, // In the middle of doing a paste that replaces all |
| 316 // text. We need this intermediate state because OnPaste() | 326 // text. We need this intermediate state because OnPaste() |
| 317 // does the actual detection of such pastes, but | 327 // does the actual detection of such pastes, but |
| 318 // OnAfterPossibleChange() has to update the paste state | 328 // OnAfterPossibleChange() has to update the paste state |
| 319 // for every edit. If OnPaste() set the state directly to | 329 // for every edit. If OnPaste() set the state directly to |
| 320 // REPLACED_ALL, OnAfterPossibleChange() wouldn't know | 330 // REPLACED_ALL, OnAfterPossibleChange() wouldn't know |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 mutable GURL paste_and_go_url_; | 466 mutable GURL paste_and_go_url_; |
| 457 mutable PageTransition::Type paste_and_go_transition_; | 467 mutable PageTransition::Type paste_and_go_transition_; |
| 458 mutable GURL paste_and_go_alternate_nav_url_; | 468 mutable GURL paste_and_go_alternate_nav_url_; |
| 459 | 469 |
| 460 Profile* profile_; | 470 Profile* profile_; |
| 461 | 471 |
| 462 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditModel); | 472 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditModel); |
| 463 }; | 473 }; |
| 464 | 474 |
| 465 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ | 475 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ |
| OLD | NEW |