OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/task/cancelable_task_tracker.h" | 17 #include "base/task/cancelable_task_tracker.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "components/history/core/browser/history_service_observer.h" | 20 #include "components/history/core/browser/history_service_observer.h" |
21 #include "components/history/core/browser/url_row.h" | 21 #include "components/history/core/browser/url_row.h" |
22 #include "components/history/core/browser/web_history_service.h" | 22 #include "components/history/core/browser/web_history_service.h" |
23 #include "components/history/core/browser/web_history_service_observer.h" | 23 #include "components/history/core/browser/web_history_service_observer.h" |
24 #include "components/sync/driver/sync_service_observer.h" | 24 #include "components/sync/driver/sync_service_observer.h" |
25 #include "content/public/browser/web_ui_message_handler.h" | 25 #include "content/public/browser/web_ui_message_handler.h" |
26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
27 | 27 |
28 class ProfileSyncService; | |
29 class SupervisedUserService; | 28 class SupervisedUserService; |
30 | 29 |
31 namespace bookmarks { | 30 namespace bookmarks { |
32 class BookmarkModel; | 31 class BookmarkModel; |
33 } | 32 } // namespace bookmarks |
| 33 |
| 34 namespace browser_sync { |
| 35 class ProfileSyncService; |
| 36 } // namespace browser_sync |
34 | 37 |
35 namespace history { | 38 namespace history { |
36 class HistoryService; | 39 class HistoryService; |
| 40 class QueryResults; |
37 struct QueryOptions; | 41 struct QueryOptions; |
38 class QueryResults; | 42 } // namespace history |
39 } | |
40 | 43 |
41 namespace sync_driver { | 44 namespace sync_driver { |
42 class SyncServiceObserver; | 45 class SyncServiceObserver; |
43 } | 46 } // namespace sync_driver |
44 | 47 |
45 // The handler for Javascript messages related to the "history" view. | 48 // The handler for Javascript messages related to the "history" view. |
46 class BrowsingHistoryHandler : public content::WebUIMessageHandler, | 49 class BrowsingHistoryHandler : public content::WebUIMessageHandler, |
47 public history::HistoryServiceObserver, | 50 public history::HistoryServiceObserver, |
48 public history::WebHistoryServiceObserver, | 51 public history::WebHistoryServiceObserver, |
49 public sync_driver::SyncServiceObserver { | 52 public sync_driver::SyncServiceObserver { |
50 public: | 53 public: |
51 // Represents a history entry to be shown to the user, representing either | 54 // Represents a history entry to be shown to the user, representing either |
52 // a local or remote visit. A single entry can represent multiple visits, | 55 // a local or remote visit. A single entry can represent multiple visits, |
53 // since only the most recent visit on a particular day is shown. | 56 // since only the most recent visit on a particular day is shown. |
(...skipping 16 matching lines...) Expand all Loading... |
70 virtual ~HistoryEntry(); | 73 virtual ~HistoryEntry(); |
71 | 74 |
72 // Formats this entry's URL and title and adds them to |result|. | 75 // Formats this entry's URL and title and adds them to |result|. |
73 void SetUrlAndTitle(base::DictionaryValue* result, | 76 void SetUrlAndTitle(base::DictionaryValue* result, |
74 bool limit_title_length) const; | 77 bool limit_title_length) const; |
75 | 78 |
76 // Converts the entry to a DictionaryValue to be owned by the caller. | 79 // Converts the entry to a DictionaryValue to be owned by the caller. |
77 std::unique_ptr<base::DictionaryValue> ToValue( | 80 std::unique_ptr<base::DictionaryValue> ToValue( |
78 bookmarks::BookmarkModel* bookmark_model, | 81 bookmarks::BookmarkModel* bookmark_model, |
79 SupervisedUserService* supervised_user_service, | 82 SupervisedUserService* supervised_user_service, |
80 const ProfileSyncService* sync_service, | 83 const browser_sync::ProfileSyncService* sync_service, |
81 bool limit_title_length) const; | 84 bool limit_title_length) const; |
82 | 85 |
83 // Comparison function for sorting HistoryEntries from newest to oldest. | 86 // Comparison function for sorting HistoryEntries from newest to oldest. |
84 static bool SortByTimeDescending( | 87 static bool SortByTimeDescending( |
85 const HistoryEntry& entry1, const HistoryEntry& entry2); | 88 const HistoryEntry& entry1, const HistoryEntry& entry2); |
86 | 89 |
87 // The type of visits this entry represents: local, remote, or both. | 90 // The type of visits this entry represents: local, remote, or both. |
88 EntryType entry_type; | 91 EntryType entry_type; |
89 | 92 |
90 GURL url; | 93 GURL url; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 240 |
238 // HistoryService (local history) observer. | 241 // HistoryService (local history) observer. |
239 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 242 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
240 history_service_observer_; | 243 history_service_observer_; |
241 | 244 |
242 // WebHistoryService (synced history) observer. | 245 // WebHistoryService (synced history) observer. |
243 ScopedObserver<history::WebHistoryService, history::WebHistoryServiceObserver> | 246 ScopedObserver<history::WebHistoryService, history::WebHistoryServiceObserver> |
244 web_history_service_observer_; | 247 web_history_service_observer_; |
245 | 248 |
246 // ProfileSyncService observer listens to late initialization of history sync. | 249 // ProfileSyncService observer listens to late initialization of history sync. |
247 ScopedObserver<ProfileSyncService, sync_driver::SyncServiceObserver> | 250 ScopedObserver<browser_sync::ProfileSyncService, |
| 251 sync_driver::SyncServiceObserver> |
248 sync_service_observer_; | 252 sync_service_observer_; |
249 | 253 |
250 // Whether the last call to Web History returned synced results. | 254 // Whether the last call to Web History returned synced results. |
251 bool has_synced_results_; | 255 bool has_synced_results_; |
252 | 256 |
253 // Whether there are other forms of browsing history on the history server. | 257 // Whether there are other forms of browsing history on the history server. |
254 bool has_other_forms_of_browsing_history_; | 258 bool has_other_forms_of_browsing_history_; |
255 | 259 |
256 base::WeakPtrFactory<BrowsingHistoryHandler> weak_factory_; | 260 base::WeakPtrFactory<BrowsingHistoryHandler> weak_factory_; |
257 | 261 |
258 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); | 262 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); |
259 }; | 263 }; |
260 | 264 |
261 #endif // CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ | 265 #endif // CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ |
OLD | NEW |