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

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

Issue 232023004: Ensures the autocomplete_controller input is saved and restored when changing tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed broken browser test. Created 6 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
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"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" 13 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
14 #include "chrome/browser/autocomplete/autocomplete_input.h"
14 #include "chrome/browser/autocomplete/autocomplete_match.h" 15 #include "chrome/browser/autocomplete/autocomplete_match.h"
15 #include "chrome/browser/ui/omnibox/omnibox_controller.h" 16 #include "chrome/browser/ui/omnibox/omnibox_controller.h"
16 #include "chrome/common/instant_types.h" 17 #include "chrome/common/instant_types.h"
17 #include "chrome/common/omnibox_focus_state.h" 18 #include "chrome/common/omnibox_focus_state.h"
18 #include "content/public/common/page_transition_types.h" 19 #include "content/public/common/page_transition_types.h"
19 #include "ui/base/window_open_disposition.h" 20 #include "ui/base/window_open_disposition.h"
20 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 23
23 class AutocompleteController; 24 class AutocompleteController;
(...skipping 29 matching lines...) Expand all
53 }; 54 };
54 55
55 struct State { 56 struct State {
56 State(bool user_input_in_progress, 57 State(bool user_input_in_progress,
57 const base::string16& user_text, 58 const base::string16& user_text,
58 const base::string16& gray_text, 59 const base::string16& gray_text,
59 const base::string16& keyword, 60 const base::string16& keyword,
60 bool is_keyword_hint, 61 bool is_keyword_hint,
61 bool url_replacement_enabled, 62 bool url_replacement_enabled,
62 OmniboxFocusState focus_state, 63 OmniboxFocusState focus_state,
63 FocusSource focus_source); 64 FocusSource focus_source,
65 const AutocompleteInput& autocomplete_input);
64 ~State(); 66 ~State();
65 67
66 bool user_input_in_progress; 68 bool user_input_in_progress;
67 const base::string16 user_text; 69 const base::string16 user_text;
68 const base::string16 gray_text; 70 const base::string16 gray_text;
69 const base::string16 keyword; 71 const base::string16 keyword;
70 const bool is_keyword_hint; 72 const bool is_keyword_hint;
71 bool url_replacement_enabled; 73 bool url_replacement_enabled;
72 OmniboxFocusState focus_state; 74 OmniboxFocusState focus_state;
73 FocusSource focus_source; 75 FocusSource focus_source;
76 const AutocompleteInput autocomplete_input;
74 }; 77 };
75 78
76 OmniboxEditModel(OmniboxView* view, 79 OmniboxEditModel(OmniboxView* view,
77 OmniboxEditController* controller, 80 OmniboxEditController* controller,
78 Profile* profile); 81 Profile* profile);
79 virtual ~OmniboxEditModel(); 82 virtual ~OmniboxEditModel();
80 83
81 // TODO(beaudoin): Remove this accessor when the AutocompleteController has 84 // TODO(beaudoin): Remove this accessor when the AutocompleteController has
82 // completely moved to OmniboxController. 85 // completely moved to OmniboxController.
83 AutocompleteController* autocomplete_controller() const { 86 AutocompleteController* autocomplete_controller() const {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Invoked any time the text may have changed in the edit. Notifies the 167 // Invoked any time the text may have changed in the edit. Notifies the
165 // controller. 168 // controller.
166 void OnChanged(); 169 void OnChanged();
167 170
168 // Reverts the edit model back to its unedited state (permanent text showing, 171 // Reverts the edit model back to its unedited state (permanent text showing,
169 // no user input in progress). 172 // no user input in progress).
170 void Revert(); 173 void Revert();
171 174
172 // Directs the popup to start autocomplete. 175 // Directs the popup to start autocomplete.
173 void StartAutocomplete(bool has_selected_text, 176 void StartAutocomplete(bool has_selected_text,
174 bool prevent_inline_autocomplete) const; 177 bool prevent_inline_autocomplete);
175 178
176 // Closes the popup and cancels any pending asynchronous queries. 179 // Closes the popup and cancels any pending asynchronous queries.
177 void StopAutocomplete(); 180 void StopAutocomplete();
178 181
179 // Determines whether the user can "paste and go", given the specified text. 182 // Determines whether the user can "paste and go", given the specified text.
180 bool CanPasteAndGo(const base::string16& text) const; 183 bool CanPasteAndGo(const base::string16& text) const;
181 184
182 // Navigates to the destination last supplied to CanPasteAndGo. 185 // Navigates to the destination last supplied to CanPasteAndGo.
183 void PasteAndGo(const base::string16& text); 186 void PasteAndGo(const base::string16& text);
184 187
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // presses escape. 547 // presses escape.
545 bool in_revert_; 548 bool in_revert_;
546 549
547 // Indicates if the upcoming autocomplete search is allowed to be treated as 550 // Indicates if the upcoming autocomplete search is allowed to be treated as
548 // an exact keyword match. If this is true then keyword mode will be 551 // an exact keyword match. If this is true then keyword mode will be
549 // triggered automatically if the input is "<keyword> <search string>". We 552 // triggered automatically if the input is "<keyword> <search string>". We
550 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. 553 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true.
551 // This has no effect if we're already in keyword mode. 554 // This has no effect if we're already in keyword mode.
552 bool allow_exact_keyword_match_; 555 bool allow_exact_keyword_match_;
553 556
557 // The input that was sent to the AutocompleteController. Since no
558 // autocomplete query is started after a tab switch, it is possible for this
559 // |input_| to differ from the one currently stored in AutocompleteController.
560 AutocompleteInput input_;
561
554 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); 562 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel);
555 }; 563 };
556 564
557 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ 565 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_controller.cc ('k') | chrome/browser/ui/omnibox/omnibox_edit_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698