OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/net/predictor_api.h" | 24 #include "chrome/browser/net/predictor_api.h" |
25 #include "chrome/browser/net/url_fixer_upper.h" | 25 #include "chrome/browser/net/url_fixer_upper.h" |
26 #include "chrome/browser/prerender/prerender_manager.h" | 26 #include "chrome/browser/prerender/prerender_manager.h" |
27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/search_engines/template_url.h" | 28 #include "chrome/browser/search_engines/template_url.h" |
29 #include "chrome/browser/search_engines/template_url_service.h" | 29 #include "chrome/browser/search_engines/template_url_service.h" |
30 #include "chrome/browser/search_engines/template_url_service_factory.h" | 30 #include "chrome/browser/search_engines/template_url_service_factory.h" |
31 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
32 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 32 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 34 #include "chrome/common/chrome_notification_types.h" |
34 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
35 #include "content/browser/user_metrics.h" | 36 #include "content/browser/user_metrics.h" |
36 #include "content/common/notification_service.h" | 37 #include "content/common/notification_service.h" |
37 #include "googleurl/src/gurl.h" | 38 #include "googleurl/src/gurl.h" |
38 #include "googleurl/src/url_util.h" | 39 #include "googleurl/src/url_util.h" |
39 #include "third_party/skia/include/core/SkBitmap.h" | 40 #include "third_party/skia/include/core/SkBitmap.h" |
40 | 41 |
41 /////////////////////////////////////////////////////////////////////////////// | 42 /////////////////////////////////////////////////////////////////////////////// |
42 // AutocompleteEditController | 43 // AutocompleteEditController |
43 | 44 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 // open). | 494 // open). |
494 if (popup_->IsOpen()) { | 495 if (popup_->IsOpen()) { |
495 AutocompleteLog log(autocomplete_controller_->input().text(), | 496 AutocompleteLog log(autocomplete_controller_->input().text(), |
496 autocomplete_controller_->input().type(), | 497 autocomplete_controller_->input().type(), |
497 popup_->selected_line(), 0, result()); | 498 popup_->selected_line(), 0, result()); |
498 if (index != AutocompletePopupModel::kNoMatch) | 499 if (index != AutocompletePopupModel::kNoMatch) |
499 log.selected_index = index; | 500 log.selected_index = index; |
500 else if (!has_temporary_text_) | 501 else if (!has_temporary_text_) |
501 log.inline_autocompleted_length = inline_autocomplete_text_.length(); | 502 log.inline_autocompleted_length = inline_autocomplete_text_.length(); |
502 NotificationService::current()->Notify( | 503 NotificationService::current()->Notify( |
503 NotificationType::OMNIBOX_OPENED_URL, Source<Profile>(profile_), | 504 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, Source<Profile>(profile_), |
504 Details<AutocompleteLog>(&log)); | 505 Details<AutocompleteLog>(&log)); |
505 } | 506 } |
506 | 507 |
507 TemplateURLService* template_url_service = | 508 TemplateURLService* template_url_service = |
508 TemplateURLServiceFactory::GetForProfile(profile_); | 509 TemplateURLServiceFactory::GetForProfile(profile_); |
509 if (template_url_service && !keyword.empty()) { | 510 if (template_url_service && !keyword.empty()) { |
510 const TemplateURL* const template_url = | 511 const TemplateURL* const template_url = |
511 template_url_service->GetTemplateURLForKeyword(keyword); | 512 template_url_service->GetTemplateURLForKeyword(keyword); |
512 | 513 |
513 // Special case for extension keywords. Don't increment usage count for | 514 // Special case for extension keywords. Don't increment usage count for |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // longer. | 584 // longer. |
584 } | 585 } |
585 | 586 |
586 const AutocompleteResult& AutocompleteEditModel::result() const { | 587 const AutocompleteResult& AutocompleteEditModel::result() const { |
587 return autocomplete_controller_->result(); | 588 return autocomplete_controller_->result(); |
588 } | 589 } |
589 | 590 |
590 void AutocompleteEditModel::OnSetFocus(bool control_down) { | 591 void AutocompleteEditModel::OnSetFocus(bool control_down) { |
591 has_focus_ = true; | 592 has_focus_ = true; |
592 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP; | 593 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP; |
593 NotificationService::current()->Notify(NotificationType::OMNIBOX_FOCUSED, | 594 NotificationService::current()->Notify(chrome::NOTIFICATION_OMNIBOX_FOCUSED, |
594 Source<AutocompleteEditModel>(this), | 595 Source<AutocompleteEditModel>(this), |
595 NotificationService::NoDetails()); | 596 NotificationService::NoDetails()); |
596 InstantController* instant = controller_->GetInstant(); | 597 InstantController* instant = controller_->GetInstant(); |
597 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); | 598 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); |
598 if (instant && tab) | 599 if (instant && tab) |
599 instant->OnAutocompleteGotFocus(tab); | 600 instant->OnAutocompleteGotFocus(tab); |
600 } | 601 } |
601 | 602 |
602 void AutocompleteEditModel::OnWillKillFocus( | 603 void AutocompleteEditModel::OnWillKillFocus( |
603 gfx::NativeView view_gaining_focus) { | 604 gfx::NativeView view_gaining_focus) { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 // static | 1019 // static |
1019 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1020 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1020 switch (c) { | 1021 switch (c) { |
1021 case 0x0020: // Space | 1022 case 0x0020: // Space |
1022 case 0x3000: // Ideographic Space | 1023 case 0x3000: // Ideographic Space |
1023 return true; | 1024 return true; |
1024 default: | 1025 default: |
1025 return false; | 1026 return false; |
1026 } | 1027 } |
1027 } | 1028 } |
OLD | NEW |