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