OLD | NEW |
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 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 47 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
48 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 48 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
49 #include "chrome/browser/ui/search/search_tab_helper.h" | 49 #include "chrome/browser/ui/search/search_tab_helper.h" |
50 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 50 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
51 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
52 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
53 #include "chrome/common/url_constants.h" | 53 #include "chrome/common/url_constants.h" |
54 #include "components/bookmarks/browser/bookmark_model.h" | 54 #include "components/bookmarks/browser/bookmark_model.h" |
55 #include "components/favicon/content/content_favicon_driver.h" | 55 #include "components/favicon/content/content_favicon_driver.h" |
56 #include "components/metrics/proto/omnibox_event.pb.h" | 56 #include "components/metrics/proto/omnibox_event.pb.h" |
| 57 #include "components/omnibox/autocomplete_match_type.h" |
57 #include "components/omnibox/autocomplete_provider.h" | 58 #include "components/omnibox/autocomplete_provider.h" |
58 #include "components/omnibox/keyword_provider.h" | 59 #include "components/omnibox/keyword_provider.h" |
59 #include "components/omnibox/search_provider.h" | 60 #include "components/omnibox/search_provider.h" |
60 #include "components/search_engines/template_url.h" | 61 #include "components/search_engines/template_url.h" |
61 #include "components/search_engines/template_url_prepopulate_data.h" | 62 #include "components/search_engines/template_url_prepopulate_data.h" |
62 #include "components/search_engines/template_url_service.h" | 63 #include "components/search_engines/template_url_service.h" |
63 #include "components/url_fixer/url_fixer.h" | 64 #include "components/url_fixer/url_fixer.h" |
64 #include "content/public/browser/navigation_controller.h" | 65 #include "content/public/browser/navigation_controller.h" |
65 #include "content/public/browser/navigation_entry.h" | 66 #include "content/public/browser/navigation_entry.h" |
66 #include "content/public/browser/notification_service.h" | 67 #include "content/public/browser/notification_service.h" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 // When the user hit enter on the existing permanent URL, treat it like a | 691 // When the user hit enter on the existing permanent URL, treat it like a |
691 // reload for scoring purposes. We could detect this by just checking | 692 // reload for scoring purposes. We could detect this by just checking |
692 // user_input_in_progress_, but it seems better to treat "edits" that end | 693 // user_input_in_progress_, but it seems better to treat "edits" that end |
693 // up leaving the URL unchanged (e.g. deleting the last character and then | 694 // up leaving the URL unchanged (e.g. deleting the last character and then |
694 // retyping it) as reloads too. We exclude non-TYPED transitions because if | 695 // retyping it) as reloads too. We exclude non-TYPED transitions because if |
695 // the transition is GENERATED, the user input something that looked | 696 // the transition is GENERATED, the user input something that looked |
696 // different from the current URL, even if it wound up at the same place | 697 // different from the current URL, even if it wound up at the same place |
697 // (e.g. manually retyping the same search query), and it seems wrong to | 698 // (e.g. manually retyping the same search query), and it seems wrong to |
698 // treat this as a reload. | 699 // treat this as a reload. |
699 match.transition = ui::PAGE_TRANSITION_RELOAD; | 700 match.transition = ui::PAGE_TRANSITION_RELOAD; |
700 } else if (for_drop || ((paste_state_ != NONE) && | 701 } else if (for_drop || |
701 match.is_history_what_you_typed_match)) { | 702 ((paste_state_ != NONE) && |
| 703 (match.type == AutocompleteMatchType::URL_WHAT_YOU_TYPED))) { |
702 // When the user pasted in a URL and hit enter, score it like a link click | 704 // When the user pasted in a URL and hit enter, score it like a link click |
703 // rather than a normal typed URL, so it doesn't get inline autocompleted | 705 // rather than a normal typed URL, so it doesn't get inline autocompleted |
704 // as aggressively later. | 706 // as aggressively later. |
705 match.transition = ui::PAGE_TRANSITION_LINK; | 707 match.transition = ui::PAGE_TRANSITION_LINK; |
706 } | 708 } |
707 | 709 |
708 // While the user is typing, the instant search base page may be prerendered | 710 // While the user is typing, the instant search base page may be prerendered |
709 // in the background. Even though certain inputs may not be eligible for | 711 // in the background. Even though certain inputs may not be eligible for |
710 // prerendering, the prerender isn't automatically cancelled as the user | 712 // prerendering, the prerender isn't automatically cancelled as the user |
711 // continues typing, in hopes the final input will end up making use of the | 713 // continues typing, in hopes the final input will end up making use of the |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 // Update state and notify view if the omnibox has focus and the caret | 1536 // Update state and notify view if the omnibox has focus and the caret |
1535 // visibility changed. | 1537 // visibility changed. |
1536 const bool was_caret_visible = is_caret_visible(); | 1538 const bool was_caret_visible = is_caret_visible(); |
1537 focus_state_ = state; | 1539 focus_state_ = state; |
1538 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1540 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1539 is_caret_visible() != was_caret_visible) | 1541 is_caret_visible() != was_caret_visible) |
1540 view_->ApplyCaretVisibility(); | 1542 view_->ApplyCaretVisibility(); |
1541 | 1543 |
1542 delegate_->OnFocusChanged(focus_state_, reason); | 1544 delegate_->OnFocusChanged(focus_state_, reason); |
1543 } | 1545 } |
OLD | NEW |