| 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 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 8 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 9 | 9 |
| 10 using content::WebContents; | 10 using content::WebContents; |
| 11 | 11 |
| 12 namespace { | |
| 13 | |
| 14 // TODO(avi): Remove when TabStripModelObserver sends WebContents. | |
| 15 content::WebContents* WebContentsOf(TabContents* tab_contents) { | |
| 16 return tab_contents ? tab_contents->web_contents() : NULL; | |
| 17 } | |
| 18 | |
| 19 } // namespace | |
| 20 | |
| 21 TabStripModelObserverBridge::TabStripModelObserverBridge(TabStripModel* model, | 12 TabStripModelObserverBridge::TabStripModelObserverBridge(TabStripModel* model, |
| 22 id controller) | 13 id controller) |
| 23 : controller_(controller), model_(model) { | 14 : controller_(controller), model_(model) { |
| 24 DCHECK(model && controller); | 15 DCHECK(model && controller); |
| 25 // Register to be a listener on the model so we can get updates and tell | 16 // Register to be a listener on the model so we can get updates and tell |
| 26 // |controller_| about them in the future. | 17 // |controller_| about them in the future. |
| 27 model_->AddObserver(this); | 18 model_->AddObserver(this); |
| 28 } | 19 } |
| 29 | 20 |
| 30 TabStripModelObserverBridge::~TabStripModelObserverBridge() { | 21 TabStripModelObserverBridge::~TabStripModelObserverBridge() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 int index, | 80 int index, |
| 90 TabChangeType change_type) { | 81 TabChangeType change_type) { |
| 91 if ([controller_ respondsToSelector: | 82 if ([controller_ respondsToSelector: |
| 92 @selector(tabChangedWithContents:atIndex:changeType:)]) { | 83 @selector(tabChangedWithContents:atIndex:changeType:)]) { |
| 93 [controller_ tabChangedWithContents:contents | 84 [controller_ tabChangedWithContents:contents |
| 94 atIndex:index | 85 atIndex:index |
| 95 changeType:change_type]; | 86 changeType:change_type]; |
| 96 } | 87 } |
| 97 } | 88 } |
| 98 | 89 |
| 99 void TabStripModelObserverBridge::TabReplacedAt( | 90 void TabStripModelObserverBridge::TabReplacedAt(TabStripModel* tab_strip_model, |
| 100 TabStripModel* tab_strip_model, | 91 WebContents* old_contents, |
| 101 TabContents* old_contents, | 92 WebContents* new_contents, |
| 102 TabContents* new_contents, | 93 int index) { |
| 103 int index) { | |
| 104 if ([controller_ respondsToSelector: | 94 if ([controller_ respondsToSelector: |
| 105 @selector(tabReplacedWithContents:previousContents:atIndex:)]) { | 95 @selector(tabReplacedWithContents:previousContents:atIndex:)]) { |
| 106 [controller_ tabReplacedWithContents:WebContentsOf(new_contents) | 96 [controller_ tabReplacedWithContents:new_contents |
| 107 previousContents:WebContentsOf(old_contents) | 97 previousContents:old_contents |
| 108 atIndex:index]; | 98 atIndex:index]; |
| 109 } else { | 99 } else { |
| 110 TabChangedAt(WebContentsOf(new_contents), index, ALL); | 100 TabChangedAt(new_contents, index, ALL); |
| 111 } | 101 } |
| 112 } | 102 } |
| 113 | 103 |
| 114 void TabStripModelObserverBridge::TabMiniStateChanged( | 104 void TabStripModelObserverBridge::TabMiniStateChanged(WebContents* contents, |
| 115 WebContents* contents, | 105 int index) { |
| 116 int index) { | |
| 117 if ([controller_ respondsToSelector: | 106 if ([controller_ respondsToSelector: |
| 118 @selector(tabMiniStateChangedWithContents:atIndex:)]) { | 107 @selector(tabMiniStateChangedWithContents:atIndex:)]) { |
| 119 [controller_ tabMiniStateChangedWithContents:contents | 108 [controller_ tabMiniStateChangedWithContents:contents |
| 120 atIndex:index]; | 109 atIndex:index]; |
| 121 } | 110 } |
| 122 } | 111 } |
| 123 | 112 |
| 124 void TabStripModelObserverBridge::TabStripEmpty() { | 113 void TabStripModelObserverBridge::TabStripEmpty() { |
| 125 if ([controller_ respondsToSelector:@selector(tabStripEmpty)]) | 114 if ([controller_ respondsToSelector:@selector(tabStripEmpty)]) |
| 126 [controller_ tabStripEmpty]; | 115 [controller_ tabStripEmpty]; |
| 127 } | 116 } |
| 128 | 117 |
| 129 void TabStripModelObserverBridge::TabStripModelDeleted() { | 118 void TabStripModelObserverBridge::TabStripModelDeleted() { |
| 130 if ([controller_ respondsToSelector:@selector(tabStripModelDeleted)]) | 119 if ([controller_ respondsToSelector:@selector(tabStripModelDeleted)]) |
| 131 [controller_ tabStripModelDeleted]; | 120 [controller_ tabStripModelDeleted]; |
| 132 } | 121 } |
| OLD | NEW |