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/scoped_vector.h" | 12 #include "base/scoped_vector.h" |
13 #include "base/singleton.h" | 13 #include "base/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/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 24 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
25 #include "chrome/browser/ui/webui/favicon_source.h" | 25 #include "chrome/browser/ui/webui/favicon_source.h" |
26 #include "chrome/browser/ui/webui/new_tab_ui.h" | 26 #include "chrome/browser/ui/webui/new_tab_ui.h" |
27 #include "chrome/browser/ui/webui/thumbnail_source.h" | 27 #include "chrome/browser/ui/webui/thumbnail_source.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" |
29 #include "content/browser/browser_thread.h" | 30 #include "content/browser/browser_thread.h" |
30 #include "content/common/notification_source.h" | 31 #include "content/common/notification_source.h" |
31 #include "content/common/notification_type.h" | 32 #include "content/common/notification_type.h" |
32 #include "googleurl/src/gurl.h" | 33 #include "googleurl/src/gurl.h" |
33 #include "grit/chromium_strings.h" | 34 #include "grit/chromium_strings.h" |
34 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
35 #include "grit/locale_settings.h" | 36 #include "grit/locale_settings.h" |
36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
37 | 38 |
38 namespace { | 39 namespace { |
(...skipping 27 matching lines...) Expand all Loading... |
66 WebUIMessageHandler* MostVisitedHandler::Attach(WebUI* web_ui) { | 67 WebUIMessageHandler* MostVisitedHandler::Attach(WebUI* web_ui) { |
67 Profile* profile = web_ui->GetProfile(); | 68 Profile* profile = web_ui->GetProfile(); |
68 url_blacklist_ = profile->GetPrefs()->GetMutableDictionary( | 69 url_blacklist_ = profile->GetPrefs()->GetMutableDictionary( |
69 prefs::kNTPMostVisitedURLsBlacklist); | 70 prefs::kNTPMostVisitedURLsBlacklist); |
70 pinned_urls_ = profile->GetPrefs()->GetMutableDictionary( | 71 pinned_urls_ = profile->GetPrefs()->GetMutableDictionary( |
71 prefs::kNTPMostVisitedPinnedURLs); | 72 prefs::kNTPMostVisitedPinnedURLs); |
72 // Set up our sources for thumbnail and favicon data. | 73 // Set up our sources for thumbnail and favicon data. |
73 ThumbnailSource* thumbnail_src = new ThumbnailSource(profile); | 74 ThumbnailSource* thumbnail_src = new ThumbnailSource(profile); |
74 profile->GetChromeURLDataManager()->AddDataSource(thumbnail_src); | 75 profile->GetChromeURLDataManager()->AddDataSource(thumbnail_src); |
75 | 76 |
76 FaviconSource* favicon_src = new FaviconSource(profile); | 77 profile->GetChromeURLDataManager()->AddDataSource(new FaviconSource(profile)); |
77 profile->GetChromeURLDataManager()->AddDataSource(favicon_src); | |
78 | 78 |
79 // Get notifications when history is cleared. | 79 // Get notifications when history is cleared. |
80 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, | 80 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, |
81 Source<Profile>(profile)); | 81 Source<Profile>(profile)); |
82 | 82 |
83 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); | 83 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); |
84 | 84 |
85 // We pre-emptively make a fetch for the most visited pages so we have the | 85 // We pre-emptively make a fetch for the most visited pages so we have the |
86 // results sooner. | 86 // results sooner. |
87 StartQueryForMostVisited(); | 87 StartQueryForMostVisited(); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 // static | 379 // static |
380 std::vector<GURL> MostVisitedHandler::GetPrePopulatedUrls() { | 380 std::vector<GURL> MostVisitedHandler::GetPrePopulatedUrls() { |
381 const std::vector<MostVisitedPage> pages = | 381 const std::vector<MostVisitedPage> pages = |
382 MostVisitedHandler::GetPrePopulatedPages(); | 382 MostVisitedHandler::GetPrePopulatedPages(); |
383 std::vector<GURL> page_urls; | 383 std::vector<GURL> page_urls; |
384 for (size_t i = 0; i < pages.size(); ++i) | 384 for (size_t i = 0; i < pages.size(); ++i) |
385 page_urls.push_back(pages[i].url); | 385 page_urls.push_back(pages[i].url); |
386 return page_urls; | 386 return page_urls; |
387 } | 387 } |
OLD | NEW |