| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_DOM_UI_MOST_VISITED_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_MOST_VISITED_HANDLER_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_MOST_VISITED_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_MOST_VISITED_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Returns a vector containing the urls for the prepopulated pages. | 66 // Returns a vector containing the urls for the prepopulated pages. |
| 67 // Used only in testing. | 67 // Used only in testing. |
| 68 static std::vector<GURL> GetPrePopulatedUrls(); | 68 static std::vector<GURL> GetPrePopulatedUrls(); |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 struct MostVisitedPage; | 71 struct MostVisitedPage; |
| 72 | 72 |
| 73 // Send a request to the HistoryService to get the most visited pages. | 73 // Send a request to the HistoryService to get the most visited pages. |
| 74 void StartQueryForMostVisited(); | 74 void StartQueryForMostVisited(); |
| 75 | 75 |
| 76 // Callback from the history system when the most visited list is available. | |
| 77 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, | |
| 78 std::vector<PageUsageData*>* data); | |
| 79 | |
| 80 // Sets pages_value_ from a vector of URLs. | |
| 81 void SetPagesValue(std::vector<PageUsageData*>* data); | |
| 82 | |
| 83 // Sets pages_value_ from a format produced by TopSites. | 76 // Sets pages_value_ from a format produced by TopSites. |
| 84 void SetPagesValueFromTopSites(const history::MostVisitedURLList& data); | 77 void SetPagesValueFromTopSites(const history::MostVisitedURLList& data); |
| 85 | 78 |
| 86 // Callback for TopSites. | 79 // Callback for TopSites. |
| 87 void OnMostVisitedURLsAvailable(const history::MostVisitedURLList& data); | 80 void OnMostVisitedURLsAvailable(const history::MostVisitedURLList& data); |
| 88 | 81 |
| 89 // Puts the passed URL in the blacklist (so it does not show as a thumbnail). | 82 // Puts the passed URL in the blacklist (so it does not show as a thumbnail). |
| 90 void BlacklistURL(const GURL& url); | 83 void BlacklistURL(const GURL& url); |
| 91 | 84 |
| 92 // Returns the key used in url_blacklist_ and pinned_urls_ for the passed | 85 // Returns the key used in url_blacklist_ and pinned_urls_ for the passed |
| 93 // |url|. | 86 // |url|. |
| 94 std::string GetDictionaryKeyForURL(const std::string& url); | 87 std::string GetDictionaryKeyForURL(const std::string& url); |
| 95 | 88 |
| 96 // Gets the page data for a pinned URL at a given index. This returns | 89 // Gets the page data for a pinned URL at a given index. This returns |
| 97 // true if found. | 90 // true if found. |
| 98 bool GetPinnedURLAtIndex(int index, MostVisitedPage* page); | 91 bool GetPinnedURLAtIndex(int index, MostVisitedPage* page); |
| 99 | 92 |
| 100 void AddPinnedURL(const MostVisitedPage& page, int index); | 93 void AddPinnedURL(const MostVisitedPage& page, int index); |
| 101 void RemovePinnedURL(const GURL& url); | 94 void RemovePinnedURL(const GURL& url); |
| 102 | 95 |
| 103 // Sends pages_value_ to the javascript side to and resets page_value_. | 96 // Sends pages_value_ to the javascript side to and resets page_value_. |
| 104 void SendPagesValue(); | 97 void SendPagesValue(); |
| 105 | 98 |
| 106 // Returns true if we should treat this as the first run of the new tab page. | 99 // Returns true if we should treat this as the first run of the new tab page. |
| 107 bool IsFirstRun(); | 100 bool IsFirstRun(); |
| 108 | 101 |
| 109 // Adds the fields in the page to the dictionary. | |
| 110 static void SetMostVisistedPage( | |
| 111 DictionaryValue* dict, | |
| 112 const MostVisitedHandler::MostVisitedPage& page); | |
| 113 | |
| 114 static const std::vector<MostVisitedPage>& GetPrePopulatedPages(); | 102 static const std::vector<MostVisitedPage>& GetPrePopulatedPages(); |
| 115 | 103 |
| 116 NotificationRegistrar registrar_; | 104 NotificationRegistrar registrar_; |
| 117 | 105 |
| 118 // Our consumer for the history service. | 106 // Our consumer for the history service. |
| 119 CancelableRequestConsumerTSimple<PageUsageData*> cancelable_consumer_; | 107 CancelableRequestConsumerTSimple<PageUsageData*> cancelable_consumer_; |
| 120 CancelableRequestConsumer topsites_consumer_; | 108 CancelableRequestConsumer topsites_consumer_; |
| 121 | 109 |
| 122 // The most visited URLs, in priority order. | 110 // The most visited URLs, in priority order. |
| 123 // Only used for matching up clicks on the page to which most visited entry | 111 // Only used for matching up clicks on the page to which most visited entry |
| (...skipping 15 matching lines...) Expand all Loading... |
| 139 // we get the first getMostVisited() call. | 127 // we get the first getMostVisited() call. |
| 140 bool got_first_most_visited_request_; | 128 bool got_first_most_visited_request_; |
| 141 | 129 |
| 142 // Keep the results of the db query here. | 130 // Keep the results of the db query here. |
| 143 scoped_ptr<ListValue> pages_value_; | 131 scoped_ptr<ListValue> pages_value_; |
| 144 | 132 |
| 145 DISALLOW_COPY_AND_ASSIGN(MostVisitedHandler); | 133 DISALLOW_COPY_AND_ASSIGN(MostVisitedHandler); |
| 146 }; | 134 }; |
| 147 | 135 |
| 148 #endif // CHROME_BROWSER_DOM_UI_MOST_VISITED_HANDLER_H_ | 136 #endif // CHROME_BROWSER_DOM_UI_MOST_VISITED_HANDLER_H_ |
| OLD | NEW |