Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: chrome/browser/ui/views/frame/browser_frame_win.cc

Issue 10892014: Make HWNDMessageHandler subclass WindowImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/frame/browser_frame_win.h" 5 #include "chrome/browser/ui/views/frame/browser_frame_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <set> 9 #include <set>
10 10
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 return true; 188 return true;
189 } 189 }
190 190
191 void BrowserFrameWin::UpdateFrameAfterFrameChange() { 191 void BrowserFrameWin::UpdateFrameAfterFrameChange() {
192 // We need to update the glass region on or off before the base class adjusts 192 // We need to update the glass region on or off before the base class adjusts
193 // the window region. 193 // the window region.
194 UpdateDWMFrame(); 194 UpdateDWMFrame();
195 NativeWidgetWin::UpdateFrameAfterFrameChange(); 195 NativeWidgetWin::UpdateFrameAfterFrameChange();
196 } 196 }
197 197
198 void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) { 198 bool BrowserFrameWin::PreHandleMSG(UINT message,
199 browser::SessionEnding(); 199 WPARAM w_param,
200 LPARAM l_param,
201 LRESULT* result) {
202 switch (message) {
203 case WM_ENDSESSION:
204 browser::SessionEnding();
205 return true;
206 case WM_INITMENUPOPUP:
207 system_menu_->UpdateStates();
208 return true;
209 case WM_ACTIVATE:
210 if (LOWORD(w_param) != WA_INACTIVE)
211 CacheMinimizeButtonDelta();
212 return false;
213 }
214 return false;
200 } 215 }
201 216
202 void BrowserFrameWin::OnInitMenuPopup(HMENU menu, UINT position, 217 void BrowserFrameWin::PostHandleMSG(UINT message,
203 BOOL is_system_menu) { 218 WPARAM w_param,
204 system_menu_->UpdateStates(); 219 LPARAM l_param) {
205 } 220 switch (message) {
221 case WM_WINDOWPOSCHANGED:
222 UpdateDWMFrame();
206 223
207 void BrowserFrameWin::OnWindowPosChanged(WINDOWPOS* window_pos) { 224 // Windows lies to us about the position of the minimize button before a
208 NativeWidgetWin::OnWindowPosChanged(window_pos); 225 // window is visible. We use this position to place the OTR avatar in RTL
209 UpdateDWMFrame(); 226 // mode, so when the window is shown, we need to re-layout and schedule a
210 227 // paint for the non-client frame view so that the icon top has the correct
211 // Windows lies to us about the position of the minimize button before a 228 // position when the window becomes visible. This fixes bugs where the icon
212 // window is visible. We use this position to place the OTR avatar in RTL 229 // appears to overlay the minimize button.
213 // mode, so when the window is shown, we need to re-layout and schedule a 230 // Note that we will call Layout every time SetWindowPos is called with
214 // paint for the non-client frame view so that the icon top has the correct 231 // SWP_SHOWWINDOW, however callers typically are careful about not
215 // position when the window becomes visible. This fixes bugs where the icon 232 // specifying this flag unless necessary to avoid flicker.
216 // appears to overlay the minimize button. 233 // This may be invoked during creation on XP and before the non_client_view
217 // Note that we will call Layout every time SetWindowPos is called with 234 // has been created.
218 // SWP_SHOWWINDOW, however callers typically are careful about not specifying 235 WINDOWPOS* window_pos = reinterpret_cast<WINDOWPOS*>(l_param);
219 // this flag unless necessary to avoid flicker. 236 if (window_pos->flags & SWP_SHOWWINDOW && GetWidget()->non_client_view()) {
220 // This may be invoked during creation on XP and before the non_client_view 237 GetWidget()->non_client_view()->Layout();
221 // has been created. 238 GetWidget()->non_client_view()->SchedulePaint();
222 if (window_pos->flags & SWP_SHOWWINDOW && GetWidget()->non_client_view()) { 239 }
223 GetWidget()->non_client_view()->Layout(); 240 break;
224 GetWidget()->non_client_view()->SchedulePaint();
225 } 241 }
226 } 242 }
227 243
228 void BrowserFrameWin::OnScreenReaderDetected() { 244 void BrowserFrameWin::OnScreenReaderDetected() {
229 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); 245 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected();
230 NativeWidgetWin::OnScreenReaderDetected(); 246 NativeWidgetWin::OnScreenReaderDetected();
231 } 247 }
232 248
233 bool BrowserFrameWin::ShouldUseNativeFrame() const { 249 bool BrowserFrameWin::ShouldUseNativeFrame() const {
234 // App panel windows draw their own frame. 250 // App panel windows draw their own frame.
(...skipping 27 matching lines...) Expand all
262 void BrowserFrameWin::ShowWithWindowState(ui::WindowShowState show_state) { 278 void BrowserFrameWin::ShowWithWindowState(ui::WindowShowState show_state) {
263 AdjustFrameForImmersiveMode(); 279 AdjustFrameForImmersiveMode();
264 views::NativeWidgetWin::ShowWithWindowState(show_state); 280 views::NativeWidgetWin::ShowWithWindowState(show_state);
265 } 281 }
266 282
267 void BrowserFrameWin::Close() { 283 void BrowserFrameWin::Close() {
268 CloseImmersiveFrame(); 284 CloseImmersiveFrame();
269 views::NativeWidgetWin::Close(); 285 views::NativeWidgetWin::Close();
270 } 286 }
271 287
272 void BrowserFrameWin::OnActivate(UINT action, BOOL minimized, HWND window) {
273 if (action != WA_INACTIVE)
274 CacheMinimizeButtonDelta();
275 views::NativeWidgetWin::OnActivate(action, minimized, window);
276 }
277
278 void BrowserFrameWin::FrameTypeChanged() { 288 void BrowserFrameWin::FrameTypeChanged() {
279 // In Windows 8 metro mode the frame type is set to FRAME_TYPE_FORCE_CUSTOM 289 // In Windows 8 metro mode the frame type is set to FRAME_TYPE_FORCE_CUSTOM
280 // by default. We reset it back to FRAME_TYPE_DEFAULT to ensure that we 290 // by default. We reset it back to FRAME_TYPE_DEFAULT to ensure that we
281 // don't end up defaulting to BrowserNonClientFrameView in all cases. 291 // don't end up defaulting to BrowserNonClientFrameView in all cases.
282 if (base::win::IsMetroProcess()) 292 if (base::win::IsMetroProcess())
283 browser_frame_->set_frame_type(views::Widget::FRAME_TYPE_DEFAULT); 293 browser_frame_->set_frame_type(views::Widget::FRAME_TYPE_DEFAULT);
284 294
285 views::NativeWidgetWin::FrameTypeChanged(); 295 views::NativeWidgetWin::FrameTypeChanged();
286 296
287 // In Windows 8 metro mode we call Show on the BrowserFrame instance to 297 // In Windows 8 metro mode we call Show on the BrowserFrame instance to
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (minimize_button_offset > 0) 349 if (minimize_button_offset > 0)
340 return minimize_button_offset; 350 return minimize_button_offset;
341 351
342 // If we fail to get the minimize button offset via the WM_GETTITLEBARINFOEX 352 // If we fail to get the minimize button offset via the WM_GETTITLEBARINFOEX
343 // message then calculate and return this via the 353 // message then calculate and return this via the
344 // cached_minimize_button_x_delta_ member value. Please see 354 // cached_minimize_button_x_delta_ member value. Please see
345 // CacheMinimizeButtonDelta() for more details. 355 // CacheMinimizeButtonDelta() for more details.
346 DCHECK(cached_minimize_button_x_delta_); 356 DCHECK(cached_minimize_button_x_delta_);
347 357
348 RECT client_rect = {0}; 358 RECT client_rect = {0};
349 GetClientRect(&client_rect); 359 GetClientRect(GetNativeView(), &client_rect);
350 360
351 if (base::i18n::IsRTL()) 361 if (base::i18n::IsRTL())
352 return cached_minimize_button_x_delta_; 362 return cached_minimize_button_x_delta_;
353 else 363 else
354 return client_rect.right - cached_minimize_button_x_delta_; 364 return client_rect.right - cached_minimize_button_x_delta_;
355 } 365 }
356 366
357 void BrowserFrameWin::TabStripDisplayModeChanged() { 367 void BrowserFrameWin::TabStripDisplayModeChanged() {
358 UpdateDWMFrame(); 368 UpdateDWMFrame();
359 } 369 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 current_tab_info->url = base::win::LocalAllocAndCopyString( 582 current_tab_info->url = base::win::LocalAllocAndCopyString(
573 UTF8ToWide(current_tab->GetURL().spec())); 583 UTF8ToWide(current_tab->GetURL().spec()));
574 } 584 }
575 585
576 void BrowserFrameWin::CacheMinimizeButtonDelta() { 586 void BrowserFrameWin::CacheMinimizeButtonDelta() {
577 int minimize_offset = GetMinimizeButtonOffsetForWindow(GetNativeView()); 587 int minimize_offset = GetMinimizeButtonOffsetForWindow(GetNativeView());
578 if (!minimize_offset) 588 if (!minimize_offset)
579 return; 589 return;
580 590
581 RECT rect = {0}; 591 RECT rect = {0};
582 GetClientRect(&rect); 592 GetClientRect(GetNativeView(), &rect);
583 // Calculate and cache the value of the minimize button delta, i.e. the 593 // Calculate and cache the value of the minimize button delta, i.e. the
584 // offset to be applied to the left or right edge of the client rect 594 // offset to be applied to the left or right edge of the client rect
585 // depending on whether the language is RTL or not. 595 // depending on whether the language is RTL or not.
586 // This cached value is only used if the WM_GETTITLEBARINFOEX message fails 596 // This cached value is only used if the WM_GETTITLEBARINFOEX message fails
587 // to get the offset of the minimize button. 597 // to get the offset of the minimize button.
588 if (base::i18n::IsRTL()) 598 if (base::i18n::IsRTL())
589 cached_minimize_button_x_delta_ = minimize_offset; 599 cached_minimize_button_x_delta_ = minimize_offset;
590 else 600 else
591 cached_minimize_button_x_delta_ = rect.right - minimize_offset; 601 cached_minimize_button_x_delta_ = rect.right - minimize_offset;
592 } 602 }
(...skipping 10 matching lines...) Expand all
603 613
604 //////////////////////////////////////////////////////////////////////////////// 614 ////////////////////////////////////////////////////////////////////////////////
605 // NativeBrowserFrame, public: 615 // NativeBrowserFrame, public:
606 616
607 // static 617 // static
608 NativeBrowserFrame* NativeBrowserFrame::CreateNativeBrowserFrame( 618 NativeBrowserFrame* NativeBrowserFrame::CreateNativeBrowserFrame(
609 BrowserFrame* browser_frame, 619 BrowserFrame* browser_frame,
610 BrowserView* browser_view) { 620 BrowserView* browser_view) {
611 return new BrowserFrameWin(browser_frame, browser_view); 621 return new BrowserFrameWin(browser_frame, browser_view);
612 } 622 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame_win.h ('k') | chrome/browser/ui/views/native_constrained_window_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698