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

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: Version for commit (merged again). 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 24 matching lines...) Expand all
35 #include "chrome/browser/search_engines/template_url_service.h" 35 #include "chrome/browser/search_engines/template_url_service.h"
36 #include "chrome/browser/search_engines/template_url_service_factory.h" 36 #include "chrome/browser/search_engines/template_url_service_factory.h"
37 #include "chrome/browser/ui/browser_list.h" 37 #include "chrome/browser/ui/browser_list.h"
38 #include "chrome/browser/ui/omnibox/omnibox_view.h" 38 #include "chrome/browser/ui/omnibox/omnibox_view.h"
39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
40 #include "chrome/common/chrome_notification_types.h" 40 #include "chrome/common/chrome_notification_types.h"
41 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/url_constants.h" 42 #include "chrome/common/url_constants.h"
43 #include "content/browser/renderer_host/render_view_host.h" 43 #include "content/browser/renderer_host/render_view_host.h"
44 #include "content/browser/tab_contents/tab_contents.h" 44 #include "content/browser/tab_contents/tab_contents.h"
45 #include "content/browser/user_metrics.h"
46 #include "content/public/browser/notification_service.h" 45 #include "content/public/browser/notification_service.h"
46 #include "content/public/browser/user_metrics.h"
47 #include "googleurl/src/gurl.h" 47 #include "googleurl/src/gurl.h"
48 #include "googleurl/src/url_util.h" 48 #include "googleurl/src/url_util.h"
49 #include "third_party/skia/include/core/SkBitmap.h" 49 #include "third_party/skia/include/core/SkBitmap.h"
50 50
51 using content::UserMetricsAction;
52
51 /////////////////////////////////////////////////////////////////////////////// 53 ///////////////////////////////////////////////////////////////////////////////
52 // AutocompleteEditController 54 // AutocompleteEditController
53 55
54 AutocompleteEditController::~AutocompleteEditController() { 56 AutocompleteEditController::~AutocompleteEditController() {
55 } 57 }
56 58
57 /////////////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////////////
58 // AutocompleteEditModel::State 60 // AutocompleteEditModel::State
59 61
60 AutocompleteEditModel::State::State(bool user_input_in_progress, 62 AutocompleteEditModel::State::State(bool user_input_in_progress,
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // Strip the keyword + leading space off the input. 543 // Strip the keyword + leading space off the input.
542 size_t prefix_length = match.template_url->keyword().length() + 1; 544 size_t prefix_length = match.template_url->keyword().length() + 1;
543 ExtensionOmniboxEventRouter::OnInputEntered( 545 ExtensionOmniboxEventRouter::OnInputEntered(
544 profile_, match.template_url->GetExtensionId(), 546 profile_, match.template_url->GetExtensionId(),
545 UTF16ToUTF8(match.fill_into_edit.substr(prefix_length))); 547 UTF16ToUTF8(match.fill_into_edit.substr(prefix_length)));
546 view_->RevertAll(); 548 view_->RevertAll();
547 return; 549 return;
548 } 550 }
549 551
550 if (template_url) { 552 if (template_url) {
551 UserMetrics::RecordAction(UserMetricsAction("AcceptedKeyword")); 553 content::RecordAction(UserMetricsAction("AcceptedKeyword"));
552 template_url_service->IncrementUsageCount(template_url); 554 template_url_service->IncrementUsageCount(template_url);
553 555
554 if (match.transition == content::PAGE_TRANSITION_KEYWORD || 556 if (match.transition == content::PAGE_TRANSITION_KEYWORD ||
555 match.transition == content::PAGE_TRANSITION_KEYWORD_GENERATED) { 557 match.transition == content::PAGE_TRANSITION_KEYWORD_GENERATED) {
556 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as 558 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as
557 // the prepopulate IDs start at 1. Distribution-specific engines will 559 // the prepopulate IDs start at 1. Distribution-specific engines will
558 // all have IDs above the maximum, and will be automatically lumped 560 // all have IDs above the maximum, and will be automatically lumped
559 // together in an "overflow" bucket in the histogram. 561 // together in an "overflow" bucket in the histogram.
560 UMA_HISTOGRAM_ENUMERATION( 562 UMA_HISTOGRAM_ENUMERATION(
561 "Omnibox.SearchEngine", template_url->prepopulate_id(), 563 "Omnibox.SearchEngine", template_url->prepopulate_id(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 DCHECK(is_keyword_hint_ && !keyword_.empty()); 602 DCHECK(is_keyword_hint_ && !keyword_.empty());
601 603
602 view_->OnBeforePossibleChange(); 604 view_->OnBeforePossibleChange();
603 view_->SetWindowTextAndCaretPos(string16(), 0); 605 view_->SetWindowTextAndCaretPos(string16(), 0);
604 is_keyword_hint_ = false; 606 is_keyword_hint_ = false;
605 view_->OnAfterPossibleChange(); 607 view_->OnAfterPossibleChange();
606 just_deleted_text_ = false; // OnAfterPossibleChange() erroneously sets this 608 just_deleted_text_ = false; // OnAfterPossibleChange() erroneously sets this
607 // since the edit contents have disappeared. It 609 // since the edit contents have disappeared. It
608 // doesn't really matter, but we clear it to be 610 // doesn't really matter, but we clear it to be
609 // consistent. 611 // consistent.
610 UserMetrics::RecordAction(UserMetricsAction("AcceptedKeywordHint")); 612 content::RecordAction(UserMetricsAction("AcceptedKeywordHint"));
611 return true; 613 return true;
612 } 614 }
613 615
614 void AutocompleteEditModel::ClearKeyword(const string16& visible_text) { 616 void AutocompleteEditModel::ClearKeyword(const string16& visible_text) {
615 view_->OnBeforePossibleChange(); 617 view_->OnBeforePossibleChange();
616 const string16 window_text(keyword_ + visible_text); 618 const string16 window_text(keyword_ + visible_text);
617 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length()); 619 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length());
618 keyword_.clear(); 620 keyword_.clear();
619 is_keyword_hint_ = false; 621 is_keyword_hint_ = false;
620 view_->OnAfterPossibleChange(); 622 view_->OnAfterPossibleChange();
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 // static 1087 // static
1086 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 1088 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
1087 switch (c) { 1089 switch (c) {
1088 case 0x0020: // Space 1090 case 0x0020: // Space
1089 case 0x3000: // Ideographic Space 1091 case 0x3000: // Ideographic Space
1090 return true; 1092 return true;
1091 default: 1093 default:
1092 return false; 1094 return false;
1093 } 1095 }
1094 } 1096 }
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | chrome/browser/background/background_mode_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698