OLD | NEW |
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 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
16 #include "chrome/browser/autocomplete/autocomplete_match.h" | 16 #include "chrome/browser/autocomplete/autocomplete_match.h" |
17 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 17 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
18 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 18 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
19 #include "chrome/browser/autocomplete/keyword_provider.h" | 19 #include "chrome/browser/autocomplete/keyword_provider.h" |
20 #include "chrome/browser/autocomplete/network_action_predictor.h" | 20 #include "chrome/browser/autocomplete/network_action_predictor.h" |
21 #include "chrome/browser/autocomplete/network_action_predictor_factory.h" | 21 #include "chrome/browser/autocomplete/network_action_predictor_factory.h" |
22 #include "chrome/browser/autocomplete/search_provider.h" | 22 #include "chrome/browser/autocomplete/search_provider.h" |
23 #include "chrome/browser/bookmarks/bookmark_utils.h" | 23 #include "chrome/browser/bookmarks/bookmark_utils.h" |
24 #include "chrome/browser/command_updater.h" | 24 #include "chrome/browser/command_updater.h" |
25 #include "chrome/browser/extensions/extension_omnibox_api.h" | 25 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
26 #include "chrome/browser/google/google_url_tracker.h" | 26 #include "chrome/browser/google/google_url_tracker.h" |
27 #include "chrome/browser/instant/instant_controller.h" | 27 #include "chrome/browser/instant/instant_controller.h" |
28 #include "chrome/browser/net/predictor.h" | 28 #include "chrome/browser/net/predictor.h" |
29 #include "chrome/browser/net/url_fixer_upper.h" | 29 #include "chrome/browser/net/url_fixer_upper.h" |
30 #include "chrome/browser/prerender/prerender_field_trial.h" | 30 #include "chrome/browser/prerender/prerender_field_trial.h" |
31 #include "chrome/browser/prerender/prerender_manager.h" | 31 #include "chrome/browser/prerender/prerender_manager.h" |
32 #include "chrome/browser/prerender/prerender_manager_factory.h" | 32 #include "chrome/browser/prerender/prerender_manager_factory.h" |
33 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
34 #include "chrome/browser/search_engines/template_url.h" | 34 #include "chrome/browser/search_engines/template_url.h" |
35 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 35 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 if (template_url->IsExtensionKeyword()) { | 552 if (template_url->IsExtensionKeyword()) { |
553 AutocompleteMatch current_match; | 553 AutocompleteMatch current_match; |
554 GetInfoForCurrentText(¤t_match, NULL); | 554 GetInfoForCurrentText(¤t_match, NULL); |
555 | 555 |
556 const AutocompleteMatch& match = | 556 const AutocompleteMatch& match = |
557 (index == AutocompletePopupModel::kNoMatch) ? | 557 (index == AutocompletePopupModel::kNoMatch) ? |
558 current_match : result().match_at(index); | 558 current_match : result().match_at(index); |
559 | 559 |
560 // Strip the keyword + leading space off the input. | 560 // Strip the keyword + leading space off the input. |
561 size_t prefix_length = match.template_url->keyword().length() + 1; | 561 size_t prefix_length = match.template_url->keyword().length() + 1; |
562 ExtensionOmniboxEventRouter::OnInputEntered(profile_, | 562 extensions::ExtensionOmniboxEventRouter::OnInputEntered(profile_, |
563 template_url->GetExtensionId(), | 563 template_url->GetExtensionId(), |
564 UTF16ToUTF8(match.fill_into_edit.substr(prefix_length))); | 564 UTF16ToUTF8(match.fill_into_edit.substr(prefix_length))); |
565 view_->RevertAll(); | 565 view_->RevertAll(); |
566 return; | 566 return; |
567 } | 567 } |
568 | 568 |
569 content::RecordAction(UserMetricsAction("AcceptedKeyword")); | 569 content::RecordAction(UserMetricsAction("AcceptedKeyword")); |
570 TemplateURLServiceFactory::GetForProfile(profile_)->IncrementUsageCount( | 570 TemplateURLServiceFactory::GetForProfile(profile_)->IncrementUsageCount( |
571 template_url); | 571 template_url); |
572 } else { | 572 } else { |
(...skipping 11 matching lines...) Expand all Loading... |
584 template_url->prepopulate_id(), | 584 template_url->prepopulate_id(), |
585 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); | 585 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); |
586 } | 586 } |
587 | 587 |
588 if (disposition != NEW_BACKGROUND_TAB) { | 588 if (disposition != NEW_BACKGROUND_TAB) { |
589 in_revert_ = true; | 589 in_revert_ = true; |
590 view_->RevertAll(); // Revert the box to its unedited state | 590 view_->RevertAll(); // Revert the box to its unedited state |
591 } | 591 } |
592 | 592 |
593 if (match.type == AutocompleteMatch::EXTENSION_APP) { | 593 if (match.type == AutocompleteMatch::EXTENSION_APP) { |
594 LaunchAppFromOmnibox(match, profile_, disposition); | 594 extensions::LaunchAppFromOmnibox(match, profile_, disposition); |
595 } else { | 595 } else { |
596 controller_->OnAutocompleteAccept(match.destination_url, disposition, | 596 controller_->OnAutocompleteAccept(match.destination_url, disposition, |
597 match.transition, alternate_nav_url); | 597 match.transition, alternate_nav_url); |
598 } | 598 } |
599 | 599 |
600 if (match.starred) | 600 if (match.starred) |
601 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_OMNIBOX); | 601 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_OMNIBOX); |
602 | 602 |
603 InstantController* instant = controller_->GetInstant(); | 603 InstantController* instant = controller_->GetInstant(); |
604 if (instant && !popup_->IsOpen()) | 604 if (instant && !popup_->IsOpen()) |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 // static | 1131 // static |
1132 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1132 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1133 switch (c) { | 1133 switch (c) { |
1134 case 0x0020: // Space | 1134 case 0x0020: // Space |
1135 case 0x3000: // Ideographic Space | 1135 case 0x3000: // Ideographic Space |
1136 return true; | 1136 return true; |
1137 default: | 1137 default: |
1138 return false; | 1138 return false; |
1139 } | 1139 } |
1140 } | 1140 } |
OLD | NEW |