local_session_event_router.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SYNC_SESSIONS_LOCAL_SESSION_EVENT_ROUTER_H_
  5. #define COMPONENTS_SYNC_SESSIONS_LOCAL_SESSION_EVENT_ROUTER_H_
  6. #include "url/gurl.h"
  7. namespace sync_sessions {
  8. class SyncedTabDelegate;
  9. // An interface defining the ways in which local open tab events can interact
  10. // with session sync. All local tab events flow to sync via this interface.
  11. // In that way it is analogous to sync changes flowing to the local model
  12. // via ProcessSyncChanges, just with a more granular breakdown.
  13. class LocalSessionEventHandler {
  14. public:
  15. LocalSessionEventHandler(const LocalSessionEventHandler&) = delete;
  16. LocalSessionEventHandler& operator=(const LocalSessionEventHandler&) = delete;
  17. virtual ~LocalSessionEventHandler() {}
  18. // Called when asynchronous session restore has completed. On Android, this
  19. // can be called multiple times (e.g. transition from a CCT without tabbed
  20. // window to actually starting a tabbed activity).
  21. virtual void OnSessionRestoreComplete() = 0;
  22. // A local navigation event took place that affects the synced session
  23. // for this instance of Chrome.
  24. virtual void OnLocalTabModified(SyncedTabDelegate* modified_tab) = 0;
  25. protected:
  26. LocalSessionEventHandler() {}
  27. };
  28. // The LocalSessionEventRouter is responsible for hooking itself up to various
  29. // notification sources in the browser process and forwarding relevant
  30. // events to a handler as defined in the LocalSessionEventHandler contract.
  31. class LocalSessionEventRouter {
  32. public:
  33. LocalSessionEventRouter(const LocalSessionEventRouter&) = delete;
  34. LocalSessionEventRouter& operator=(const LocalSessionEventRouter&) = delete;
  35. virtual ~LocalSessionEventRouter() {}
  36. virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0;
  37. virtual void Stop() = 0;
  38. protected:
  39. LocalSessionEventRouter() {}
  40. };
  41. } // namespace sync_sessions
  42. #endif // COMPONENTS_SYNC_SESSIONS_LOCAL_SESSION_EVENT_ROUTER_H_