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/ui/webui/most_visited_handler.h" | 5 #include "chrome/browser/ui/webui/most_visited_handler.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/md5.h" | 11 #include "base/md5.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/history/page_usage_data.h" | 19 #include "chrome/browser/history/page_usage_data.h" |
20 #include "chrome/browser/history/top_sites.h" | 20 #include "chrome/browser/history/top_sites.h" |
21 #include "chrome/browser/metrics/user_metrics.h" | 21 #include "chrome/browser/metrics/user_metrics.h" |
22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
23 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 25 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
26 #include "chrome/browser/ui/webui/favicon_source.h" | 26 #include "chrome/browser/ui/webui/favicon_source.h" |
27 #include "chrome/browser/ui/webui/new_tab_ui.h" | 27 #include "chrome/browser/ui/webui/new_tab_ui.h" |
28 #include "chrome/browser/ui/webui/thumbnail_source.h" | 28 #include "chrome/browser/ui/webui/thumbnail_source.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" |
30 #include "content/browser/browser_thread.h" | 31 #include "content/browser/browser_thread.h" |
31 #include "content/common/notification_source.h" | 32 #include "content/common/notification_source.h" |
32 #include "content/common/notification_type.h" | 33 #include "content/common/notification_type.h" |
33 #include "googleurl/src/gurl.h" | 34 #include "googleurl/src/gurl.h" |
34 #include "grit/chromium_strings.h" | 35 #include "grit/chromium_strings.h" |
35 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
36 #include "grit/locale_settings.h" | 37 #include "grit/locale_settings.h" |
37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
38 | 39 |
39 namespace { | 40 namespace { |
(...skipping 21 matching lines...) Expand all Loading... |
61 | 62 |
62 MostVisitedHandler::~MostVisitedHandler() { | 63 MostVisitedHandler::~MostVisitedHandler() { |
63 } | 64 } |
64 | 65 |
65 WebUIMessageHandler* MostVisitedHandler::Attach(WebUI* web_ui) { | 66 WebUIMessageHandler* MostVisitedHandler::Attach(WebUI* web_ui) { |
66 Profile* profile = web_ui->GetProfile(); | 67 Profile* profile = web_ui->GetProfile(); |
67 // Set up our sources for thumbnail and favicon data. | 68 // Set up our sources for thumbnail and favicon data. |
68 ThumbnailSource* thumbnail_src = new ThumbnailSource(profile); | 69 ThumbnailSource* thumbnail_src = new ThumbnailSource(profile); |
69 profile->GetChromeURLDataManager()->AddDataSource(thumbnail_src); | 70 profile->GetChromeURLDataManager()->AddDataSource(thumbnail_src); |
70 | 71 |
71 FaviconSource* favicon_src = new FaviconSource(profile); | 72 profile->GetChromeURLDataManager()->AddDataSource(new FaviconSource(profile)); |
72 profile->GetChromeURLDataManager()->AddDataSource(favicon_src); | |
73 | 73 |
74 // Get notifications when history is cleared. | 74 // Get notifications when history is cleared. |
75 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, | 75 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, |
76 Source<Profile>(profile)); | 76 Source<Profile>(profile)); |
77 | 77 |
78 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); | 78 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); |
79 | 79 |
80 // We pre-emptively make a fetch for the most visited pages so we have the | 80 // We pre-emptively make a fetch for the most visited pages so we have the |
81 // results sooner. | 81 // results sooner. |
82 StartQueryForMostVisited(); | 82 StartQueryForMostVisited(); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 380 |
381 // static | 381 // static |
382 std::vector<GURL> MostVisitedHandler::GetPrePopulatedUrls() { | 382 std::vector<GURL> MostVisitedHandler::GetPrePopulatedUrls() { |
383 const std::vector<MostVisitedPage> pages = | 383 const std::vector<MostVisitedPage> pages = |
384 MostVisitedHandler::GetPrePopulatedPages(); | 384 MostVisitedHandler::GetPrePopulatedPages(); |
385 std::vector<GURL> page_urls; | 385 std::vector<GURL> page_urls; |
386 for (size_t i = 0; i < pages.size(); ++i) | 386 for (size_t i = 0; i < pages.size(); ++i) |
387 page_urls.push_back(pages[i].url); | 387 page_urls.push_back(pages[i].url); |
388 return page_urls; | 388 return page_urls; |
389 } | 389 } |
OLD | NEW |