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 // TODO(alicet): clean up dependencies on defaults.h and max tab count. | 9 // TODO(alicet): clean up dependencies on defaults.h and max tab count. |
10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
11 #include "chrome/browser/extensions/extension_tab_helper.h" | 11 #include "chrome/browser/extensions/extension_tab_helper.h" |
12 #include "chrome/browser/favicon/favicon_tab_helper.h" | 12 #include "chrome/browser/favicon/favicon_tab_helper.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/tabs/tab_strip_model.h" | 14 #include "chrome/browser/tabs/tab_strip_model.h" |
15 #include "chrome/browser/tabs/tab_strip_selection_model.h" | 15 #include "chrome/browser/tabs/tab_strip_selection_model.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 18 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
19 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" |
20 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" | 20 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
21 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "content/browser/renderer_host/render_view_host.h" | 23 #include "content/browser/renderer_host/render_view_host.h" |
24 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
25 #include "content/browser/user_metrics.h" | 25 #include "content/browser/user_metrics.h" |
26 #include "content/common/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
27 #include "views/controls/menu/menu_item_view.h" | 27 #include "views/controls/menu/menu_item_view.h" |
28 #include "views/controls/menu/menu_model_adapter.h" | 28 #include "views/controls/menu/menu_model_adapter.h" |
29 #include "views/controls/menu/menu_runner.h" | 29 #include "views/controls/menu/menu_runner.h" |
30 #include "views/widget/widget.h" | 30 #include "views/widget/widget.h" |
31 | 31 |
32 static TabRendererData::NetworkState TabContentsNetworkState( | 32 static TabRendererData::NetworkState TabContentsNetworkState( |
33 TabContents* contents) { | 33 TabContents* contents) { |
34 if (!contents || !contents->IsLoading()) | 34 if (!contents || !contents->IsLoading()) |
35 return TabRendererData::NETWORK_STATE_NONE; | 35 return TabRendererData::NETWORK_STATE_NONE; |
36 if (contents->waiting_for_response()) | 36 if (contents->waiting_for_response()) |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 BrowserTabStripController::BrowserTabStripController(Browser* browser, | 133 BrowserTabStripController::BrowserTabStripController(Browser* browser, |
134 TabStripModel* model) | 134 TabStripModel* model) |
135 : model_(model), | 135 : model_(model), |
136 tabstrip_(NULL), | 136 tabstrip_(NULL), |
137 browser_(browser), | 137 browser_(browser), |
138 hover_tab_selector_(model) { | 138 hover_tab_selector_(model) { |
139 model_->AddObserver(this); | 139 model_->AddObserver(this); |
140 | 140 |
141 notification_registrar_.Add(this, | 141 notification_registrar_.Add(this, |
142 chrome::NOTIFICATION_TAB_CLOSEABLE_STATE_CHANGED, | 142 chrome::NOTIFICATION_TAB_CLOSEABLE_STATE_CHANGED, |
143 NotificationService::AllSources()); | 143 content::NotificationService::AllSources()); |
144 } | 144 } |
145 | 145 |
146 BrowserTabStripController::~BrowserTabStripController() { | 146 BrowserTabStripController::~BrowserTabStripController() { |
147 // When we get here the TabStrip is being deleted. We need to explicitly | 147 // When we get here the TabStrip is being deleted. We need to explicitly |
148 // cancel the menu, otherwise it may try to invoke something on the tabstrip | 148 // cancel the menu, otherwise it may try to invoke something on the tabstrip |
149 // from it's destructor. | 149 // from it's destructor. |
150 if (context_menu_contents_.get()) | 150 if (context_menu_contents_.get()) |
151 context_menu_contents_->Cancel(); | 151 context_menu_contents_->Cancel(); |
152 | 152 |
153 model_->RemoveObserver(this); | 153 model_->RemoveObserver(this); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 469 |
470 void BrowserTabStripController::StopHighlightTabsForCommand( | 470 void BrowserTabStripController::StopHighlightTabsForCommand( |
471 TabStripModel::ContextMenuCommand command_id, | 471 TabStripModel::ContextMenuCommand command_id, |
472 BaseTab* tab) { | 472 BaseTab* tab) { |
473 if (command_id == TabStripModel::CommandCloseTabsToRight || | 473 if (command_id == TabStripModel::CommandCloseTabsToRight || |
474 command_id == TabStripModel::CommandCloseOtherTabs) { | 474 command_id == TabStripModel::CommandCloseOtherTabs) { |
475 // Just tell all Tabs to stop pulsing - it's safe. | 475 // Just tell all Tabs to stop pulsing - it's safe. |
476 tabstrip_->StopAllHighlighting(); | 476 tabstrip_->StopAllHighlighting(); |
477 } | 477 } |
478 } | 478 } |
OLD | NEW |