OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_COCOA_TABS_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ |
6 #define CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
10 | 10 |
| 11 #include "base/compiler_specific.h" |
11 #include "chrome/browser/tabs/tab_strip_model_observer.h" | 12 #include "chrome/browser/tabs/tab_strip_model_observer.h" |
12 | 13 |
13 class TabContentsWrapper; | 14 class TabContentsWrapper; |
14 class TabStripModel; | 15 class TabStripModel; |
15 | 16 |
16 // A C++ bridge class to handle receiving notifications from the C++ tab strip | 17 // A C++ bridge class to handle receiving notifications from the C++ tab strip |
17 // model. When the caller allocates a bridge, it automatically registers for | 18 // model. When the caller allocates a bridge, it automatically registers for |
18 // notifications from |model| and passes messages to |controller| via the | 19 // notifications from |model| and passes messages to |controller| via the |
19 // informal protocol below. The owner of this object is responsible for deleting | 20 // informal protocol below. The owner of this object is responsible for deleting |
20 // it (and thus unhooking notifications) before |controller| is destroyed. | 21 // it (and thus unhooking notifications) before |controller| is destroyed. |
21 class TabStripModelObserverBridge : public TabStripModelObserver { | 22 class TabStripModelObserverBridge : public TabStripModelObserver { |
22 public: | 23 public: |
23 TabStripModelObserverBridge(TabStripModel* model, id controller); | 24 TabStripModelObserverBridge(TabStripModel* model, id controller); |
24 virtual ~TabStripModelObserverBridge(); | 25 virtual ~TabStripModelObserverBridge(); |
25 | 26 |
26 // Overridden from TabStripModelObserver | 27 // Overridden from TabStripModelObserver |
27 virtual void TabInsertedAt(TabContentsWrapper* contents, | 28 virtual void TabInsertedAt(TabContentsWrapper* contents, |
28 int index, | 29 int index, |
29 bool foreground); | 30 bool foreground) OVERRIDE; |
30 virtual void TabClosingAt(TabStripModel* tab_strip_model, | 31 virtual void TabClosingAt(TabStripModel* tab_strip_model, |
31 TabContentsWrapper* contents, | 32 TabContentsWrapper* contents, |
32 int index); | 33 int index) OVERRIDE; |
33 virtual void TabDetachedAt(TabContentsWrapper* contents, int index); | 34 virtual void TabDetachedAt(TabContentsWrapper* contents, int index) OVERRIDE; |
34 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 35 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, |
35 TabContentsWrapper* new_contents, | 36 TabContentsWrapper* new_contents, |
36 int index, | 37 int index, |
37 bool user_gesture); | 38 bool user_gesture) OVERRIDE; |
38 virtual void TabMoved(TabContentsWrapper* contents, | 39 virtual void TabMoved(TabContentsWrapper* contents, |
39 int from_index, | 40 int from_index, |
40 int to_index); | 41 int to_index) OVERRIDE; |
41 virtual void TabChangedAt(TabContentsWrapper* contents, int index, | 42 virtual void TabChangedAt(TabContentsWrapper* contents, int index, |
42 TabChangeType change_type); | 43 TabChangeType change_type) OVERRIDE; |
43 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 44 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
44 TabContentsWrapper* old_contents, | 45 TabContentsWrapper* old_contents, |
45 TabContentsWrapper* new_contents, | 46 TabContentsWrapper* new_contents, |
46 int index); | 47 int index) OVERRIDE; |
47 virtual void TabMiniStateChanged(TabContentsWrapper* contents, int index); | 48 virtual void TabMiniStateChanged(TabContentsWrapper* contents, |
48 virtual void TabStripEmpty(); | 49 int index) OVERRIDE; |
49 virtual void TabStripModelDeleted(); | 50 virtual void TabStripEmpty() OVERRIDE; |
| 51 virtual void TabStripModelDeleted() OVERRIDE; |
50 | 52 |
51 private: | 53 private: |
52 id controller_; // weak, owns me | 54 id controller_; // weak, owns me |
53 TabStripModel* model_; // weak, owned by Browser | 55 TabStripModel* model_; // weak, owned by Browser |
54 }; | 56 }; |
55 | 57 |
56 // A collection of methods which can be selectively implemented by any | 58 // A collection of methods which can be selectively implemented by any |
57 // Cocoa object to receive updates about changes to a tab strip model. It is | 59 // Cocoa object to receive updates about changes to a tab strip model. It is |
58 // ok to not implement them, the calling code checks before calling. | 60 // ok to not implement them, the calling code checks before calling. |
59 @interface NSObject(TabStripModelBridge) | 61 @interface NSObject(TabStripModelBridge) |
(...skipping 17 matching lines...) Expand all Loading... |
77 - (void)tabReplacedWithContents:(TabContentsWrapper*)newContents | 79 - (void)tabReplacedWithContents:(TabContentsWrapper*)newContents |
78 previousContents:(TabContentsWrapper*)oldContents | 80 previousContents:(TabContentsWrapper*)oldContents |
79 atIndex:(NSInteger)index; | 81 atIndex:(NSInteger)index; |
80 - (void)tabMiniStateChangedWithContents:(TabContentsWrapper*)contents | 82 - (void)tabMiniStateChangedWithContents:(TabContentsWrapper*)contents |
81 atIndex:(NSInteger)index; | 83 atIndex:(NSInteger)index; |
82 - (void)tabStripEmpty; | 84 - (void)tabStripEmpty; |
83 - (void)tabStripModelDeleted; | 85 - (void)tabStripModelDeleted; |
84 @end | 86 @end |
85 | 87 |
86 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ | 88 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ |
OLD | NEW |