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

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

Issue 10704074: "Paste and go" state was being calculated wrong on views (at least). Fix by making this calculatio… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 (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_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 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 void Revert(); 161 void Revert();
162 162
163 // Directs the popup to start autocomplete. 163 // Directs the popup to start autocomplete.
164 void StartAutocomplete(bool has_selected_text, 164 void StartAutocomplete(bool has_selected_text,
165 bool prevent_inline_autocomplete) const; 165 bool prevent_inline_autocomplete) const;
166 166
167 // Closes the popup and cancels any pending asynchronous queries. 167 // Closes the popup and cancels any pending asynchronous queries.
168 void StopAutocomplete(); 168 void StopAutocomplete();
169 169
170 // Determines whether the user can "paste and go", given the specified text. 170 // Determines whether the user can "paste and go", given the specified text.
171 // This also updates the internal paste-and-go-related state variables as
172 // appropriate so that the controller doesn't need to be repeatedly queried
173 // for the same text in every clipboard-related function.
174 bool CanPasteAndGo(const string16& text) const; 171 bool CanPasteAndGo(const string16& text) const;
175 172
176 // Navigates to the destination last supplied to CanPasteAndGo. 173 // Navigates to the destination last supplied to CanPasteAndGo.
177 void PasteAndGo(); 174 void PasteAndGo(const string16& text);
178 175
179 // Returns true if this is a paste-and-search rather than paste-and-go (or 176 // Returns true if this is a paste-and-search rather than paste-and-go (or
180 // nothing). 177 // nothing).
181 bool is_paste_and_search() const { 178 bool IsPasteAndSearch(const string16& text) const;
182 return (paste_and_go_match_.transition != content::PAGE_TRANSITION_TYPED);
183 }
184 179
185 // Asks the browser to load the popup's currently selected item, using the 180 // Asks the browser to load the popup's currently selected item, using the
186 // supplied disposition. This may close the popup. If |for_drop| is true, 181 // supplied disposition. This may close the popup. If |for_drop| is true,
187 // it indicates the input is being accepted as part of a drop operation and 182 // it indicates the input is being accepted as part of a drop operation and
188 // the transition should be treated as LINK (so that it won't trigger the 183 // the transition should be treated as LINK (so that it won't trigger the
189 // URL to be autocompleted). 184 // URL to be autocompleted).
190 void AcceptInput(WindowOpenDisposition disposition, 185 void AcceptInput(WindowOpenDisposition disposition,
191 bool for_drop); 186 bool for_drop);
192 187
193 // Asks the browser to load the item at |index|, with the given properties. 188 // Asks the browser to load the item at |index|, with the given properties.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // keyword. 388 // keyword.
394 static bool IsSpaceCharForAcceptingKeyword(wchar_t c); 389 static bool IsSpaceCharForAcceptingKeyword(wchar_t c);
395 390
396 // Classify the current page being viewed as, for example, the new tab 391 // Classify the current page being viewed as, for example, the new tab
397 // page or a normal web page. Used for logging omnibox events for 392 // page or a normal web page. Used for logging omnibox events for
398 // UMA opted-in users. Examines the user's profile to determine if the 393 // UMA opted-in users. Examines the user's profile to determine if the
399 // current page is the user's home page. 394 // current page is the user's home page.
400 metrics::OmniboxEventProto::PageClassification ClassifyPage( 395 metrics::OmniboxEventProto::PageClassification ClassifyPage(
401 const GURL& gurl) const; 396 const GURL& gurl) const;
402 397
398 // Sets |match| and |alternate_nav_url| based on classifying |text|.
399 // |alternate_nav_url| may be NULL.
400 void ClassifyStringForPasteAndGo(const string16& text,
401 AutocompleteMatch* match,
402 GURL* alternate_nav_url) const;
403
403 scoped_ptr<AutocompleteController> autocomplete_controller_; 404 scoped_ptr<AutocompleteController> autocomplete_controller_;
404 405
405 OmniboxView* view_; 406 OmniboxView* view_;
406 407
407 OmniboxPopupModel* popup_; 408 OmniboxPopupModel* popup_;
408 409
409 OmniboxEditController* controller_; 410 OmniboxEditController* controller_;
410 411
411 // Whether the edit has focus. 412 // Whether the edit has focus.
412 bool has_focus_; 413 bool has_focus_;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // selected keyword, or just some input text that looks like a keyword (so we 488 // selected keyword, or just some input text that looks like a keyword (so we
488 // can show a hint to press <tab>). This is the keyword in either case; 489 // can show a hint to press <tab>). This is the keyword in either case;
489 // is_keyword_hint_ (below) distinguishes the two cases. 490 // is_keyword_hint_ (below) distinguishes the two cases.
490 string16 keyword_; 491 string16 keyword_;
491 492
492 // True if the keyword associated with this match is merely a hint, i.e. the 493 // True if the keyword associated with this match is merely a hint, i.e. the
493 // user hasn't actually selected a keyword yet. When this is true, we can use 494 // user hasn't actually selected a keyword yet. When this is true, we can use
494 // keyword_ to show a "Press <tab> to search" sort of hint. 495 // keyword_ to show a "Press <tab> to search" sort of hint.
495 bool is_keyword_hint_; 496 bool is_keyword_hint_;
496 497
497 // Paste And Go-related state. See CanPasteAndGo().
498 mutable AutocompleteMatch paste_and_go_match_;
499 mutable GURL paste_and_go_alternate_nav_url_;
500
501 Profile* profile_; 498 Profile* profile_;
502 499
503 // This is needed as prior to accepting the current text the model is 500 // This is needed as prior to accepting the current text the model is
504 // reverted, which triggers resetting instant. We don't want to update instant 501 // reverted, which triggers resetting instant. We don't want to update instant
505 // in this case, so we use the flag to determine if this is happening. 502 // in this case, so we use the flag to determine if this is happening.
506 bool in_revert_; 503 bool in_revert_;
507 504
508 // Indicates if the upcoming autocomplete search is allowed to be treated as 505 // Indicates if the upcoming autocomplete search is allowed to be treated as
509 // an exact keyword match. If this is true then keyword mode will be 506 // an exact keyword match. If this is true then keyword mode will be
510 // triggered automatically if the input is "<keyword> <search string>". We 507 // triggered automatically if the input is "<keyword> <search string>". We
511 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. 508 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true.
512 // This has no effect if we're already in keyword mode. 509 // This has no effect if we're already in keyword mode.
513 bool allow_exact_keyword_match_; 510 bool allow_exact_keyword_match_;
514 511
515 // Last value of InstantCompleteBehavior supplied to |SetSuggestedText|. 512 // Last value of InstantCompleteBehavior supplied to |SetSuggestedText|.
516 InstantCompleteBehavior instant_complete_behavior_; 513 InstantCompleteBehavior instant_complete_behavior_;
517 514
518 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); 515 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel);
519 }; 516 };
520 517
521 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ 518 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.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