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

Side by Side Diff: ui/views/win/hwnd_message_handler.cc

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: update Created 8 years, 1 month 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
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 "ui/views/win/hwnd_message_handler.h" 5 #include "ui/views/win/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/system_monitor/system_monitor.h" 11 #include "base/power_monitor/power_monitor.h"
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #include "ui/base/events/event.h" 13 #include "ui/base/events/event.h"
14 #include "ui/base/keycodes/keyboard_code_conversion_win.h" 14 #include "ui/base/keycodes/keyboard_code_conversion_win.h"
15 #include "ui/base/native_theme/native_theme_win.h" 15 #include "ui/base/native_theme/native_theme_win.h"
16 #include "ui/base/win/hwnd_util.h" 16 #include "ui/base/win/hwnd_util.h"
17 #include "ui/base/win/mouse_wheel_util.h" 17 #include "ui/base/win/mouse_wheel_util.h"
18 #include "ui/base/win/shell.h" 18 #include "ui/base/win/shell.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/canvas_paint.h" 20 #include "ui/gfx/canvas_paint.h"
21 #include "ui/gfx/canvas_skia_paint.h" 21 #include "ui/gfx/canvas_skia_paint.h"
(...skipping 11 matching lines...) Expand all
33 #include "ui/views/win/scoped_fullscreen_visibility.h" 33 #include "ui/views/win/scoped_fullscreen_visibility.h"
34 34
35 #if !defined(USE_AURA) 35 #if !defined(USE_AURA)
36 #include "ui/views/accessibility/native_view_accessibility_win.h" 36 #include "ui/views/accessibility/native_view_accessibility_win.h"
37 #include "ui/views/widget/child_window_message_processor.h" 37 #include "ui/views/widget/child_window_message_processor.h"
38 #endif 38 #endif
39 39
40 namespace views { 40 namespace views {
41 namespace { 41 namespace {
42 42
43 // Used to signal the power event when receiving Windows power broadcast
44 // message.
45 base::PowerMonitor::Signaler* g_power_signaler = NULL;
46
43 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a 47 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a
44 // move. win32 doesn't appear to offer a way to determine the result of a move, 48 // move. win32 doesn't appear to offer a way to determine the result of a move,
45 // so we install hooks to determine if we got a mouse up and assume the move 49 // so we install hooks to determine if we got a mouse up and assume the move
46 // completed. 50 // completed.
47 class MoveLoopMouseWatcher { 51 class MoveLoopMouseWatcher {
48 public: 52 public:
49 explicit MoveLoopMouseWatcher(HWNDMessageHandler* host); 53 explicit MoveLoopMouseWatcher(HWNDMessageHandler* host);
50 ~MoveLoopMouseWatcher(); 54 ~MoveLoopMouseWatcher();
51 55
52 // Returns true if the mouse is up, or if we couldn't install the hook. 56 // Returns true if the mouse is up, or if we couldn't install the hook.
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 is_right_mouse_pressed_on_caption_(false), 382 is_right_mouse_pressed_on_caption_(false),
379 lock_updates_count_(0), 383 lock_updates_count_(0),
380 destroyed_(NULL), 384 destroyed_(NULL),
381 ignore_window_pos_changes_(false), 385 ignore_window_pos_changes_(false),
382 ALLOW_THIS_IN_INITIALIZER_LIST(ignore_pos_changes_factory_(this)), 386 ALLOW_THIS_IN_INITIALIZER_LIST(ignore_pos_changes_factory_(this)),
383 last_monitor_(NULL), 387 last_monitor_(NULL),
384 use_layered_buffer_(false), 388 use_layered_buffer_(false),
385 layered_alpha_(255), 389 layered_alpha_(255),
386 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)), 390 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)),
387 can_update_layered_window_(true) { 391 can_update_layered_window_(true) {
392 if (g_power_signaler == NULL && base::PowerMonitor::Get())
393 g_power_signaler = base::PowerMonitor::Get()->GetSignalerOnce();
388 } 394 }
389 395
390 HWNDMessageHandler::~HWNDMessageHandler() { 396 HWNDMessageHandler::~HWNDMessageHandler() {
391 delegate_ = NULL; 397 delegate_ = NULL;
392 if (destroyed_ != NULL) 398 if (destroyed_ != NULL)
393 *destroyed_ = true; 399 *destroyed_ = true;
394 // Prevent calls back into this class via WNDPROC now that we've been 400 // Prevent calls back into this class via WNDPROC now that we've been
395 // destroyed. 401 // destroyed.
396 ClearUserData(); 402 ClearUserData();
397 } 403 }
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 #endif 1846 #endif
1841 } 1847 }
1842 } else { 1848 } else {
1843 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. 1849 // TODO(msw): Find a better solution for this crbug.com/93530 workaround.
1844 // Some scenarios otherwise fail to validate minimized app/popup windows. 1850 // Some scenarios otherwise fail to validate minimized app/popup windows.
1845 ValidateRect(hwnd(), NULL); 1851 ValidateRect(hwnd(), NULL);
1846 } 1852 }
1847 } 1853 }
1848 1854
1849 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { 1855 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) {
1850 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 1856 CHECK(!g_power_signaler);
vandebo (ex-Chrome) 2012/10/30 20:41:24 CHECK(g_power_signaler)
vandebo (ex-Chrome) 2012/10/30 20:41:24 Wrap both of these lines in an if (base::SystemMon
Hongbo Min 2012/10/31 12:52:50 Done.
Hongbo Min 2012/10/31 12:52:50 Done.
vandebo (ex-Chrome) 2012/10/31 17:30:34 This didn't get done.
Hongbo Min 2012/11/01 09:26:57 Done.
1851 if (monitor) 1857 g_power_signaler->ProcessWmPowerBroadcastMessage(power_event);
1852 monitor->ProcessWmPowerBroadcastMessage(power_event); 1858
1853 SetMsgHandled(FALSE); 1859 SetMsgHandled(FALSE);
1854 return 0; 1860 return 0;
1855 } 1861 }
1856 1862
1857 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, 1863 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message,
1858 WPARAM w_param, 1864 WPARAM w_param,
1859 LPARAM l_param) { 1865 LPARAM l_param) {
1860 SetMsgHandled(FALSE); 1866 SetMsgHandled(FALSE);
1861 return 0; 1867 return 0;
1862 } 1868 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 DwmExtendFrameIntoClientArea(hwnd(), &m); 2081 DwmExtendFrameIntoClientArea(hwnd(), &m);
2076 } 2082 }
2077 if (window_pos->flags & SWP_SHOWWINDOW) 2083 if (window_pos->flags & SWP_SHOWWINDOW)
2078 delegate_->HandleVisibilityChanged(true); 2084 delegate_->HandleVisibilityChanged(true);
2079 else if (window_pos->flags & SWP_HIDEWINDOW) 2085 else if (window_pos->flags & SWP_HIDEWINDOW)
2080 delegate_->HandleVisibilityChanged(false); 2086 delegate_->HandleVisibilityChanged(false);
2081 SetMsgHandled(FALSE); 2087 SetMsgHandled(FALSE);
2082 } 2088 }
2083 2089
2084 } // namespace views 2090 } // namespace views
OLDNEW
« net/url_request/url_request_job.h ('K') | « net/url_request/url_request_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698