| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/tabs/browser_tab_strip_controller.h" | 5 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/extensions/extension_tab_helper.h" | 9 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 10 #include "chrome/browser/favicon/favicon_tab_helper.h" | 10 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/tabs/tab_strip_model.h" | 12 #include "chrome/browser/tabs/tab_strip_model.h" |
| 13 #include "chrome/browser/tabs/tab_strip_selection_model.h" | 13 #include "chrome/browser/tabs/tab_strip_selection_model.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 16 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 16 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 17 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" | 17 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" |
| 18 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" | 18 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 20 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
| 21 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
| 22 #include "content/browser/user_metrics.h" | 23 #include "content/browser/user_metrics.h" |
| 23 #include "content/common/notification_service.h" | 24 #include "content/common/notification_service.h" |
| 24 #include "views/controls/menu/menu_item_view.h" | 25 #include "views/controls/menu/menu_item_view.h" |
| 25 #include "views/controls/menu/menu_model_adapter.h" | 26 #include "views/controls/menu/menu_model_adapter.h" |
| 26 #include "views/widget/widget.h" | 27 #include "views/widget/widget.h" |
| 27 | 28 |
| 28 static TabRendererData::NetworkState TabContentsNetworkState( | 29 static TabRendererData::NetworkState TabContentsNetworkState( |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 131 |
| 131 BrowserTabStripController::BrowserTabStripController(Browser* browser, | 132 BrowserTabStripController::BrowserTabStripController(Browser* browser, |
| 132 TabStripModel* model) | 133 TabStripModel* model) |
| 133 : model_(model), | 134 : model_(model), |
| 134 tabstrip_(NULL), | 135 tabstrip_(NULL), |
| 135 browser_(browser), | 136 browser_(browser), |
| 136 hover_tab_selector_(model) { | 137 hover_tab_selector_(model) { |
| 137 model_->AddObserver(this); | 138 model_->AddObserver(this); |
| 138 | 139 |
| 139 notification_registrar_.Add(this, | 140 notification_registrar_.Add(this, |
| 140 NotificationType::TAB_CLOSEABLE_STATE_CHANGED, | 141 chrome::NOTIFICATION_TAB_CLOSEABLE_STATE_CHANGED, |
| 141 NotificationService::AllSources()); | 142 NotificationService::AllSources()); |
| 142 } | 143 } |
| 143 | 144 |
| 144 BrowserTabStripController::~BrowserTabStripController() { | 145 BrowserTabStripController::~BrowserTabStripController() { |
| 145 // When we get here the TabStrip is being deleted. We need to explicitly | 146 // When we get here the TabStrip is being deleted. We need to explicitly |
| 146 // cancel the menu, otherwise it may try to invoke something on the tabstrip | 147 // cancel the menu, otherwise it may try to invoke something on the tabstrip |
| 147 // from it's destructor. | 148 // from it's destructor. |
| 148 if (context_menu_contents_.get()) | 149 if (context_menu_contents_.get()) |
| 149 context_menu_contents_->Cancel(); | 150 context_menu_contents_->Cancel(); |
| 150 | 151 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 397 |
| 397 void BrowserTabStripController::TabBlockedStateChanged( | 398 void BrowserTabStripController::TabBlockedStateChanged( |
| 398 TabContentsWrapper* contents, | 399 TabContentsWrapper* contents, |
| 399 int model_index) { | 400 int model_index) { |
| 400 SetTabDataAt(contents, model_index); | 401 SetTabDataAt(contents, model_index); |
| 401 } | 402 } |
| 402 | 403 |
| 403 //////////////////////////////////////////////////////////////////////////////// | 404 //////////////////////////////////////////////////////////////////////////////// |
| 404 // BrowserTabStripController, NotificationObserver implementation: | 405 // BrowserTabStripController, NotificationObserver implementation: |
| 405 | 406 |
| 406 void BrowserTabStripController::Observe(NotificationType type, | 407 void BrowserTabStripController::Observe(int type, |
| 407 const NotificationSource& source, const NotificationDetails& details) { | 408 const NotificationSource& source, const NotificationDetails& details) { |
| 408 DCHECK(type.value == NotificationType::TAB_CLOSEABLE_STATE_CHANGED); | 409 DCHECK(type == chrome::NOTIFICATION_TAB_CLOSEABLE_STATE_CHANGED); |
| 409 // Note that this notification may be fired during a model mutation and | 410 // Note that this notification may be fired during a model mutation and |
| 410 // possibly before the tabstrip has processed the change. | 411 // possibly before the tabstrip has processed the change. |
| 411 // Here, we just re-layout each existing tab to reflect the change in its | 412 // Here, we just re-layout each existing tab to reflect the change in its |
| 412 // closeable state, and then schedule paint for entire tabstrip. | 413 // closeable state, and then schedule paint for entire tabstrip. |
| 413 for (int i = 0; i < tabstrip_->tab_count(); ++i) | 414 for (int i = 0; i < tabstrip_->tab_count(); ++i) |
| 414 tabstrip_->base_tab_at_tab_index(i)->Layout(); | 415 tabstrip_->base_tab_at_tab_index(i)->Layout(); |
| 415 tabstrip_->SchedulePaint(); | 416 tabstrip_->SchedulePaint(); |
| 416 } | 417 } |
| 417 | 418 |
| 418 void BrowserTabStripController::SetTabRendererDataFromModel( | 419 void BrowserTabStripController::SetTabRendererDataFromModel( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 474 |
| 474 void BrowserTabStripController::StopHighlightTabsForCommand( | 475 void BrowserTabStripController::StopHighlightTabsForCommand( |
| 475 TabStripModel::ContextMenuCommand command_id, | 476 TabStripModel::ContextMenuCommand command_id, |
| 476 BaseTab* tab) { | 477 BaseTab* tab) { |
| 477 if (command_id == TabStripModel::CommandCloseTabsToRight || | 478 if (command_id == TabStripModel::CommandCloseTabsToRight || |
| 478 command_id == TabStripModel::CommandCloseOtherTabs) { | 479 command_id == TabStripModel::CommandCloseOtherTabs) { |
| 479 // Just tell all Tabs to stop pulsing - it's safe. | 480 // Just tell all Tabs to stop pulsing - it's safe. |
| 480 tabstrip_->StopAllHighlighting(); | 481 tabstrip_->StopAllHighlighting(); |
| 481 } | 482 } |
| 482 } | 483 } |
| OLD | NEW |