| 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 #include "base/metrics/nacl_histogram.h" | 5 #include "base/metrics/nacl_histogram.h" |
| 6 #include "chrome/browser/tabs/default_tab_handler.h" | 6 #include "chrome/browser/tabs/default_tab_handler.h" |
| 7 #include "chrome/browser/tabs/tab_strip_model.h" | 7 #include "chrome/browser/tabs/tab_strip_model.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 | 9 |
| 10 //////////////////////////////////////////////////////////////////////////////// | 10 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
| 28 // DefaultTabHandler, TabHandler implementation: | 28 // DefaultTabHandler, TabHandler implementation: |
| 29 | 29 |
| 30 TabStripModel* DefaultTabHandler::GetTabStripModel() const { | 30 TabStripModel* DefaultTabHandler::GetTabStripModel() const { |
| 31 return model_.get(); | 31 return model_.get(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
| 35 // DefaultTabHandler, TabStripModelDelegate implementation: | 35 // DefaultTabHandler, TabStripModelDelegate implementation: |
| 36 | 36 |
| 37 TabContents* DefaultTabHandler::AddBlankTab(bool foreground) { | 37 TabContentsWrapper* DefaultTabHandler::AddBlankTab(bool foreground) { |
| 38 UmaNaclHistogramEnumeration(NEW_TAB_NACL_BASELINE); | 38 UmaNaclHistogramEnumeration(NEW_TAB_NACL_BASELINE); |
| 39 return delegate_->AsBrowser()->AddBlankTab(foreground); | 39 return delegate_->AsBrowser()->AddBlankTab(foreground); |
| 40 } | 40 } |
| 41 | 41 |
| 42 TabContents* DefaultTabHandler::AddBlankTabAt(int index, bool foreground) { | 42 TabContentsWrapper* DefaultTabHandler::AddBlankTabAt(int index, |
| 43 bool foreground) { |
| 43 return delegate_->AsBrowser()->AddBlankTabAt(index, foreground); | 44 return delegate_->AsBrowser()->AddBlankTabAt(index, foreground); |
| 44 } | 45 } |
| 45 | 46 |
| 46 Browser* DefaultTabHandler::CreateNewStripWithContents( | 47 Browser* DefaultTabHandler::CreateNewStripWithContents( |
| 47 TabContents* detached_contents, | 48 TabContentsWrapper* detached_contents, |
| 48 const gfx::Rect& window_bounds, | 49 const gfx::Rect& window_bounds, |
| 49 const DockInfo& dock_info, | 50 const DockInfo& dock_info, |
| 50 bool maximize) { | 51 bool maximize) { |
| 51 return delegate_->AsBrowser()->CreateNewStripWithContents(detached_contents, | 52 return delegate_->AsBrowser()->CreateNewStripWithContents(detached_contents, |
| 52 window_bounds, | 53 window_bounds, |
| 53 dock_info, | 54 dock_info, |
| 54 maximize); | 55 maximize); |
| 55 } | 56 } |
| 56 | 57 |
| 57 void DefaultTabHandler::ContinueDraggingDetachedTab( | 58 void DefaultTabHandler::ContinueDraggingDetachedTab( |
| 58 TabContents* contents, | 59 TabContentsWrapper* contents, |
| 59 const gfx::Rect& window_bounds, | 60 const gfx::Rect& window_bounds, |
| 60 const gfx::Rect& tab_bounds) { | 61 const gfx::Rect& tab_bounds) { |
| 61 delegate_->AsBrowser()->ContinueDraggingDetachedTab(contents, | 62 delegate_->AsBrowser()->ContinueDraggingDetachedTab(contents, |
| 62 window_bounds, | 63 window_bounds, |
| 63 tab_bounds); | 64 tab_bounds); |
| 64 } | 65 } |
| 65 | 66 |
| 66 int DefaultTabHandler::GetDragActions() const { | 67 int DefaultTabHandler::GetDragActions() const { |
| 67 return delegate_->AsBrowser()->GetDragActions(); | 68 return delegate_->AsBrowser()->GetDragActions(); |
| 68 } | 69 } |
| 69 | 70 |
| 70 TabContents* DefaultTabHandler::CreateTabContentsForURL( | 71 TabContentsWrapper* DefaultTabHandler::CreateTabContentsForURL( |
| 71 const GURL& url, | 72 const GURL& url, |
| 72 const GURL& referrer, | 73 const GURL& referrer, |
| 73 Profile* profile, | 74 Profile* profile, |
| 74 PageTransition::Type transition, | 75 PageTransition::Type transition, |
| 75 bool defer_load, | 76 bool defer_load, |
| 76 SiteInstance* instance) const { | 77 SiteInstance* instance) const { |
| 77 return delegate_->AsBrowser()->CreateTabContentsForURL(url, | 78 return delegate_->AsBrowser()->CreateTabContentsForURL(url, |
| 78 referrer, | 79 referrer, |
| 79 profile, | 80 profile, |
| 80 transition, | 81 transition, |
| 81 defer_load, | 82 defer_load, |
| 82 instance); | 83 instance); |
| 83 } | 84 } |
| 84 | 85 |
| 85 bool DefaultTabHandler::CanDuplicateContentsAt(int index) { | 86 bool DefaultTabHandler::CanDuplicateContentsAt(int index) { |
| 86 return delegate_->AsBrowser()->CanDuplicateContentsAt(index); | 87 return delegate_->AsBrowser()->CanDuplicateContentsAt(index); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void DefaultTabHandler::DuplicateContentsAt(int index) { | 90 void DefaultTabHandler::DuplicateContentsAt(int index) { |
| 90 delegate_->AsBrowser()->DuplicateContentsAt(index); | 91 delegate_->AsBrowser()->DuplicateContentsAt(index); |
| 91 } | 92 } |
| 92 | 93 |
| 93 void DefaultTabHandler::CloseFrameAfterDragSession() { | 94 void DefaultTabHandler::CloseFrameAfterDragSession() { |
| 94 delegate_->AsBrowser()->CloseFrameAfterDragSession(); | 95 delegate_->AsBrowser()->CloseFrameAfterDragSession(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void DefaultTabHandler::CreateHistoricalTab(TabContents* contents) { | 98 void DefaultTabHandler::CreateHistoricalTab(TabContentsWrapper* contents) { |
| 98 delegate_->AsBrowser()->CreateHistoricalTab(contents); | 99 delegate_->AsBrowser()->CreateHistoricalTab(contents); |
| 99 } | 100 } |
| 100 | 101 |
| 101 bool DefaultTabHandler::RunUnloadListenerBeforeClosing(TabContents* contents) { | 102 bool DefaultTabHandler::RunUnloadListenerBeforeClosing( |
| 103 TabContentsWrapper* contents) { |
| 102 return delegate_->AsBrowser()->RunUnloadListenerBeforeClosing(contents); | 104 return delegate_->AsBrowser()->RunUnloadListenerBeforeClosing(contents); |
| 103 } | 105 } |
| 104 | 106 |
| 105 bool DefaultTabHandler::CanCloseContentsAt(int index) { | 107 bool DefaultTabHandler::CanCloseContentsAt(int index) { |
| 106 return delegate_->AsBrowser()->CanCloseContentsAt(index); | 108 return delegate_->AsBrowser()->CanCloseContentsAt(index); |
| 107 } | 109 } |
| 108 | 110 |
| 109 bool DefaultTabHandler::CanBookmarkAllTabs() const { | 111 bool DefaultTabHandler::CanBookmarkAllTabs() const { |
| 110 return delegate_->AsBrowser()->CanBookmarkAllTabs(); | 112 return delegate_->AsBrowser()->CanBookmarkAllTabs(); |
| 111 } | 113 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 134 return delegate_->AsBrowser()->LargeIconsPermitted(); | 136 return delegate_->AsBrowser()->LargeIconsPermitted(); |
| 135 } | 137 } |
| 136 | 138 |
| 137 bool DefaultTabHandler::UseVerticalTabs() const { | 139 bool DefaultTabHandler::UseVerticalTabs() const { |
| 138 return delegate_->AsBrowser()->UseVerticalTabs(); | 140 return delegate_->AsBrowser()->UseVerticalTabs(); |
| 139 } | 141 } |
| 140 | 142 |
| 141 //////////////////////////////////////////////////////////////////////////////// | 143 //////////////////////////////////////////////////////////////////////////////// |
| 142 // DefaultTabHandler, TabStripModelObserver implementation: | 144 // DefaultTabHandler, TabStripModelObserver implementation: |
| 143 | 145 |
| 144 void DefaultTabHandler::TabInsertedAt(TabContents* contents, | 146 void DefaultTabHandler::TabInsertedAt(TabContentsWrapper* contents, |
| 145 int index, | 147 int index, |
| 146 bool foreground) { | 148 bool foreground) { |
| 147 delegate_->AsBrowser()->TabInsertedAt(contents, index, foreground); | 149 delegate_->AsBrowser()->TabInsertedAt(contents, index, foreground); |
| 148 } | 150 } |
| 149 | 151 |
| 150 void DefaultTabHandler::TabClosingAt(TabStripModel* tab_strip_model, | 152 void DefaultTabHandler::TabClosingAt(TabStripModel* tab_strip_model, |
| 151 TabContents* contents, | 153 TabContentsWrapper* contents, |
| 152 int index) { | 154 int index) { |
| 153 delegate_->AsBrowser()->TabClosingAt(tab_strip_model, contents, index); | 155 delegate_->AsBrowser()->TabClosingAt(tab_strip_model, contents, index); |
| 154 } | 156 } |
| 155 | 157 |
| 156 void DefaultTabHandler::TabDetachedAt(TabContents* contents, int index) { | 158 void DefaultTabHandler::TabDetachedAt(TabContentsWrapper* contents, int index) { |
| 157 delegate_->AsBrowser()->TabDetachedAt(contents, index); | 159 delegate_->AsBrowser()->TabDetachedAt(contents, index); |
| 158 } | 160 } |
| 159 | 161 |
| 160 void DefaultTabHandler::TabDeselectedAt(TabContents* contents, int index) { | 162 void DefaultTabHandler::TabDeselectedAt(TabContentsWrapper* contents, |
| 163 int index) { |
| 161 delegate_->AsBrowser()->TabDeselectedAt(contents, index); | 164 delegate_->AsBrowser()->TabDeselectedAt(contents, index); |
| 162 } | 165 } |
| 163 | 166 |
| 164 void DefaultTabHandler::TabSelectedAt(TabContents* old_contents, | 167 void DefaultTabHandler::TabSelectedAt(TabContentsWrapper* old_contents, |
| 165 TabContents* new_contents, | 168 TabContentsWrapper* new_contents, |
| 166 int index, | 169 int index, |
| 167 bool user_gesture) { | 170 bool user_gesture) { |
| 168 delegate_->AsBrowser()->TabSelectedAt(old_contents, | 171 delegate_->AsBrowser()->TabSelectedAt(old_contents, |
| 169 new_contents, | 172 new_contents, |
| 170 index, | 173 index, |
| 171 user_gesture); | 174 user_gesture); |
| 172 } | 175 } |
| 173 | 176 |
| 174 void DefaultTabHandler::TabMoved(TabContents* contents, | 177 void DefaultTabHandler::TabMoved(TabContentsWrapper* contents, |
| 175 int from_index, | 178 int from_index, |
| 176 int to_index) { | 179 int to_index) { |
| 177 delegate_->AsBrowser()->TabMoved(contents, from_index, to_index); | 180 delegate_->AsBrowser()->TabMoved(contents, from_index, to_index); |
| 178 } | 181 } |
| 179 | 182 |
| 180 void DefaultTabHandler::TabReplacedAt(TabContents* old_contents, | 183 void DefaultTabHandler::TabReplacedAt(TabContentsWrapper* old_contents, |
| 181 TabContents* new_contents, | 184 TabContentsWrapper* new_contents, |
| 182 int index) { | 185 int index) { |
| 183 delegate_->AsBrowser()->TabReplacedAt(old_contents, new_contents, index); | 186 delegate_->AsBrowser()->TabReplacedAt(old_contents, new_contents, index); |
| 184 } | 187 } |
| 185 | 188 |
| 186 void DefaultTabHandler::TabPinnedStateChanged(TabContents* contents, | 189 void DefaultTabHandler::TabPinnedStateChanged(TabContentsWrapper* contents, |
| 187 int index) { | 190 int index) { |
| 188 delegate_->AsBrowser()->TabPinnedStateChanged(contents, index); | 191 delegate_->AsBrowser()->TabPinnedStateChanged(contents, index); |
| 189 } | 192 } |
| 190 | 193 |
| 191 void DefaultTabHandler::TabStripEmpty() { | 194 void DefaultTabHandler::TabStripEmpty() { |
| 192 delegate_->AsBrowser()->TabStripEmpty(); | 195 delegate_->AsBrowser()->TabStripEmpty(); |
| 193 } | 196 } |
| 194 | 197 |
| 195 //////////////////////////////////////////////////////////////////////////////// | 198 //////////////////////////////////////////////////////////////////////////////// |
| 196 // TabHandler, public: | 199 // TabHandler, public: |
| 197 | 200 |
| 198 // static | 201 // static |
| 199 TabHandler* TabHandler::CreateTabHandler(TabHandlerDelegate* delegate) { | 202 TabHandler* TabHandler::CreateTabHandler(TabHandlerDelegate* delegate) { |
| 200 return new DefaultTabHandler(delegate); | 203 return new DefaultTabHandler(delegate); |
| 201 } | 204 } |
| 202 | 205 |
| OLD | NEW |