| 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 #include "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 5 #include "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 8 | 8 |
| 9 using content::WebContents; | 9 using content::WebContents; |
| 10 | 10 |
| 11 TabStripModelObserverBridge::TabStripModelObserverBridge(TabStripModel* model, | 11 TabStripModelObserverBridge::TabStripModelObserverBridge(TabStripModel* model, |
| 12 id controller) | 12 id controller) |
| 13 : controller_(controller), model_(model) { | 13 : controller_(controller), model_(model) { |
| 14 DCHECK(model && controller); | 14 DCHECK(model && controller); |
| 15 // Register to be a listener on the model so we can get updates and tell | 15 // Register to be a listener on the model so we can get updates and tell |
| 16 // |controller_| about them in the future. | 16 // |controller_| about them in the future. |
| 17 model_->AddObserver(this); | 17 model_->AddObserver(this); |
| 18 } | 18 } |
| 19 | 19 |
| 20 TabStripModelObserverBridge::~TabStripModelObserverBridge() { | 20 TabStripModelObserverBridge::~TabStripModelObserverBridge() { |
| 21 // Remove ourselves from receiving notifications. | 21 // Remove ourselves from receiving notifications. |
| 22 model_->RemoveObserver(this); | 22 model_->RemoveObserver(this); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void TabStripModelObserverBridge::TabInsertedAt(WebContents* contents, | 25 void TabStripModelObserverBridge::TabInsertedAt(TabStripModel* tab_strip_model, |
| 26 WebContents* contents, |
| 26 int index, | 27 int index, |
| 27 bool foreground) { | 28 bool foreground) { |
| 28 if ([controller_ respondsToSelector: | 29 if ([controller_ respondsToSelector: |
| 29 @selector(insertTabWithContents:atIndex:inForeground:)]) { | 30 @selector(insertTabWithContents:atIndex:inForeground:)]) { |
| 30 [controller_ insertTabWithContents:contents | 31 [controller_ insertTabWithContents:contents |
| 31 atIndex:index | 32 atIndex:index |
| 32 inForeground:foreground]; | 33 inForeground:foreground]; |
| 33 } | 34 } |
| 34 } | 35 } |
| 35 | 36 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if ([controller_ respondsToSelector: | 106 if ([controller_ respondsToSelector: |
| 106 @selector(tabReplacedWithContents:previousContents:atIndex:)]) { | 107 @selector(tabReplacedWithContents:previousContents:atIndex:)]) { |
| 107 [controller_ tabReplacedWithContents:new_contents | 108 [controller_ tabReplacedWithContents:new_contents |
| 108 previousContents:old_contents | 109 previousContents:old_contents |
| 109 atIndex:index]; | 110 atIndex:index]; |
| 110 } else { | 111 } else { |
| 111 TabChangedAt(new_contents, index, ALL); | 112 TabChangedAt(new_contents, index, ALL); |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 | 115 |
| 115 void TabStripModelObserverBridge::TabPinnedStateChanged(WebContents* contents, | 116 void TabStripModelObserverBridge::TabPinnedStateChanged( |
| 116 int index) { | 117 TabStripModel* tab_strip_model, |
| 118 WebContents* contents, |
| 119 int index) { |
| 117 if ([controller_ respondsToSelector: | 120 if ([controller_ respondsToSelector: |
| 118 @selector(tabPinnedStateChangedWithContents:atIndex:)]) { | 121 @selector(tabPinnedStateChangedWithContents:atIndex:)]) { |
| 119 [controller_ tabPinnedStateChangedWithContents:contents | 122 [controller_ tabPinnedStateChangedWithContents:contents |
| 120 atIndex:index]; | 123 atIndex:index]; |
| 121 } | 124 } |
| 122 } | 125 } |
| 123 | 126 |
| 124 void TabStripModelObserverBridge::TabStripEmpty() { | 127 void TabStripModelObserverBridge::TabStripEmpty() { |
| 125 if ([controller_ respondsToSelector:@selector(tabStripEmpty)]) | 128 if ([controller_ respondsToSelector:@selector(tabStripEmpty)]) |
| 126 [controller_ tabStripEmpty]; | 129 [controller_ tabStripEmpty]; |
| 127 } | 130 } |
| OLD | NEW |