Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / win / foreground_helper.h
blob8387c13b7eea9b62d7450106c453facafbf2211c
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
3 // found in the LICENSE file.
5 #ifndef UI_BASE_WIN_FOREGROUND_HELPER_H_
6 #define UI_BASE_WIN_FOREGROUND_HELPER_H_
8 #include "base/logging.h"
9 #include "ui/base/ui_base_export.h"
10 #include "ui/gfx/win/window_impl.h"
12 namespace ui {
14 // Helper class for moving a window to the foreground.
15 // Windows XP and later will not allow a window which is in the background to
16 // move to the foreground, unless requested by the current window in the
17 // foreground. For automated testing, we really want some of our windows
18 // to be capable of moving to the foreground.
20 // This is probably leveraging a windows bug.
21 class UI_BASE_EXPORT ForegroundHelper : public gfx::WindowImpl {
22 public:
23 ForegroundHelper() : window_(NULL) { }
25 CR_BEGIN_MSG_MAP_EX(ForegroundHelper)
26 CR_MSG_WM_HOTKEY(OnHotKey)
27 CR_END_MSG_MAP()
29 // Brings a window into the foreground.
30 // Can be called from any window, even if the caller is not the
31 // foreground window.
32 static HRESULT SetForeground(HWND window);
34 private:
35 HRESULT ForegroundHotKey(HWND window);
37 // Handle the registered Hotkey being pressed.
38 void OnHotKey(int id, UINT vcode, UINT modifiers);
40 HWND window_;
42 DISALLOW_COPY_AND_ASSIGN(ForegroundHelper);
45 } // namespace ui
47 #endif // UI_BASE_WIN_FOREGROUND_HELPER_H_