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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit.cc

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to content namespace. Update usages. Update extract_actions tool. Created 9 years 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) 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 22 matching lines...) Expand all
33 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 33 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
34 #include "chrome/browser/search_engines/template_url_service.h" 34 #include "chrome/browser/search_engines/template_url_service.h"
35 #include "chrome/browser/search_engines/template_url_service_factory.h" 35 #include "chrome/browser/search_engines/template_url_service_factory.h"
36 #include "chrome/browser/ui/browser_list.h" 36 #include "chrome/browser/ui/browser_list.h"
37 #include "chrome/browser/ui/omnibox/omnibox_view.h" 37 #include "chrome/browser/ui/omnibox/omnibox_view.h"
38 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 38 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
39 #include "chrome/common/chrome_notification_types.h" 39 #include "chrome/common/chrome_notification_types.h"
40 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/url_constants.h" 41 #include "chrome/common/url_constants.h"
42 #include "content/browser/renderer_host/render_view_host.h" 42 #include "content/browser/renderer_host/render_view_host.h"
43 #include "content/browser/user_metrics.h"
44 #include "content/public/browser/notification_service.h" 43 #include "content/public/browser/notification_service.h"
44 #include "content/public/browser/user_metrics.h"
45 #include "googleurl/src/gurl.h" 45 #include "googleurl/src/gurl.h"
46 #include "googleurl/src/url_util.h" 46 #include "googleurl/src/url_util.h"
47 #include "third_party/skia/include/core/SkBitmap.h" 47 #include "third_party/skia/include/core/SkBitmap.h"
48 48
49 using content::UserMetricsAction;
50
49 /////////////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////////////
50 // AutocompleteEditController 52 // AutocompleteEditController
51 53
52 AutocompleteEditController::~AutocompleteEditController() { 54 AutocompleteEditController::~AutocompleteEditController() {
53 } 55 }
54 56
55 /////////////////////////////////////////////////////////////////////////////// 57 ///////////////////////////////////////////////////////////////////////////////
56 // AutocompleteEditModel::State 58 // AutocompleteEditModel::State
57 59
58 AutocompleteEditModel::State::State(bool user_input_in_progress, 60 AutocompleteEditModel::State::State(bool user_input_in_progress,
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // Strip the keyword + leading space off the input. 540 // Strip the keyword + leading space off the input.
539 size_t prefix_length = match.template_url->keyword().length() + 1; 541 size_t prefix_length = match.template_url->keyword().length() + 1;
540 ExtensionOmniboxEventRouter::OnInputEntered( 542 ExtensionOmniboxEventRouter::OnInputEntered(
541 profile_, match.template_url->GetExtensionId(), 543 profile_, match.template_url->GetExtensionId(),
542 UTF16ToUTF8(match.fill_into_edit.substr(prefix_length))); 544 UTF16ToUTF8(match.fill_into_edit.substr(prefix_length)));
543 view_->RevertAll(); 545 view_->RevertAll();
544 return; 546 return;
545 } 547 }
546 548
547 if (template_url) { 549 if (template_url) {
548 UserMetrics::RecordAction(UserMetricsAction("AcceptedKeyword")); 550 content::RecordAction(UserMetricsAction("AcceptedKeyword"));
549 template_url_service->IncrementUsageCount(template_url); 551 template_url_service->IncrementUsageCount(template_url);
550 552
551 if (match.transition == content::PAGE_TRANSITION_KEYWORD || 553 if (match.transition == content::PAGE_TRANSITION_KEYWORD ||
552 match.transition == content::PAGE_TRANSITION_KEYWORD_GENERATED) { 554 match.transition == content::PAGE_TRANSITION_KEYWORD_GENERATED) {
553 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as 555 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as
554 // the prepopulate IDs start at 1. Distribution-specific engines will 556 // the prepopulate IDs start at 1. Distribution-specific engines will
555 // all have IDs above the maximum, and will be automatically lumped 557 // all have IDs above the maximum, and will be automatically lumped
556 // together in an "overflow" bucket in the histogram. 558 // together in an "overflow" bucket in the histogram.
557 UMA_HISTOGRAM_ENUMERATION( 559 UMA_HISTOGRAM_ENUMERATION(
558 "Omnibox.SearchEngine", template_url->prepopulate_id(), 560 "Omnibox.SearchEngine", template_url->prepopulate_id(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 DCHECK(is_keyword_hint_ && !keyword_.empty()); 599 DCHECK(is_keyword_hint_ && !keyword_.empty());
598 600
599 view_->OnBeforePossibleChange(); 601 view_->OnBeforePossibleChange();
600 view_->SetWindowTextAndCaretPos(string16(), 0); 602 view_->SetWindowTextAndCaretPos(string16(), 0);
601 is_keyword_hint_ = false; 603 is_keyword_hint_ = false;
602 view_->OnAfterPossibleChange(); 604 view_->OnAfterPossibleChange();
603 just_deleted_text_ = false; // OnAfterPossibleChange() erroneously sets this 605 just_deleted_text_ = false; // OnAfterPossibleChange() erroneously sets this
604 // since the edit contents have disappeared. It 606 // since the edit contents have disappeared. It
605 // doesn't really matter, but we clear it to be 607 // doesn't really matter, but we clear it to be
606 // consistent. 608 // consistent.
607 UserMetrics::RecordAction(UserMetricsAction("AcceptedKeywordHint")); 609 content::RecordAction(UserMetricsAction("AcceptedKeywordHint"));
608 return true; 610 return true;
609 } 611 }
610 612
611 void AutocompleteEditModel::ClearKeyword(const string16& visible_text) { 613 void AutocompleteEditModel::ClearKeyword(const string16& visible_text) {
612 view_->OnBeforePossibleChange(); 614 view_->OnBeforePossibleChange();
613 const string16 window_text(keyword_ + visible_text); 615 const string16 window_text(keyword_ + visible_text);
614 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length()); 616 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length());
615 keyword_.clear(); 617 keyword_.clear();
616 is_keyword_hint_ = false; 618 is_keyword_hint_ = false;
617 view_->OnAfterPossibleChange(); 619 view_->OnAfterPossibleChange();
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 // static 1084 // static
1083 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 1085 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
1084 switch (c) { 1086 switch (c) {
1085 case 0x0020: // Space 1087 case 0x0020: // Space
1086 case 0x3000: // Ideographic Space 1088 case 0x3000: // Ideographic Space
1087 return true; 1089 return true;
1088 default: 1090 default:
1089 return false; 1091 return false;
1090 } 1092 }
1091 } 1093 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698