| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/cocoa/tab_strip_model_observer_bridge.h" | |
| 6 | |
| 7 #include "chrome/browser/tabs/tab_strip_model.h" | |
| 8 | |
| 9 TabStripModelObserverBridge::TabStripModelObserverBridge(TabStripModel* model, | |
| 10 id controller) | |
| 11 : controller_(controller), model_(model) { | |
| 12 DCHECK(model && controller); | |
| 13 // Register to be a listener on the model so we can get updates and tell | |
| 14 // |controller_| about them in the future. | |
| 15 model_->AddObserver(this); | |
| 16 } | |
| 17 | |
| 18 TabStripModelObserverBridge::~TabStripModelObserverBridge() { | |
| 19 // Remove ourselves from receiving notifications. | |
| 20 model_->RemoveObserver(this); | |
| 21 } | |
| 22 | |
| 23 void TabStripModelObserverBridge::TabInsertedAt(TabContentsWrapper* contents, | |
| 24 int index, | |
| 25 bool foreground) { | |
| 26 if ([controller_ respondsToSelector: | |
| 27 @selector(insertTabWithContents:atIndex:inForeground:)]) { | |
| 28 [controller_ insertTabWithContents:contents | |
| 29 atIndex:index | |
| 30 inForeground:foreground]; | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 void TabStripModelObserverBridge::TabClosingAt(TabStripModel* tab_strip_model, | |
| 35 TabContentsWrapper* contents, | |
| 36 int index) { | |
| 37 if ([controller_ respondsToSelector: | |
| 38 @selector(tabClosingWithContents:atIndex:)]) { | |
| 39 [controller_ tabClosingWithContents:contents atIndex:index]; | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 void TabStripModelObserverBridge::TabDetachedAt(TabContentsWrapper* contents, | |
| 44 int index) { | |
| 45 if ([controller_ respondsToSelector: | |
| 46 @selector(tabDetachedWithContents:atIndex:)]) { | |
| 47 [controller_ tabDetachedWithContents:contents atIndex:index]; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 void TabStripModelObserverBridge::TabSelectedAt( | |
| 52 TabContentsWrapper* old_contents, | |
| 53 TabContentsWrapper* new_contents, | |
| 54 int index, | |
| 55 bool user_gesture) { | |
| 56 if ([controller_ respondsToSelector: | |
| 57 @selector(selectTabWithContents:previousContents:atIndex: | |
| 58 userGesture:)]) { | |
| 59 [controller_ selectTabWithContents:new_contents | |
| 60 previousContents:old_contents | |
| 61 atIndex:index | |
| 62 userGesture:user_gesture]; | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 void TabStripModelObserverBridge::TabMoved(TabContentsWrapper* contents, | |
| 67 int from_index, | |
| 68 int to_index) { | |
| 69 if ([controller_ respondsToSelector: | |
| 70 @selector(tabMovedWithContents:fromIndex:toIndex:)]) { | |
| 71 [controller_ tabMovedWithContents:contents | |
| 72 fromIndex:from_index | |
| 73 toIndex:to_index]; | |
| 74 } | |
| 75 } | |
| 76 | |
| 77 void TabStripModelObserverBridge::TabChangedAt(TabContentsWrapper* contents, | |
| 78 int index, | |
| 79 TabChangeType change_type) { | |
| 80 if ([controller_ respondsToSelector: | |
| 81 @selector(tabChangedWithContents:atIndex:changeType:)]) { | |
| 82 [controller_ tabChangedWithContents:contents | |
| 83 atIndex:index | |
| 84 changeType:change_type]; | |
| 85 } | |
| 86 } | |
| 87 | |
| 88 void TabStripModelObserverBridge::TabReplacedAt( | |
| 89 TabStripModel* tab_strip_model, | |
| 90 TabContentsWrapper* old_contents, | |
| 91 TabContentsWrapper* new_contents, | |
| 92 int index) { | |
| 93 if ([controller_ respondsToSelector: | |
| 94 @selector(tabReplacedWithContents:previousContents:atIndex:)]) { | |
| 95 [controller_ tabReplacedWithContents:new_contents | |
| 96 previousContents:old_contents | |
| 97 atIndex:index]; | |
| 98 } else { | |
| 99 TabChangedAt(new_contents, index, ALL); | |
| 100 } | |
| 101 } | |
| 102 | |
| 103 void TabStripModelObserverBridge::TabMiniStateChanged( | |
| 104 TabContentsWrapper* contents, int index) { | |
| 105 if ([controller_ respondsToSelector: | |
| 106 @selector(tabMiniStateChangedWithContents:atIndex:)]) { | |
| 107 [controller_ tabMiniStateChangedWithContents:contents atIndex:index]; | |
| 108 } | |
| 109 } | |
| 110 | |
| 111 void TabStripModelObserverBridge::TabStripEmpty() { | |
| 112 if ([controller_ respondsToSelector:@selector(tabStripEmpty)]) | |
| 113 [controller_ tabStripEmpty]; | |
| 114 } | |
| 115 | |
| 116 void TabStripModelObserverBridge::TabStripModelDeleted() { | |
| 117 if ([controller_ respondsToSelector:@selector(tabStripModelDeleted)]) | |
| 118 [controller_ tabStripModelDeleted]; | |
| 119 } | |
| OLD | NEW |