| 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 |
| 28 namespace sessiosn { |
| 29 class LiveTabContext; |
| 30 } |
| 31 |
| 27 class Profile; | 32 class Profile; |
| 28 class TabAndroid; | 33 class TabAndroid; |
| 29 | 34 |
| 30 // Abstract representation of a Tab Model for Android. Since Android does | 35 // Abstract representation of a Tab Model for Android. Since Android does |
| 31 // not use Browser/BrowserList, this is required to allow Chrome to interact | 36 // not use Browser/BrowserList, this is required to allow Chrome to interact |
| 32 // with Android's Tabs and Tab Model. | 37 // with Android's Tabs and Tab Model. |
| 33 class TabModel : public content::NotificationObserver { | 38 class TabModel : public content::NotificationObserver { |
| 34 public: | 39 public: |
| 35 virtual Profile* GetProfile() const; | 40 virtual Profile* GetProfile() const; |
| 36 virtual bool IsOffTheRecord() const; | 41 virtual bool IsOffTheRecord() const; |
| 37 virtual browser_sync::SyncedWindowDelegate* GetSyncedWindowDelegate() const; | 42 virtual browser_sync::SyncedWindowDelegate* GetSyncedWindowDelegate() const; |
| 38 virtual SessionID::id_type GetSessionId() const; | 43 virtual SessionID::id_type GetSessionId() const; |
| 44 virtual const SessionID& SessionId() const; |
| 45 virtual sessions::LiveTabContext* GetLiveTabContext() const; |
| 39 | 46 |
| 40 virtual int GetTabCount() const = 0; | 47 virtual int GetTabCount() const = 0; |
| 41 virtual int GetActiveIndex() const = 0; | 48 virtual int GetActiveIndex() const = 0; |
| 42 virtual content::WebContents* GetActiveWebContents() const; | 49 virtual content::WebContents* GetActiveWebContents() const; |
| 43 virtual content::WebContents* GetWebContentsAt(int index) const = 0; | 50 virtual content::WebContents* GetWebContentsAt(int index) const = 0; |
| 44 // This will return NULL if the tab has not yet been initialized. | 51 // This will return NULL if the tab has not yet been initialized. |
| 45 virtual TabAndroid* GetTabAt(int index) const = 0; | 52 virtual TabAndroid* GetTabAt(int index) const = 0; |
| 46 | 53 |
| 47 virtual void SetActiveIndex(int index) = 0; | 54 virtual void SetActiveIndex(int index) = 0; |
| 48 virtual void CloseTabAt(int index) = 0; | 55 virtual void CloseTabAt(int index) = 0; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 | 78 |
| 72 private: | 79 private: |
| 73 // Determines how TabModel will interact with the profile. | 80 // Determines how TabModel will interact with the profile. |
| 74 void Observe(int type, | 81 void Observe(int type, |
| 75 const content::NotificationSource& source, | 82 const content::NotificationSource& source, |
| 76 const content::NotificationDetails& details) override; | 83 const content::NotificationDetails& details) override; |
| 77 | 84 |
| 78 // The profile associated with this TabModel. | 85 // The profile associated with this TabModel. |
| 79 Profile* profile_; | 86 Profile* profile_; |
| 80 | 87 |
| 88 // The LiveTabContext associated with TabModel. |
| 89 // Used when we access the tab restore service and write the correct |
| 90 // window id data into TabRestoreService::Entry. |
| 91 std::unique_ptr<AndroidLiveTabContext> live_tab_context_; |
| 92 |
| 81 // Describes if this TabModel contains an off-the-record profile. | 93 // Describes if this TabModel contains an off-the-record profile. |
| 82 bool is_off_the_record_; | 94 bool is_off_the_record_; |
| 83 | 95 |
| 84 // The SyncedWindowDelegate associated with this TabModel. | 96 // The SyncedWindowDelegate associated with this TabModel. |
| 85 std::unique_ptr<browser_sync::SyncedWindowDelegateAndroid> | 97 std::unique_ptr<browser_sync::SyncedWindowDelegateAndroid> |
| 86 synced_window_delegate_; | 98 synced_window_delegate_; |
| 87 | 99 |
| 88 // Unique identifier of this TabModel for session restore. This id is only | 100 // 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 | 101 // unique within the current session, and is not guaranteed to be unique |
| 90 // across sessions. | 102 // across sessions. |
| 91 SessionID session_id_; | 103 SessionID session_id_; |
| 92 | 104 |
| 93 // The Registrar used to register TabModel for notifications. | 105 // The Registrar used to register TabModel for notifications. |
| 94 content::NotificationRegistrar registrar_; | 106 content::NotificationRegistrar registrar_; |
| 95 | 107 |
| 96 DISALLOW_COPY_AND_ASSIGN(TabModel); | 108 DISALLOW_COPY_AND_ASSIGN(TabModel); |
| 97 }; | 109 }; |
| 98 | 110 |
| 99 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_H_ | 111 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_H_ |
| OLD | NEW |