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 "chrome/browser/chromeos/tab_closeable_state_watcher.h" | 5 #include "chrome/browser/chromeos/tab_closeable_state_watcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/browser/browser_shutdown.h" |
9 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
10 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 12 #include "chrome/browser/tab_contents/tab_contents.h" |
12 #include "chrome/browser/tab_contents/tab_contents_view.h" | 13 #include "chrome/browser/tab_contents/tab_contents_view.h" |
13 #include "chrome/common/notification_service.h" | 14 #include "chrome/common/notification_service.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 signing_off_(false), | 69 signing_off_(false), |
69 bwsi_session_( | 70 bwsi_session_( |
70 CommandLine::ForCurrentProcess()->HasSwitch(switches::kBWSI)) { | 71 CommandLine::ForCurrentProcess()->HasSwitch(switches::kBWSI)) { |
71 BrowserList::AddObserver(this); | 72 BrowserList::AddObserver(this); |
72 notification_registrar_.Add(this, NotificationType::APP_EXITING, | 73 notification_registrar_.Add(this, NotificationType::APP_EXITING, |
73 NotificationService::AllSources()); | 74 NotificationService::AllSources()); |
74 } | 75 } |
75 | 76 |
76 TabCloseableStateWatcher::~TabCloseableStateWatcher() { | 77 TabCloseableStateWatcher::~TabCloseableStateWatcher() { |
77 BrowserList::RemoveObserver(this); | 78 BrowserList::RemoveObserver(this); |
78 DCHECK(tabstrip_watchers_.empty()); | 79 if (!browser_shutdown::ShuttingDownWithoutClosingBrowsers()) |
| 80 DCHECK(tabstrip_watchers_.empty()); |
79 } | 81 } |
80 | 82 |
81 bool TabCloseableStateWatcher::CanCloseTab(const Browser* browser) const { | 83 bool TabCloseableStateWatcher::CanCloseTab(const Browser* browser) const { |
82 return browser->type() != Browser::TYPE_NORMAL ? true : can_close_tab_; | 84 return browser->type() != Browser::TYPE_NORMAL ? true : can_close_tab_; |
83 } | 85 } |
84 | 86 |
85 bool TabCloseableStateWatcher::CanCloseBrowser(Browser* browser) { | 87 bool TabCloseableStateWatcher::CanCloseBrowser(Browser* browser) { |
86 BrowserActionType action_type; | 88 BrowserActionType action_type; |
87 bool can_close = CanCloseBrowserImpl(browser, &action_type); | 89 bool can_close = CanCloseBrowserImpl(browser, &action_type); |
88 if (action_type == OPEN_WINDOW) { | 90 if (action_type == OPEN_WINDOW) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 if (!can_close_tab_) | 248 if (!can_close_tab_) |
247 return false; | 249 return false; |
248 | 250 |
249 // Otherwise, close existing tabs, and deny closing of browser. | 251 // Otherwise, close existing tabs, and deny closing of browser. |
250 // TabClosingAt will open NTP when the last tab is being closed. | 252 // TabClosingAt will open NTP when the last tab is being closed. |
251 *action_type = OPEN_NTP; | 253 *action_type = OPEN_NTP; |
252 return false; | 254 return false; |
253 } | 255 } |
254 | 256 |
255 } // namespace chromeos | 257 } // namespace chromeos |
OLD | NEW |