OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/panels/panel_view.h" | 5 #include "chrome/browser/ui/views/panels/panel_view.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 #if defined(OS_WIN) | 304 #if defined(OS_WIN) |
305 ui::win::SetAppIdForWindow( | 305 ui::win::SetAppIdForWindow( |
306 ShellIntegration::GetAppModelIdForProfile( | 306 ShellIntegration::GetAppModelIdForProfile( |
307 base::UTF8ToWide(panel->app_name()), panel->profile()->GetPath()), | 307 base::UTF8ToWide(panel->app_name()), panel->profile()->GetPath()), |
308 views::HWNDForWidget(window_)); | 308 views::HWNDForWidget(window_)); |
309 ui::win::PreventWindowFromPinning(views::HWNDForWidget(window_)); | 309 ui::win::PreventWindowFromPinning(views::HWNDForWidget(window_)); |
310 #endif | 310 #endif |
311 } | 311 } |
312 | 312 |
313 PanelView::~PanelView() { | 313 PanelView::~PanelView() { |
314 if (window_) | |
315 window_->RemoveObserver(this); | |
316 } | 314 } |
317 | 315 |
318 void PanelView::ShowPanel() { | 316 void PanelView::ShowPanel() { |
319 ShowPanelInactive(); | 317 ShowPanelInactive(); |
320 ActivatePanel(); | 318 ActivatePanel(); |
321 } | 319 } |
322 | 320 |
323 void PanelView::ShowPanelInactive() { | 321 void PanelView::ShowPanelInactive() { |
324 if (window_->IsVisible()) | 322 if (window_->IsVisible()) |
325 return; | 323 return; |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 else | 772 else |
775 return *app_icon.ToImageSkia(); | 773 return *app_icon.ToImageSkia(); |
776 } | 774 } |
777 | 775 |
778 gfx::ImageSkia PanelView::GetWindowIcon() { | 776 gfx::ImageSkia PanelView::GetWindowIcon() { |
779 gfx::Image icon = panel_->GetCurrentPageIcon(); | 777 gfx::Image icon = panel_->GetCurrentPageIcon(); |
780 return icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia(); | 778 return icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia(); |
781 } | 779 } |
782 | 780 |
783 void PanelView::WindowClosing() { | 781 void PanelView::WindowClosing() { |
784 | |
785 // When closing a panel via window.close, API or the close button, | 782 // When closing a panel via window.close, API or the close button, |
786 // ClosePanel() is called first, destroying the native |window_| | 783 // ClosePanel() is called first, destroying the native |window_| |
787 // which results in this method being called. ClosePanel() sets | 784 // which results in this method being called. ClosePanel() sets |
788 // |window_closed_| to NULL. | 785 // |window_closed_| to NULL. |
789 // If we still have a |window_closed_| here, the close was triggered by the | 786 // If we still have a |window_closed_| here, the close was triggered by the |
790 // OS, (e.g. clicking on taskbar menu), which destroys the native |window_| | 787 // OS, (e.g. clicking on taskbar menu), which destroys the native |window_| |
791 // without invoking ClosePanel() beforehand. | 788 // without invoking ClosePanel() beforehand. |
792 if (!window_closed_) { | 789 if (!window_closed_) { |
793 panel_->OnWindowClosing(); | 790 panel_->OnWindowClosing(); |
794 ClosePanel(); | 791 ClosePanel(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 | 941 |
945 const std::map<ui::Accelerator, int>& accelerator_table = | 942 const std::map<ui::Accelerator, int>& accelerator_table = |
946 GetAcceleratorTable(); | 943 GetAcceleratorTable(); |
947 std::map<ui::Accelerator, int>::const_iterator iter = | 944 std::map<ui::Accelerator, int>::const_iterator iter = |
948 accelerator_table.find(accelerator); | 945 accelerator_table.find(accelerator); |
949 DCHECK(iter != accelerator_table.end()); | 946 DCHECK(iter != accelerator_table.end()); |
950 return panel_->ExecuteCommandIfEnabled(iter->second); | 947 return panel_->ExecuteCommandIfEnabled(iter->second); |
951 } | 948 } |
952 | 949 |
953 void PanelView::OnWidgetDestroying(views::Widget* widget) { | 950 void PanelView::OnWidgetDestroying(views::Widget* widget) { |
954 if (window_) { | 951 window_ = NULL; |
955 window_->RemoveObserver(this); | |
956 window_ = NULL; | |
957 } | |
958 } | 952 } |
959 | 953 |
960 void PanelView::OnWidgetActivationChanged(views::Widget* widget, bool active) { | 954 void PanelView::OnWidgetActivationChanged(views::Widget* widget, bool active) { |
961 #if defined(OS_WIN) | 955 #if defined(OS_WIN) |
962 // WM_NCACTIVATED could be sent when an active window is being destroyed on | 956 // WM_NCACTIVATED could be sent when an active window is being destroyed on |
963 // Windows. We need to guard against this. | 957 // Windows. We need to guard against this. |
964 if (window_closed_) | 958 if (window_closed_) |
965 return; | 959 return; |
966 | 960 |
967 bool focused = active; | 961 bool focused = active; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 // SWP_FRAMECHANGED flag must be called in order for the cached window data | 1126 // SWP_FRAMECHANGED flag must be called in order for the cached window data |
1133 // to be updated properly. | 1127 // to be updated properly. |
1134 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).a
spx | 1128 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).a
spx |
1135 if (update_frame) { | 1129 if (update_frame) { |
1136 ::SetWindowPos(native_window, NULL, 0, 0, 0, 0, | 1130 ::SetWindowPos(native_window, NULL, 0, 0, 0, 0, |
1137 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | | 1131 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | |
1138 SWP_NOZORDER | SWP_NOACTIVATE); | 1132 SWP_NOZORDER | SWP_NOACTIVATE); |
1139 } | 1133 } |
1140 } | 1134 } |
1141 #endif | 1135 #endif |
OLD | NEW |