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" |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 // The user is using a non-substituting keyword or is explicitly in | 550 // The user is using a non-substituting keyword or is explicitly in |
551 // keyword mode. | 551 // keyword mode. |
552 | 552 |
553 // Special case for extension keywords. Don't increment usage count for | 553 // Special case for extension keywords. Don't increment usage count for |
554 // these. | 554 // these. |
555 if (template_url->IsExtensionKeyword()) { | 555 if (template_url->IsExtensionKeyword()) { |
556 AutocompleteMatch current_match; | 556 AutocompleteMatch current_match; |
557 GetInfoForCurrentText(¤t_match, NULL); | 557 GetInfoForCurrentText(¤t_match, NULL); |
558 | 558 |
559 const AutocompleteMatch& match = | 559 const AutocompleteMatch& match = |
560 index == AutocompletePopupModel::kNoMatch ? | 560 (index == AutocompletePopupModel::kNoMatch) ? |
561 current_match : result().match_at(index); | 561 current_match : result().match_at(index); |
562 | 562 |
563 // Strip the keyword + leading space off the input. | 563 // Strip the keyword + leading space off the input. |
564 size_t prefix_length = match.template_url->keyword().length() + 1; | 564 size_t prefix_length = match.template_url->keyword().length() + 1; |
565 ExtensionOmniboxEventRouter::OnInputEntered(profile_, | 565 ExtensionOmniboxEventRouter::OnInputEntered(profile_, |
566 template_url->GetExtensionId(), | 566 template_url->GetExtensionId(), |
567 UTF16ToUTF8(match.fill_into_edit.substr(prefix_length))); | 567 UTF16ToUTF8(match.fill_into_edit.substr(prefix_length))); |
568 view_->RevertAll(); | 568 view_->RevertAll(); |
569 return; | 569 return; |
570 } | 570 } |
571 | 571 |
572 content::RecordAction(UserMetricsAction("AcceptedKeyword")); | 572 content::RecordAction(UserMetricsAction("AcceptedKeyword")); |
573 TemplateURLService* template_url_service = | 573 TemplateURLServiceFactory::GetForProfile(profile_)->IncrementUsageCount( |
574 TemplateURLServiceFactory::GetForProfile(profile_); | 574 template_url); |
575 if (template_url_service) | |
576 template_url_service->IncrementUsageCount(template_url); | |
577 } else { | 575 } else { |
578 DCHECK_EQ(content::PAGE_TRANSITION_GENERATED, match.transition); | 576 DCHECK_EQ(content::PAGE_TRANSITION_GENERATED, match.transition); |
579 // NOTE: We purposefully don't increment the usage count of the default | 577 // NOTE: We purposefully don't increment the usage count of the default |
580 // search engine here like we do for explicit keywords above; see comments | 578 // search engine here like we do for explicit keywords above; see comments |
581 // in template_url.h. | 579 // in template_url.h. |
582 } | 580 } |
583 | 581 |
584 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as | 582 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as |
585 // the prepopulate IDs start at 1. Distribution-specific engines will | 583 // the prepopulate IDs start at 1. Distribution-specific engines will |
586 // all have IDs above the maximum, and will be automatically lumped | 584 // all have IDs above the maximum, and will be automatically lumped |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 // static | 1134 // static |
1137 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1135 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1138 switch (c) { | 1136 switch (c) { |
1139 case 0x0020: // Space | 1137 case 0x0020: // Space |
1140 case 0x3000: // Ideographic Space | 1138 case 0x3000: // Ideographic Space |
1141 return true; | 1139 return true; |
1142 default: | 1140 default: |
1143 return false; | 1141 return false; |
1144 } | 1142 } |
1145 } | 1143 } |
OLD | NEW |