| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_COCOA_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_COCOA_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_COCOA_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ | 6 #define CHROME_BROWSER_COCOA_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 "chrome/browser/tabs/tab_strip_model_observer.h" | 11 #include "chrome/browser/tabs/tab_strip_model_observer.h" |
| 12 | 12 |
| 13 class TabContents; | 13 class TabContentsWrapper; |
| 14 class TabStripModel; | 14 class TabStripModel; |
| 15 | 15 |
| 16 // A C++ bridge class to handle receiving notifications from the C++ tab strip | 16 // 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 | 17 // model. When the caller allocates a bridge, it automatically registers for |
| 18 // notifications from |model| and passes messages to |controller| via the | 18 // notifications from |model| and passes messages to |controller| via the |
| 19 // informal protocol below. The owner of this object is responsible for deleting | 19 // informal protocol below. The owner of this object is responsible for deleting |
| 20 // it (and thus unhooking notifications) before |controller| is destroyed. | 20 // it (and thus unhooking notifications) before |controller| is destroyed. |
| 21 class TabStripModelObserverBridge : public TabStripModelObserver { | 21 class TabStripModelObserverBridge : public TabStripModelObserver { |
| 22 public: | 22 public: |
| 23 TabStripModelObserverBridge(TabStripModel* model, id controller); | 23 TabStripModelObserverBridge(TabStripModel* model, id controller); |
| 24 virtual ~TabStripModelObserverBridge(); | 24 virtual ~TabStripModelObserverBridge(); |
| 25 | 25 |
| 26 // Overridden from TabStripModelObserver | 26 // Overridden from TabStripModelObserver |
| 27 virtual void TabInsertedAt(TabContents* contents, | 27 virtual void TabInsertedAt(TabContentsWrapper* contents, |
| 28 int index, | 28 int index, |
| 29 bool foreground); | 29 bool foreground); |
| 30 virtual void TabClosingAt(TabStripModel* tab_strip_model, | 30 virtual void TabClosingAt(TabStripModel* tab_strip_model, |
| 31 TabContents* contents, | 31 TabContentsWrapper* contents, |
| 32 int index); | 32 int index); |
| 33 virtual void TabDetachedAt(TabContents* contents, int index); | 33 virtual void TabDetachedAt(TabContentsWrapper* contents, int index); |
| 34 virtual void TabSelectedAt(TabContents* old_contents, | 34 virtual void TabSelectedAt(TabContentsWrapper* old_contents, |
| 35 TabContents* new_contents, | 35 TabContentsWrapper* new_contents, |
| 36 int index, | 36 int index, |
| 37 bool user_gesture); | 37 bool user_gesture); |
| 38 virtual void TabMoved(TabContents* contents, | 38 virtual void TabMoved(TabContentsWrapper* contents, |
| 39 int from_index, | 39 int from_index, |
| 40 int to_index); | 40 int to_index); |
| 41 virtual void TabChangedAt(TabContents* contents, int index, | 41 virtual void TabChangedAt(TabContentsWrapper* contents, int index, |
| 42 TabChangeType change_type); | 42 TabChangeType change_type); |
| 43 virtual void TabReplacedAt(TabContents* old_contents, | 43 virtual void TabReplacedAt(TabContentsWrapper* old_contents, |
| 44 TabContents* new_contents, | 44 TabContentsWrapper* new_contents, |
| 45 int index); | 45 int index); |
| 46 virtual void TabMiniStateChanged(TabContents* contents, int index); | 46 virtual void TabMiniStateChanged(TabContentsWrapper* contents, int index); |
| 47 virtual void TabStripEmpty(); | 47 virtual void TabStripEmpty(); |
| 48 virtual void TabStripModelDeleted(); | 48 virtual void TabStripModelDeleted(); |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 id controller_; // weak, owns me | 51 id controller_; // weak, owns me |
| 52 TabStripModel* model_; // weak, owned by Browser | 52 TabStripModel* model_; // weak, owned by Browser |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // A collection of methods which can be selectively implemented by any | 55 // A collection of methods which can be selectively implemented by any |
| 56 // Cocoa object to receive updates about changes to a tab strip model. It is | 56 // Cocoa object to receive updates about changes to a tab strip model. It is |
| 57 // ok to not implement them, the calling code checks before calling. | 57 // ok to not implement them, the calling code checks before calling. |
| 58 @interface NSObject(TabStripModelBridge) | 58 @interface NSObject(TabStripModelBridge) |
| 59 - (void)insertTabWithContents:(TabContents*)contents | 59 - (void)insertTabWithContents:(TabContentsWrapper*)contents |
| 60 atIndex:(NSInteger)index | 60 atIndex:(NSInteger)index |
| 61 inForeground:(bool)inForeground; | 61 inForeground:(bool)inForeground; |
| 62 - (void)tabClosingWithContents:(TabContents*)contents | 62 - (void)tabClosingWithContents:(TabContentsWrapper*)contents |
| 63 atIndex:(NSInteger)index; | 63 atIndex:(NSInteger)index; |
| 64 - (void)tabDetachedWithContents:(TabContents*)contents | 64 - (void)tabDetachedWithContents:(TabContentsWrapper*)contents |
| 65 atIndex:(NSInteger)index; | 65 atIndex:(NSInteger)index; |
| 66 - (void)selectTabWithContents:(TabContents*)newContents | 66 - (void)selectTabWithContents:(TabContentsWrapper*)newContents |
| 67 previousContents:(TabContents*)oldContents | 67 previousContents:(TabContentsWrapper*)oldContents |
| 68 atIndex:(NSInteger)index | 68 atIndex:(NSInteger)index |
| 69 userGesture:(bool)wasUserGesture; | 69 userGesture:(bool)wasUserGesture; |
| 70 - (void)tabMovedWithContents:(TabContents*)contents | 70 - (void)tabMovedWithContents:(TabContentsWrapper*)contents |
| 71 fromIndex:(NSInteger)from | 71 fromIndex:(NSInteger)from |
| 72 toIndex:(NSInteger)to; | 72 toIndex:(NSInteger)to; |
| 73 - (void)tabChangedWithContents:(TabContents*)contents | 73 - (void)tabChangedWithContents:(TabContentsWrapper*)contents |
| 74 atIndex:(NSInteger)index | 74 atIndex:(NSInteger)index |
| 75 changeType:(TabStripModelObserver::TabChangeType)change; | 75 changeType:(TabStripModelObserver::TabChangeType)change; |
| 76 - (void)tabReplacedWithContents:(TabContents*)newContents | 76 - (void)tabReplacedWithContents:(TabContentsWrapper*)newContents |
| 77 previousContents:(TabContents*)oldContents | 77 previousContents:(TabContentsWrapper*)oldContents |
| 78 atIndex:(NSInteger)index; | 78 atIndex:(NSInteger)index; |
| 79 - (void)tabMiniStateChangedWithContents:(TabContents*)contents | 79 - (void)tabMiniStateChangedWithContents:(TabContentsWrapper*)contents |
| 80 atIndex:(NSInteger)index; | 80 atIndex:(NSInteger)index; |
| 81 - (void)tabStripEmpty; | 81 - (void)tabStripEmpty; |
| 82 - (void)tabStripModelDeleted; | 82 - (void)tabStripModelDeleted; |
| 83 @end | 83 @end |
| 84 | 84 |
| 85 #endif // CHROME_BROWSER_COCOA_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ | 85 #endif // CHROME_BROWSER_COCOA_TAB_STRIP_MODEL_OBSERVER_BRIDGE_H_ |
| OLD | NEW |