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/ui/webui/ntp/suggestions_page_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
27 #include "components/history/core/browser/page_usage_data.h" | 27 #include "components/history/core/browser/page_usage_data.h" |
28 #include "components/pref_registry/pref_registry_syncable.h" | 28 #include "components/pref_registry/pref_registry_syncable.h" |
29 #include "content/public/browser/navigation_controller.h" | 29 #include "content/public/browser/navigation_controller.h" |
30 #include "content/public/browser/navigation_entry.h" | 30 #include "content/public/browser/navigation_entry.h" |
31 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
32 #include "content/public/browser/url_data_source.h" | 32 #include "content/public/browser/url_data_source.h" |
33 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
35 #include "content/public/browser/web_ui.h" | 35 #include "content/public/browser/web_ui.h" |
36 #include "content/public/common/page_transition_types.h" | 36 #include "ui/base/page_transition_types.h" |
37 #include "url/gurl.h" | 37 #include "url/gurl.h" |
38 | 38 |
39 using base::UserMetricsAction; | 39 using base::UserMetricsAction; |
40 | 40 |
41 SuggestionsHandler::SuggestionsHandler() | 41 SuggestionsHandler::SuggestionsHandler() |
42 : got_first_suggestions_request_(false), | 42 : got_first_suggestions_request_(false), |
43 suggestions_viewed_(false), | 43 suggestions_viewed_(false), |
44 user_action_logged_(false) { | 44 user_action_logged_(false) { |
45 } | 45 } |
46 | 46 |
47 SuggestionsHandler::~SuggestionsHandler() { | 47 SuggestionsHandler::~SuggestionsHandler() { |
48 if (!user_action_logged_ && suggestions_viewed_) { | 48 if (!user_action_logged_ && suggestions_viewed_) { |
49 const GURL ntp_url = GURL(chrome::kChromeUINewTabURL); | 49 const GURL ntp_url = GURL(chrome::kChromeUINewTabURL); |
50 int action_id = NTP_FOLLOW_ACTION_OTHER; | 50 int action_id = NTP_FOLLOW_ACTION_OTHER; |
51 content::NavigationEntry* entry = | 51 content::NavigationEntry* entry = |
52 web_ui()->GetWebContents()->GetController().GetLastCommittedEntry(); | 52 web_ui()->GetWebContents()->GetController().GetLastCommittedEntry(); |
53 if (entry && (entry->GetURL() != ntp_url)) { | 53 if (entry && (entry->GetURL() != ntp_url)) { |
54 action_id = | 54 action_id = |
55 content::PageTransitionStripQualifier(entry->GetTransitionType()); | 55 ui::PageTransitionStripQualifier(entry->GetTransitionType()); |
56 } | 56 } |
57 | 57 |
58 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id, | 58 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id, |
59 NUM_NTP_FOLLOW_ACTIONS); | 59 NUM_NTP_FOLLOW_ACTIONS); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 void SuggestionsHandler::RegisterMessages() { | 63 void SuggestionsHandler::RegisterMessages() { |
64 Profile* profile = Profile::FromWebUI(web_ui()); | 64 Profile* profile = Profile::FromWebUI(web_ui()); |
65 // Set up our sources for thumbnail and favicon data. | 65 // Set up our sources for thumbnail and favicon data. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { | 191 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { |
192 return base::MD5String(url); | 192 return base::MD5String(url); |
193 } | 193 } |
194 | 194 |
195 // static | 195 // static |
196 void SuggestionsHandler::RegisterProfilePrefs( | 196 void SuggestionsHandler::RegisterProfilePrefs( |
197 user_prefs::PrefRegistrySyncable* registry) { | 197 user_prefs::PrefRegistrySyncable* registry) { |
198 // TODO(georgey) add user preferences (such as own blacklist) as needed. | 198 // TODO(georgey) add user preferences (such as own blacklist) as needed. |
199 } | 199 } |
OLD | NEW |