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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 params.keep_on_top = always_on_top; | 278 params.keep_on_top = always_on_top; |
279 params.bounds = bounds; | 279 params.bounds = bounds; |
280 window_->Init(params); | 280 window_->Init(params); |
281 window_->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM); | 281 window_->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM); |
282 window_->set_focus_on_creation(false); | 282 window_->set_focus_on_creation(false); |
283 window_->AddObserver(this); | 283 window_->AddObserver(this); |
284 | 284 |
285 web_view_ = new views::WebView(NULL); | 285 web_view_ = new views::WebView(NULL); |
286 AddChildView(web_view_); | 286 AddChildView(web_view_); |
287 | 287 |
288 OnViewWasResized(); | |
289 | |
290 // Register accelarators supported by panels. | 288 // Register accelarators supported by panels. |
291 views::FocusManager* focus_manager = GetFocusManager(); | 289 views::FocusManager* focus_manager = GetFocusManager(); |
292 const std::map<ui::Accelerator, int>& accelerator_table = | 290 const std::map<ui::Accelerator, int>& accelerator_table = |
293 GetAcceleratorTable(); | 291 GetAcceleratorTable(); |
294 for (std::map<ui::Accelerator, int>::const_iterator iter = | 292 for (std::map<ui::Accelerator, int>::const_iterator iter = |
295 accelerator_table.begin(); | 293 accelerator_table.begin(); |
296 iter != accelerator_table.end(); ++iter) { | 294 iter != accelerator_table.end(); ++iter) { |
297 focus_manager->RegisterAccelerator( | 295 focus_manager->RegisterAccelerator( |
298 iter->first, ui::AcceleratorManager::kNormalPriority, this); | 296 iter->first, ui::AcceleratorManager::kNormalPriority, this); |
299 } | 297 } |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 | 888 |
891 void PanelView::UpdateWindowIcon() { | 889 void PanelView::UpdateWindowIcon() { |
892 window_->UpdateWindowIcon(); | 890 window_->UpdateWindowIcon(); |
893 GetFrameView()->UpdateIcon(); | 891 GetFrameView()->UpdateIcon(); |
894 } | 892 } |
895 | 893 |
896 void PanelView::Layout() { | 894 void PanelView::Layout() { |
897 // |web_view_| might not be created yet when the window is first created. | 895 // |web_view_| might not be created yet when the window is first created. |
898 if (web_view_) | 896 if (web_view_) |
899 web_view_->SetBounds(0, 0, width(), height()); | 897 web_view_->SetBounds(0, 0, width(), height()); |
900 OnViewWasResized(); | |
901 } | 898 } |
902 | 899 |
903 gfx::Size PanelView::GetMinimumSize() { | 900 gfx::Size PanelView::GetMinimumSize() { |
904 // If the panel is minimized, it can be rendered to very small size, like | 901 // If the panel is minimized, it can be rendered to very small size, like |
905 // 4-pixel lines when it is docked. Otherwise, its size should not be less | 902 // 4-pixel lines when it is docked. Otherwise, its size should not be less |
906 // than its minimum size. | 903 // than its minimum size. |
907 return panel_->IsMinimized() ? gfx::Size() : | 904 return panel_->IsMinimized() ? gfx::Size() : |
908 gfx::Size(panel::kPanelMinWidth, panel::kPanelMinHeight); | 905 gfx::Size(panel::kPanelMinWidth, panel::kPanelMinHeight); |
909 } | 906 } |
910 | 907 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 // SWP_FRAMECHANGED flag must be called in order for the cached window data | 1120 // SWP_FRAMECHANGED flag must be called in order for the cached window data |
1124 // to be updated properly. | 1121 // to be updated properly. |
1125 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).a
spx | 1122 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).a
spx |
1126 if (update_frame) { | 1123 if (update_frame) { |
1127 ::SetWindowPos(native_window, NULL, 0, 0, 0, 0, | 1124 ::SetWindowPos(native_window, NULL, 0, 0, 0, 0, |
1128 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | | 1125 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | |
1129 SWP_NOZORDER | SWP_NOACTIVATE); | 1126 SWP_NOZORDER | SWP_NOACTIVATE); |
1130 } | 1127 } |
1131 } | 1128 } |
1132 #endif | 1129 #endif |
1133 | |
1134 void PanelView::OnViewWasResized() { | |
1135 #if defined(OS_WIN) && !defined(USE_AURA) | |
1136 content::WebContents* web_contents = panel_->GetWebContents(); | |
1137 if (!web_view_ || !web_contents) | |
1138 return; | |
1139 | |
1140 // When the panel is frameless or has thin frame, the mouse resizing should | |
1141 // also be triggered from the part of client area that is close to the window | |
1142 // frame. | |
1143 int width = web_view_->size().width(); | |
1144 int height = web_view_->size().height(); | |
1145 // Compute the thickness of the client area that needs to be counted towards | |
1146 // mouse resizing. | |
1147 int thickness_for_mouse_resizing = | |
1148 kResizeInsideBoundsSize - GetFrameView()->BorderThickness(); | |
1149 DCHECK(thickness_for_mouse_resizing > 0); | |
1150 SkRegion* region = new SkRegion; | |
1151 region->op(0, 0, thickness_for_mouse_resizing, height, SkRegion::kUnion_Op); | |
1152 region->op(width - thickness_for_mouse_resizing, 0, width, height, | |
1153 SkRegion::kUnion_Op); | |
1154 region->op(0, height - thickness_for_mouse_resizing, width, height, | |
1155 SkRegion::kUnion_Op); | |
1156 web_contents->GetRenderViewHost()->GetView()->SetClickthroughRegion(region); | |
1157 #endif | |
1158 } | |
OLD | NEW |