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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.h

Issue 14358005: Omnibox refactor, moved OnResultChanged to OmniboxController (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_
6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 OmniboxEditModel(OmniboxView* view, 80 OmniboxEditModel(OmniboxView* view,
81 OmniboxEditController* controller, 81 OmniboxEditController* controller,
82 Profile* profile); 82 Profile* profile);
83 virtual ~OmniboxEditModel(); 83 virtual ~OmniboxEditModel();
84 84
85 AutocompleteController* autocomplete_controller() const { 85 AutocompleteController* autocomplete_controller() const {
86 return omnibox_controller_->autocomplete_controller(); 86 return omnibox_controller_->autocomplete_controller();
87 } 87 }
88 88
89 void set_popup_model(OmniboxPopupModel* popup_model) { 89 void set_popup_model(OmniboxPopupModel* popup_model) {
90 popup_ = popup_model; 90 omnibox_controller_->set_popup_model(popup_model);
91 } 91 }
92 92
93 // TODO: The edit and popup should be siblings owned by the LocationBarView, 93 // TODO: The edit and popup should be siblings owned by the LocationBarView,
94 // making this accessor unnecessary. 94 // making this accessor unnecessary.
95 OmniboxPopupModel* popup_model() const { return popup_; } 95 OmniboxPopupModel* popup_model() const {
96 return omnibox_controller_->popup_model();
97 }
96 98
97 OmniboxEditController* controller() const { return controller_; } 99 OmniboxEditController* controller() const { return controller_; }
98 100
99 Profile* profile() const { return profile_; } 101 Profile* profile() const { return profile_; }
100 102
101 // Returns the current state. This assumes we are switching tabs, and changes 103 // Returns the current state. This assumes we are switching tabs, and changes
102 // the internal state appropriately. 104 // the internal state appropriately.
103 const State GetStateForTabSwitch(); 105 const State GetStateForTabSwitch();
104 106
105 // Restores local state from the saved |state|. 107 // Restores local state from the saved |state|.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // is_keyword_hint_). 222 // is_keyword_hint_).
221 const string16& keyword() const { return keyword_; } 223 const string16& keyword() const { return keyword_; }
222 bool is_keyword_hint() const { return is_keyword_hint_; } 224 bool is_keyword_hint() const { return is_keyword_hint_; }
223 225
224 // Accepts the current keyword hint as a keyword. It always returns true for 226 // Accepts the current keyword hint as a keyword. It always returns true for
225 // caller convenience. |entered_method| indicates how the use entered 227 // caller convenience. |entered_method| indicates how the use entered
226 // keyword mode. This parameter is only used for metrics/logging; it's not 228 // keyword mode. This parameter is only used for metrics/logging; it's not
227 // used to change user-visible behavior. 229 // used to change user-visible behavior.
228 bool AcceptKeyword(EnteredKeywordModeMethod entered_method); 230 bool AcceptKeyword(EnteredKeywordModeMethod entered_method);
229 231
232 // Accepts the current temporary text as the user text.
233 void AcceptTemporaryTextAsUserText();
234
230 // Clears the current keyword. |visible_text| is the (non-keyword) text 235 // Clears the current keyword. |visible_text| is the (non-keyword) text
231 // currently visible in the edit. 236 // currently visible in the edit.
232 void ClearKeyword(const string16& visible_text); 237 void ClearKeyword(const string16& visible_text);
233 238
234 // Returns the current autocomplete result. This logic should in the future 239 // Returns the current autocomplete result. This logic should in the future
235 // live in AutocompleteController but resides here for now. This method is 240 // live in AutocompleteController but resides here for now. This method is
236 // used by AutomationProvider::AutocompleteEditGetMatches. 241 // used by AutomationProvider::AutocompleteEditGetMatches.
237 const AutocompleteResult& result() const; 242 const AutocompleteResult& result() const {
243 return omnibox_controller_->result();
244 }
238 245
239 // Called when the view is gaining focus. |control_down| is whether the 246 // Called when the view is gaining focus. |control_down| is whether the
240 // control key is down (at the time we're gaining focus). 247 // control key is down (at the time we're gaining focus).
241 void OnSetFocus(bool control_down); 248 void OnSetFocus(bool control_down);
242 249
243 // Sets the visibility of the caret in the omnibox, if it has focus. The 250 // Sets the visibility of the caret in the omnibox, if it has focus. The
244 // visibility of the caret is reset to visible if either 251 // visibility of the caret is reset to visible if either
245 // - The user starts typing, or 252 // - The user starts typing, or
246 // - We explicitly focus the omnibox again. 253 // - We explicitly focus the omnibox again.
247 // The latter case must be handled in three separate places--OnSetFocus(), 254 // The latter case must be handled in three separate places--OnSetFocus(),
(...skipping 17 matching lines...) Expand all
265 // Called when the user presses or releases the control key. Changes state as 272 // Called when the user presses or releases the control key. Changes state as
266 // necessary. 273 // necessary.
267 void OnControlKeyChanged(bool pressed); 274 void OnControlKeyChanged(bool pressed);
268 275
269 // Called when the user pastes in text. 276 // Called when the user pastes in text.
270 void on_paste() { paste_state_ = PASTING; } 277 void on_paste() { paste_state_ = PASTING; }
271 278
272 // Returns true if pasting is in progress. 279 // Returns true if pasting is in progress.
273 bool is_pasting() const { return paste_state_ == PASTING; } 280 bool is_pasting() const { return paste_state_ == PASTING; }
274 281
282 // TODO(beaudoin): Try not to expose this.
283 bool in_revert() const { return in_revert_; }
284
275 // Called when the user presses up or down. |count| is a repeat count, 285 // Called when the user presses up or down. |count| is a repeat count,
276 // negative for moving up, positive for moving down. 286 // negative for moving up, positive for moving down.
277 virtual void OnUpOrDownKeyPressed(int count); 287 virtual void OnUpOrDownKeyPressed(int count);
278 288
279 // Called when any relevant data changes. This rolls together several 289 // Called when any relevant data changes. This rolls together several
280 // separate pieces of data into one call so we can update all the UI 290 // separate pieces of data into one call so we can update all the UI
281 // efficiently: 291 // efficiently:
282 // |text| is either the new temporary text from the user manually selecting 292 // |text| is either the new temporary text from the user manually selecting
283 // a different match, or the inline autocomplete text. We distinguish by 293 // a different match, or the inline autocomplete text. We distinguish by
284 // checking if |destination_for_temporary_text_change| is NULL. 294 // checking if |destination_for_temporary_text_change| is NULL.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // AutomationProvider::AutocompleteEditIsQueryInProgress. 363 // AutomationProvider::AutocompleteEditIsQueryInProgress.
354 bool query_in_progress() const; 364 bool query_in_progress() const;
355 365
356 // Called whenever user_text_ should change. 366 // Called whenever user_text_ should change.
357 void InternalSetUserText(const string16& text); 367 void InternalSetUserText(const string16& text);
358 368
359 // Returns true if a keyword is selected. 369 // Returns true if a keyword is selected.
360 bool KeywordIsSelected() const; 370 bool KeywordIsSelected() const;
361 371
362 // Turns off keyword mode for the current match. 372 // Turns off keyword mode for the current match.
363 void ClearPopupKeywordMode() const; 373 void ClearPopupKeywordMode() const {
374 omnibox_controller_->ClearPopupKeywordMode();
375 }
364 376
365 // Conversion between user text and display text. User text is the text the 377 // Conversion between user text and display text. User text is the text the
366 // user has input. Display text is the text being shown in the edit. The 378 // user has input. Display text is the text being shown in the edit. The
367 // two are different if a keyword is selected. 379 // two are different if a keyword is selected.
368 string16 DisplayTextFromUserText(const string16& text) const; 380 string16 DisplayTextFromUserText(const string16& text) const;
369 string16 UserTextFromDisplayText(const string16& text) const; 381 string16 UserTextFromDisplayText(const string16& text) const;
370 382
371 // Copies the selected match into |match|. If an update is in progress, 383 // Copies the selected match into |match|. If an update is in progress,
372 // "selected" means "default in the latest matches". If there are no matches, 384 // "selected" means "default in the latest matches". If there are no matches,
373 // does not update |match|. 385 // does not update |match|.
374 // 386 //
375 // If |alternate_nav_url| is non-NULL, it will be set to the alternate 387 // If |alternate_nav_url| is non-NULL, it will be set to the alternate
376 // navigation URL for |url| if one exists, or left unchanged otherwise. See 388 // navigation URL for |url| if one exists, or left unchanged otherwise. See
377 // comments on AutocompleteResult::GetAlternateNavURL(). 389 // comments on AutocompleteResult::GetAlternateNavURL().
378 // 390 //
379 // TODO(pkasting): When manually_selected_match_ moves to the controller, this 391 // TODO(pkasting): When manually_selected_match_ moves to the controller, this
380 // can move too. 392 // can move too.
381 void InfoForCurrentSelection(AutocompleteMatch* match, 393 void InfoForCurrentSelection(AutocompleteMatch* match,
382 GURL* alternate_nav_url) const; 394 GURL* alternate_nav_url) const {
395 omnibox_controller_->InfoForCurrentSelection(match, alternate_nav_url);
396 }
383 397
384 // Returns the default match for the current text, as well as the alternate 398 // Returns the default match for the current text, as well as the alternate
385 // nav URL, if |alternate_nav_url| is non-NULL and there is such a URL. 399 // nav URL, if |alternate_nav_url| is non-NULL and there is such a URL.
386 void GetInfoForCurrentText(AutocompleteMatch* match, 400 void GetInfoForCurrentText(AutocompleteMatch* match,
387 GURL* alternate_nav_url) const; 401 GURL* alternate_nav_url) const;
388 402
389 // Reverts the edit box from a temporary text back to the original user text. 403 // Reverts the edit box from a temporary text back to the original user text.
390 // If |revert_popup| is true then the popup will be reverted as well. 404 // If |revert_popup| is true then the popup will be reverted as well.
391 void RevertTemporaryText(bool revert_popup); 405 void RevertTemporaryText(bool revert_popup);
392 406
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // If focus_state_ does not match |state|, we update it and notify the 446 // If focus_state_ does not match |state|, we update it and notify the
433 // InstantController about the change (passing along the |reason| for the 447 // InstantController about the change (passing along the |reason| for the
434 // change). If the caret visibility changes, we call ApplyCaretVisibility() on 448 // change). If the caret visibility changes, we call ApplyCaretVisibility() on
435 // the view. 449 // the view.
436 void SetFocusState(OmniboxFocusState state, OmniboxFocusChangeReason reason); 450 void SetFocusState(OmniboxFocusState state, OmniboxFocusChangeReason reason);
437 451
438 scoped_ptr<OmniboxController> omnibox_controller_; 452 scoped_ptr<OmniboxController> omnibox_controller_;
439 453
440 OmniboxView* view_; 454 OmniboxView* view_;
441 455
442 OmniboxPopupModel* popup_;
443
444 OmniboxEditController* controller_; 456 OmniboxEditController* controller_;
445 457
446 scoped_ptr<OmniboxCurrentPageDelegate> delegate_; 458 scoped_ptr<OmniboxCurrentPageDelegate> delegate_;
447 459
448 OmniboxFocusState focus_state_; 460 OmniboxFocusState focus_state_;
449 461
450 // The URL of the currently displayed page. 462 // The URL of the currently displayed page.
451 string16 permanent_text_; 463 string16 permanent_text_;
452 464
453 // This flag is true when the user has modified the contents of the edit, but 465 // This flag is true when the user has modified the contents of the edit, but
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // an exact keyword match. If this is true then keyword mode will be 564 // an exact keyword match. If this is true then keyword mode will be
553 // triggered automatically if the input is "<keyword> <search string>". We 565 // triggered automatically if the input is "<keyword> <search string>". We
554 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. 566 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true.
555 // This has no effect if we're already in keyword mode. 567 // This has no effect if we're already in keyword mode.
556 bool allow_exact_keyword_match_; 568 bool allow_exact_keyword_match_;
557 569
558 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); 570 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel);
559 }; 571 };
560 572
561 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ 573 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698