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

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: Revert using Singleton pattern for PowerMonitor 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 // Reference the Signaler defined in the global PowerMonitor instance.
vandebo (ex-Chrome) 2012/10/29 18:04:38 Remove or update this comment to say *why* this is
Hongbo Min 2012/10/30 14:33:47 Done.
44 base::PowerMonitor::Signaler* g_power_signaler = NULL;
45
43 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a 46 // 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, 47 // 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 48 // so we install hooks to determine if we got a mouse up and assume the move
46 // completed. 49 // completed.
47 class MoveLoopMouseWatcher { 50 class MoveLoopMouseWatcher {
48 public: 51 public:
49 explicit MoveLoopMouseWatcher(HWNDMessageHandler* host); 52 explicit MoveLoopMouseWatcher(HWNDMessageHandler* host);
50 ~MoveLoopMouseWatcher(); 53 ~MoveLoopMouseWatcher();
51 54
52 // Returns true if the mouse is up, or if we couldn't install the hook. 55 // 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), 381 is_right_mouse_pressed_on_caption_(false),
379 lock_updates_count_(0), 382 lock_updates_count_(0),
380 destroyed_(NULL), 383 destroyed_(NULL),
381 ignore_window_pos_changes_(false), 384 ignore_window_pos_changes_(false),
382 ALLOW_THIS_IN_INITIALIZER_LIST(ignore_pos_changes_factory_(this)), 385 ALLOW_THIS_IN_INITIALIZER_LIST(ignore_pos_changes_factory_(this)),
383 last_monitor_(NULL), 386 last_monitor_(NULL),
384 use_layered_buffer_(false), 387 use_layered_buffer_(false),
385 layered_alpha_(255), 388 layered_alpha_(255),
386 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)), 389 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)),
387 can_update_layered_window_(true) { 390 can_update_layered_window_(true) {
391 if (g_power_signaler == NULL && base::PowerMonitor::Get())
392 g_power_signaler = base::PowerMonitor::Get()->GetSignalerOnce();
388 } 393 }
389 394
390 HWNDMessageHandler::~HWNDMessageHandler() { 395 HWNDMessageHandler::~HWNDMessageHandler() {
391 delegate_ = NULL; 396 delegate_ = NULL;
392 if (destroyed_ != NULL) 397 if (destroyed_ != NULL)
393 *destroyed_ = true; 398 *destroyed_ = true;
394 // Prevent calls back into this class via WNDPROC now that we've been 399 // Prevent calls back into this class via WNDPROC now that we've been
395 // destroyed. 400 // destroyed.
396 ClearUserData(); 401 ClearUserData();
397 } 402 }
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 #endif 1845 #endif
1841 } 1846 }
1842 } else { 1847 } else {
1843 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. 1848 // TODO(msw): Find a better solution for this crbug.com/93530 workaround.
1844 // Some scenarios otherwise fail to validate minimized app/popup windows. 1849 // Some scenarios otherwise fail to validate minimized app/popup windows.
1845 ValidateRect(hwnd(), NULL); 1850 ValidateRect(hwnd(), NULL);
1846 } 1851 }
1847 } 1852 }
1848 1853
1849 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { 1854 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) {
1850 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 1855 CHECK(!g_power_signaler);
1851 if (monitor) 1856 g_power_signaler->ProcessWmPowerBroadcastMessage(power_event);
1852 monitor->ProcessWmPowerBroadcastMessage(power_event); 1857
1853 SetMsgHandled(FALSE); 1858 SetMsgHandled(FALSE);
1854 return 0; 1859 return 0;
1855 } 1860 }
1856 1861
1857 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, 1862 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message,
1858 WPARAM w_param, 1863 WPARAM w_param,
1859 LPARAM l_param) { 1864 LPARAM l_param) {
1860 SetMsgHandled(FALSE); 1865 SetMsgHandled(FALSE);
1861 return 0; 1866 return 0;
1862 } 1867 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 DwmExtendFrameIntoClientArea(hwnd(), &m); 2080 DwmExtendFrameIntoClientArea(hwnd(), &m);
2076 } 2081 }
2077 if (window_pos->flags & SWP_SHOWWINDOW) 2082 if (window_pos->flags & SWP_SHOWWINDOW)
2078 delegate_->HandleVisibilityChanged(true); 2083 delegate_->HandleVisibilityChanged(true);
2079 else if (window_pos->flags & SWP_HIDEWINDOW) 2084 else if (window_pos->flags & SWP_HIDEWINDOW)
2080 delegate_->HandleVisibilityChanged(false); 2085 delegate_->HandleVisibilityChanged(false);
2081 SetMsgHandled(FALSE); 2086 SetMsgHandled(FALSE);
2082 } 2087 }
2083 2088
2084 } // namespace views 2089 } // namespace views
OLDNEW
« content/browser/gamepad/gamepad_test_helpers.cc ('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