| 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 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_RECENTLY_CLOSED_TABS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_RECENTLY_CLOSED_TABS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_NTP_RECENTLY_CLOSED_TABS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_RECENTLY_CLOSED_TABS_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/sessions/tab_restore_service.h" | 9 #include "chrome/browser/sessions/tab_restore_service.h" |
| 10 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 10 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 virtual void RegisterMessages() OVERRIDE; | 22 virtual void RegisterMessages() OVERRIDE; |
| 23 | 23 |
| 24 // Callback for the "reopenTab" message. Rewrites the history of the | 24 // Callback for the "reopenTab" message. Rewrites the history of the |
| 25 // currently displayed tab to be the one in TabRestoreService with a | 25 // currently displayed tab to be the one in TabRestoreService with a |
| 26 // history of a session passed in through the content pointer. | 26 // history of a session passed in through the content pointer. |
| 27 void HandleReopenTab(const ListValue* args); | 27 void HandleReopenTab(const ListValue* args); |
| 28 | 28 |
| 29 // Callback for the "getRecentlyClosedTabs" message. | 29 // Callback for the "getRecentlyClosedTabs" message. |
| 30 void HandleGetRecentlyClosedTabs(const ListValue* args); | 30 void HandleGetRecentlyClosedTabs(const ListValue* args); |
| 31 | 31 |
| 32 // Callback for the "clearRecentlyClosed" message. |
| 33 void HandleClearRecentlyClosed(const ListValue* args); |
| 34 |
| 32 // Observer callback for TabRestoreServiceObserver. Sends data on | 35 // Observer callback for TabRestoreServiceObserver. Sends data on |
| 33 // recently closed tabs to the javascript side of this page to | 36 // recently closed tabs to the javascript side of this page to |
| 34 // display to the user. | 37 // display to the user. |
| 35 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; | 38 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; |
| 36 | 39 |
| 37 // Observer callback to notice when our associated TabRestoreService | 40 // Observer callback to notice when our associated TabRestoreService |
| 38 // is destroyed. | 41 // is destroyed. |
| 39 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; | 42 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; |
| 40 | 43 |
| 41 // Converts a list of TabRestoreService entries to the JSON format required | 44 // Converts a list of TabRestoreService entries to the JSON format required |
| 42 // by the NTP and adds them to the given list value. | 45 // by the NTP and adds them to the given list value. |
| 43 static void CreateRecentlyClosedValues( | 46 static void CreateRecentlyClosedValues( |
| 44 const TabRestoreService::Entries& entries, | 47 const TabRestoreService::Entries& entries, |
| 45 base::ListValue* entry_list_value); | 48 base::ListValue* entry_list_value); |
| 46 | 49 |
| 47 private: | 50 private: |
| 51 // Construct and initialize tab_restore_service_ if it's NULL. |
| 52 // tab_restore_service_ may still be NULL, however, in incognito mode. |
| 53 void EnsureTabRestoreService(); |
| 54 |
| 48 // TabRestoreService that we are observing. | 55 // TabRestoreService that we are observing. |
| 49 TabRestoreService* tab_restore_service_; | 56 TabRestoreService* tab_restore_service_; |
| 50 | 57 |
| 51 DISALLOW_COPY_AND_ASSIGN(RecentlyClosedTabsHandler); | 58 DISALLOW_COPY_AND_ASSIGN(RecentlyClosedTabsHandler); |
| 52 }; | 59 }; |
| 53 | 60 |
| 54 #endif // CHROME_BROWSER_UI_WEBUI_NTP_RECENTLY_CLOSED_TABS_HANDLER_H_ | 61 #endif // CHROME_BROWSER_UI_WEBUI_NTP_RECENTLY_CLOSED_TABS_HANDLER_H_ |
| OLD | NEW |