| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ANDROID_TAB_MODEL_TAB_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_H_ | 6 #define CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/ui/android/tab_model/android_live_tab_context.h" |
| 11 #include "components/sessions/core/session_id.h" | 12 #include "components/sessions/core/session_id.h" |
| 12 #include "components/sync_sessions/synced_window_delegate.h" | 13 #include "components/sync_sessions/synced_window_delegate.h" |
| 13 #include "components/toolbar/toolbar_model.h" | 14 #include "components/toolbar/toolbar_model.h" |
| 14 #include "components/toolbar/toolbar_model_delegate.h" | 15 #include "components/toolbar/toolbar_model_delegate.h" |
| 15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 17 | 18 |
| 18 namespace browser_sync { | 19 namespace browser_sync { |
| 19 class SyncedWindowDelegate; | 20 class SyncedWindowDelegate; |
| 20 class SyncedWindowDelegateAndroid; | 21 class SyncedWindowDelegateAndroid; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 class WebContents; | 25 class WebContents; |
| 25 } | 26 } |
| 26 | 27 |
| 27 class Profile; | 28 class Profile; |
| 28 class TabAndroid; | 29 class TabAndroid; |
| 29 | 30 |
| 30 // Abstract representation of a Tab Model for Android. Since Android does | 31 // Abstract representation of a Tab Model for Android. Since Android does |
| 31 // not use Browser/BrowserList, this is required to allow Chrome to interact | 32 // not use Browser/BrowserList, this is required to allow Chrome to interact |
| 32 // with Android's Tabs and Tab Model. | 33 // with Android's Tabs and Tab Model. |
| 33 class TabModel : public content::NotificationObserver { | 34 class TabModel : public content::NotificationObserver { |
| 34 public: | 35 public: |
| 35 virtual Profile* GetProfile() const; | 36 virtual Profile* GetProfile() const; |
| 36 virtual bool IsOffTheRecord() const; | 37 virtual bool IsOffTheRecord() const; |
| 37 virtual browser_sync::SyncedWindowDelegate* GetSyncedWindowDelegate() const; | 38 virtual browser_sync::SyncedWindowDelegate* GetSyncedWindowDelegate() const; |
| 38 virtual SessionID::id_type GetSessionId() const; | 39 virtual SessionID::id_type GetSessionId() const; |
| 40 virtual const SessionID& SessionId() const; |
| 41 virtual sessions::LiveTabContext* GetLiveTabContext() const; |
| 39 | 42 |
| 40 virtual int GetTabCount() const = 0; | 43 virtual int GetTabCount() const = 0; |
| 41 virtual int GetActiveIndex() const = 0; | 44 virtual int GetActiveIndex() const = 0; |
| 42 virtual content::WebContents* GetActiveWebContents() const; | 45 virtual content::WebContents* GetActiveWebContents() const; |
| 43 virtual content::WebContents* GetWebContentsAt(int index) const = 0; | 46 virtual content::WebContents* GetWebContentsAt(int index) const = 0; |
| 44 // This will return NULL if the tab has not yet been initialized. | 47 // This will return NULL if the tab has not yet been initialized. |
| 45 virtual TabAndroid* GetTabAt(int index) const = 0; | 48 virtual TabAndroid* GetTabAt(int index) const = 0; |
| 46 | 49 |
| 47 virtual void SetActiveIndex(int index) = 0; | 50 virtual void SetActiveIndex(int index) = 0; |
| 48 virtual void CloseTabAt(int index) = 0; | 51 virtual void CloseTabAt(int index) = 0; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 | 74 |
| 72 private: | 75 private: |
| 73 // Determines how TabModel will interact with the profile. | 76 // Determines how TabModel will interact with the profile. |
| 74 void Observe(int type, | 77 void Observe(int type, |
| 75 const content::NotificationSource& source, | 78 const content::NotificationSource& source, |
| 76 const content::NotificationDetails& details) override; | 79 const content::NotificationDetails& details) override; |
| 77 | 80 |
| 78 // The profile associated with this TabModel. | 81 // The profile associated with this TabModel. |
| 79 Profile* profile_; | 82 Profile* profile_; |
| 80 | 83 |
| 84 // The LiveTabContext associated with TabModel. |
| 85 // Used to restore closed tabs through the TabRestoreService. |
| 86 std::unique_ptr<AndroidLiveTabContext> live_tab_context_; |
| 87 |
| 81 // Describes if this TabModel contains an off-the-record profile. | 88 // Describes if this TabModel contains an off-the-record profile. |
| 82 bool is_off_the_record_; | 89 bool is_off_the_record_; |
| 83 | 90 |
| 84 // The SyncedWindowDelegate associated with this TabModel. | 91 // The SyncedWindowDelegate associated with this TabModel. |
| 85 std::unique_ptr<browser_sync::SyncedWindowDelegateAndroid> | 92 std::unique_ptr<browser_sync::SyncedWindowDelegateAndroid> |
| 86 synced_window_delegate_; | 93 synced_window_delegate_; |
| 87 | 94 |
| 88 // Unique identifier of this TabModel for session restore. This id is only | 95 // Unique identifier of this TabModel for session restore. This id is only |
| 89 // unique within the current session, and is not guaranteed to be unique | 96 // unique within the current session, and is not guaranteed to be unique |
| 90 // across sessions. | 97 // across sessions. |
| 91 SessionID session_id_; | 98 SessionID session_id_; |
| 92 | 99 |
| 93 // The Registrar used to register TabModel for notifications. | 100 // The Registrar used to register TabModel for notifications. |
| 94 content::NotificationRegistrar registrar_; | 101 content::NotificationRegistrar registrar_; |
| 95 | 102 |
| 96 DISALLOW_COPY_AND_ASSIGN(TabModel); | 103 DISALLOW_COPY_AND_ASSIGN(TabModel); |
| 97 }; | 104 }; |
| 98 | 105 |
| 99 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_H_ | 106 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_H_ |
| OLD | NEW |