OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "chrome/browser/views/tab_contents_container_view.h" | 7 #include "chrome/browser/views/tab_contents_container_view.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/render_view_host.h" | 10 #include "chrome/browser/render_view_host.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 void TabContentsContainerView::SetTabContents(TabContents* tab_contents) { | 32 void TabContentsContainerView::SetTabContents(TabContents* tab_contents) { |
33 if (tab_contents_) { | 33 if (tab_contents_) { |
34 // TODO(brettw) should this move to HWNDView::Detach which is called below? | 34 // TODO(brettw) should this move to HWNDView::Detach which is called below? |
35 // It needs cleanup regardless. | 35 // It needs cleanup regardless. |
36 HWND container_hwnd = tab_contents_->GetContainerHWND(); | 36 HWND container_hwnd = tab_contents_->GetContainerHWND(); |
37 | 37 |
38 // Hide the contents before adjusting its parent to avoid a full desktop | 38 // Hide the contents before adjusting its parent to avoid a full desktop |
39 // flicker. | 39 // flicker. |
40 ::ShowWindow(container_hwnd, SW_HIDE); | 40 if(container_hwnd) |
| 41 ::ShowWindow(container_hwnd, SW_HIDE); |
41 | 42 |
42 // Reset the parent to NULL to ensure hidden tabs don't receive messages. | 43 // Reset the parent to NULL to ensure hidden tabs don't receive messages. |
43 ::SetParent(container_hwnd, NULL); | 44 if(container_hwnd) |
| 45 ::SetParent(container_hwnd, NULL); |
44 | 46 |
45 tab_contents_->WasHidden(); | 47 tab_contents_->WasHidden(); |
46 | 48 |
47 // Unregister the tab contents window from the FocusManager. | 49 // Unregister the tab contents window from the FocusManager. |
48 views::FocusManager::UninstallFocusSubclass(container_hwnd); | 50 if(container_hwnd) |
| 51 views::FocusManager::UninstallFocusSubclass(container_hwnd); |
49 HWND hwnd = tab_contents_->GetContentHWND(); | 52 HWND hwnd = tab_contents_->GetContentHWND(); |
50 if (hwnd) { | 53 if (hwnd) { |
51 // We may not have an HWND anymore, if the renderer crashed and we are | 54 // We may not have an HWND anymore, if the renderer crashed and we are |
52 // displaying the sad tab for example. | 55 // displaying the sad tab for example. |
53 FocusManager::UninstallFocusSubclass(hwnd); | 56 FocusManager::UninstallFocusSubclass(hwnd); |
54 } | 57 } |
55 | 58 |
56 views::RootView* root_view = tab_contents_->GetContentsRootView(); | 59 views::RootView* root_view = tab_contents_->GetContentsRootView(); |
57 if (root_view) { | 60 if (root_view) { |
58 // Unlink the RootViews as a clean-up. | 61 // Unlink the RootViews as a clean-up. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 Focus(); | 243 Focus(); |
241 } | 244 } |
242 | 245 |
243 void TabContentsContainerView::TabContentsDestroyed(TabContents* contents) { | 246 void TabContentsContainerView::TabContentsDestroyed(TabContents* contents) { |
244 // Sometimes, a TabContents is destroyed before we know about it. This allows | 247 // Sometimes, a TabContents is destroyed before we know about it. This allows |
245 // us to clean up our state in case this happens. | 248 // us to clean up our state in case this happens. |
246 DCHECK(contents == tab_contents_); | 249 DCHECK(contents == tab_contents_); |
247 SetTabContents(NULL); | 250 SetTabContents(NULL); |
248 } | 251 } |
249 | 252 |
OLD | NEW |