| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_DOM_UI_FOREIGN_SESSION_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_DOM_UI_FOREIGN_SESSION_HANDLER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <map> | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "chrome/browser/dom_ui/dom_ui.h" | |
| 14 #include "chrome/browser/sessions/session_service.h" | |
| 15 #include "chrome/browser/sync/glue/session_model_associator.h" | |
| 16 #include "chrome/common/notification_observer.h" | |
| 17 #include "chrome/common/notification_registrar.h" | |
| 18 | |
| 19 namespace browser_sync { | |
| 20 | |
| 21 class ForeignSessionHandler : public DOMMessageHandler, | |
| 22 public NotificationObserver { | |
| 23 public: | |
| 24 // DOMMessageHandler implementation. | |
| 25 virtual void RegisterMessages(); | |
| 26 | |
| 27 ForeignSessionHandler(); | |
| 28 virtual ~ForeignSessionHandler() {} | |
| 29 | |
| 30 private: | |
| 31 // Used to register ForeignSessionHandler for notifications. | |
| 32 void Init(); | |
| 33 | |
| 34 // Determines how ForeignSessionHandler will interact with the new tab page. | |
| 35 void Observe(NotificationType type, const NotificationSource& source, | |
| 36 const NotificationDetails& details); | |
| 37 | |
| 38 // Returns a pointer to the current session model associator or NULL. | |
| 39 SessionModelAssociator* GetModelAssociator(); | |
| 40 | |
| 41 // Determines whether foreign sessions should be obtained from the sync model. | |
| 42 // This is a javascript callback handler, and it is also called when the sync | |
| 43 // model has changed and the new tab page needs to reflect the changes. | |
| 44 void HandleGetForeignSessions(const Value* content); | |
| 45 | |
| 46 // Helper for reopening a foreign session in a new browser window. | |
| 47 void OpenForeignSession(SessionModelAssociator* associator, int64 id); | |
| 48 | |
| 49 // Helper for listing the foreign sessions on the new tab page. | |
| 50 void GetForeignSessions(SessionModelAssociator* associator); | |
| 51 | |
| 52 // Determines which session is to be opened, and then calls | |
| 53 // OpenForeignSession, to begin the process of opening a new browser window. | |
| 54 // This is a javascript callback handler. | |
| 55 void HandleReopenForeignSession(const Value* content); | |
| 56 | |
| 57 // The Registrar used to register ForeignSessionHandler for notifications. | |
| 58 NotificationRegistrar registrar_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(ForeignSessionHandler); | |
| 61 }; | |
| 62 | |
| 63 } // namespace browser_sync | |
| 64 | |
| 65 #endif // CHROME_BROWSER_DOM_UI_FOREIGN_SESSION_HANDLER_H_ | |
| 66 | |
| OLD | NEW |