| 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_TABS_TAB_STRIP_MODEL_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_OBSERVER_H_ | 6 #define CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_OBSERVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 class TabContents; | 9 class TabContents; |
| 10 typedef TabContents TabContentsWrapper; | |
| 11 class TabStripModel; | 10 class TabStripModel; |
| 12 class TabStripSelectionModel; | 11 class TabStripSelectionModel; |
| 13 | 12 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 13 //////////////////////////////////////////////////////////////////////////////// |
| 15 // | 14 // |
| 16 // TabStripModelObserver | 15 // TabStripModelObserver |
| 17 // | 16 // |
| 18 // Objects implement this interface when they wish to be notified of changes | 17 // Objects implement this interface when they wish to be notified of changes |
| 19 // to the TabStripModel. | 18 // to the TabStripModel. |
| 20 // | 19 // |
| (...skipping 12 matching lines...) Expand all Loading... |
| 33 // Only the loading state changed. | 32 // Only the loading state changed. |
| 34 LOADING_ONLY, | 33 LOADING_ONLY, |
| 35 | 34 |
| 36 // Only the title changed and page isn't loading. | 35 // Only the title changed and page isn't loading. |
| 37 TITLE_NOT_LOADING, | 36 TITLE_NOT_LOADING, |
| 38 | 37 |
| 39 // Change not characterized by LOADING_ONLY or TITLE_NOT_LOADING. | 38 // Change not characterized by LOADING_ONLY or TITLE_NOT_LOADING. |
| 40 ALL | 39 ALL |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 // A new TabContentsWrapper was inserted into the TabStripModel at the | 42 // A new TabContents was inserted into the TabStripModel at the |
| 44 // specified index. |foreground| is whether or not it was opened in the | 43 // specified index. |foreground| is whether or not it was opened in the |
| 45 // foreground (selected). | 44 // foreground (selected). |
| 46 virtual void TabInsertedAt(TabContentsWrapper* contents, | 45 virtual void TabInsertedAt(TabContents* contents, |
| 47 int index, | 46 int index, |
| 48 bool foreground); | 47 bool foreground); |
| 49 | 48 |
| 50 // The specified TabContentsWrapper at |index| is being closed (and eventually | 49 // The specified TabContents at |index| is being closed (and eventually |
| 51 // destroyed). |tab_strip_model| is the TabStripModel the tab was part of. | 50 // destroyed). |tab_strip_model| is the TabStripModel the tab was part of. |
| 52 virtual void TabClosingAt(TabStripModel* tab_strip_model, | 51 virtual void TabClosingAt(TabStripModel* tab_strip_model, |
| 53 TabContentsWrapper* contents, | 52 TabContents* contents, |
| 54 int index); | 53 int index); |
| 55 | 54 |
| 56 // The specified TabContentsWrapper at |index| is being detached, perhaps to | 55 // The specified TabContents at |index| is being detached, perhaps to |
| 57 // be inserted in another TabStripModel. The implementer should take whatever | 56 // be inserted in another TabStripModel. The implementer should take whatever |
| 58 // action is necessary to deal with the TabContentsWrapper no longer being | 57 // action is necessary to deal with the TabContents no longer being |
| 59 // present. | 58 // present. |
| 60 virtual void TabDetachedAt(TabContentsWrapper* contents, int index); | 59 virtual void TabDetachedAt(TabContents* contents, int index); |
| 61 | 60 |
| 62 // The active TabContentsWrapper is about to change from |old_contents|. | 61 // The active TabContents is about to change from |old_contents|. |
| 63 // This gives observers a chance to prepare for an impending switch before it | 62 // This gives observers a chance to prepare for an impending switch before it |
| 64 // happens. | 63 // happens. |
| 65 virtual void TabDeactivated(TabContentsWrapper* contents); | 64 virtual void TabDeactivated(TabContents* contents); |
| 66 | 65 |
| 67 // Sent when the active tab changes. The previously active tab is identified | 66 // Sent when the active tab changes. The previously active tab is identified |
| 68 // by |old_contents| and the newly active tab by |new_contents|. |index| is | 67 // by |old_contents| and the newly active tab by |new_contents|. |index| is |
| 69 // the index of |new_contents|. |user_gesture| specifies whether or not this | 68 // the index of |new_contents|. |user_gesture| specifies whether or not this |
| 70 // was done by a user input event (e.g. clicking on a tab, keystroke) or as a | 69 // was done by a user input event (e.g. clicking on a tab, keystroke) or as a |
| 71 // side-effect of some other function. | 70 // side-effect of some other function. |
| 72 // Note: It is possible for the selection to change while the active tab | 71 // Note: It is possible for the selection to change while the active tab |
| 73 // remains unchanged. For example, control-click may not change the active tab | 72 // remains unchanged. For example, control-click may not change the active tab |
| 74 // but does change the selection. In this case |ActiveTabChanged| is not sent. | 73 // but does change the selection. In this case |ActiveTabChanged| is not sent. |
| 75 // If you care about any changes to the selection, override | 74 // If you care about any changes to the selection, override |
| 76 // TabSelectionChanged. | 75 // TabSelectionChanged. |
| 77 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 76 virtual void ActiveTabChanged(TabContents* old_contents, |
| 78 TabContentsWrapper* new_contents, | 77 TabContents* new_contents, |
| 79 int index, | 78 int index, |
| 80 bool user_gesture); | 79 bool user_gesture); |
| 81 | 80 |
| 82 // Sent when the selection changes in |tab_strip_model|. More precisely when | 81 // Sent when the selection changes in |tab_strip_model|. More precisely when |
| 83 // selected tabs, anchor tab or active tab change. |old_model| is a snapshot | 82 // selected tabs, anchor tab or active tab change. |old_model| is a snapshot |
| 84 // of the selection model before the change. See also ActiveTabChanged for | 83 // of the selection model before the change. See also ActiveTabChanged for |
| 85 // details. | 84 // details. |
| 86 virtual void TabSelectionChanged(TabStripModel* tab_strip_model, | 85 virtual void TabSelectionChanged(TabStripModel* tab_strip_model, |
| 87 const TabStripSelectionModel& old_model); | 86 const TabStripSelectionModel& old_model); |
| 88 | 87 |
| 89 // The specified TabContentsWrapper at |from_index| was moved to |to_index|. | 88 // The specified TabContents at |from_index| was moved to |to_index|. |
| 90 virtual void TabMoved(TabContentsWrapper* contents, | 89 virtual void TabMoved(TabContents* contents, |
| 91 int from_index, | 90 int from_index, |
| 92 int to_index); | 91 int to_index); |
| 93 | 92 |
| 94 // The specified TabContentsWrapper at |index| changed in some way. |contents| | 93 // The specified TabContents at |index| changed in some way. |contents| |
| 95 // may be an entirely different object and the old value is no longer | 94 // may be an entirely different object and the old value is no longer |
| 96 // available by the time this message is delivered. | 95 // available by the time this message is delivered. |
| 97 // | 96 // |
| 98 // See TabChangeType for a description of |change_type|. | 97 // See TabChangeType for a description of |change_type|. |
| 99 virtual void TabChangedAt(TabContentsWrapper* contents, | 98 virtual void TabChangedAt(TabContents* contents, |
| 100 int index, | 99 int index, |
| 101 TabChangeType change_type); | 100 TabChangeType change_type); |
| 102 | 101 |
| 103 // The tab contents was replaced at the specified index. This is invoked | 102 // The tab contents was replaced at the specified index. This is invoked |
| 104 // when instant is enabled and the user navigates by way of instant or when | 103 // when instant is enabled and the user navigates by way of instant or when |
| 105 // prerendering swaps in a prerendered TabContentsWrapper. | 104 // prerendering swaps in a prerendered TabContents. |
| 106 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 105 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
| 107 TabContentsWrapper* old_contents, | 106 TabContents* old_contents, |
| 108 TabContentsWrapper* new_contents, | 107 TabContents* new_contents, |
| 109 int index); | 108 int index); |
| 110 | 109 |
| 111 // Invoked when the pinned state of a tab changes. See note in | 110 // Invoked when the pinned state of a tab changes. See note in |
| 112 // TabMiniStateChanged as to how this relates to TabMiniStateChanged. | 111 // TabMiniStateChanged as to how this relates to TabMiniStateChanged. |
| 113 virtual void TabPinnedStateChanged(TabContentsWrapper* contents, int index); | 112 virtual void TabPinnedStateChanged(TabContents* contents, int index); |
| 114 | 113 |
| 115 // Invoked if the mini state of a tab changes. | 114 // Invoked if the mini state of a tab changes. |
| 116 // NOTE: this is sent when the pinned state of a non-app tab changes and is | 115 // NOTE: this is sent when the pinned state of a non-app tab changes and is |
| 117 // sent in addition to TabPinnedStateChanged. UI code typically need not care | 116 // sent in addition to TabPinnedStateChanged. UI code typically need not care |
| 118 // about TabPinnedStateChanged, but instead this. | 117 // about TabPinnedStateChanged, but instead this. |
| 119 virtual void TabMiniStateChanged(TabContentsWrapper* contents, int index); | 118 virtual void TabMiniStateChanged(TabContents* contents, int index); |
| 120 | 119 |
| 121 // Invoked when the blocked state of a tab changes. | 120 // Invoked when the blocked state of a tab changes. |
| 122 // NOTE: This is invoked when a tab becomes blocked/unblocked by a tab modal | 121 // NOTE: This is invoked when a tab becomes blocked/unblocked by a tab modal |
| 123 // window. | 122 // window. |
| 124 virtual void TabBlockedStateChanged(TabContentsWrapper* contents, int index); | 123 virtual void TabBlockedStateChanged(TabContents* contents, int index); |
| 125 | 124 |
| 126 // The TabStripModel now no longer has any tabs. The implementer may | 125 // The TabStripModel now no longer has any tabs. The implementer may |
| 127 // use this as a trigger to try and close the window containing the | 126 // use this as a trigger to try and close the window containing the |
| 128 // TabStripModel, for example... | 127 // TabStripModel, for example... |
| 129 virtual void TabStripEmpty(); | 128 virtual void TabStripEmpty(); |
| 130 | 129 |
| 131 // Sent when the tabstrip model is about to be deleted and any reference held | 130 // Sent when the tabstrip model is about to be deleted and any reference held |
| 132 // must be dropped. | 131 // must be dropped. |
| 133 virtual void TabStripModelDeleted(); | 132 virtual void TabStripModelDeleted(); |
| 134 | 133 |
| 135 // Invoked when an active/selected tab at |index| is selected again (ie - the | 134 // Invoked when an active/selected tab at |index| is selected again (ie - the |
| 136 // active/foreground tab is clicked). | 135 // active/foreground tab is clicked). |
| 137 virtual void ActiveTabClicked(int index); | 136 virtual void ActiveTabClicked(int index); |
| 138 | 137 |
| 139 protected: | 138 protected: |
| 140 virtual ~TabStripModelObserver() {} | 139 virtual ~TabStripModelObserver() {} |
| 141 }; | 140 }; |
| 142 | 141 |
| 143 #endif // CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_OBSERVER_H_ | 142 #endif // CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_OBSERVER_H_ |
| OLD | NEW |