summaryrefslogtreecommitdiff
path: root/chromium/ui/base/win
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/ui/base/win
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
downloadqtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/ui/base/win')
-rw-r--r--chromium/ui/base/win/dpi_setup.cc19
-rw-r--r--chromium/ui/base/win/dpi_setup.h22
-rw-r--r--chromium/ui/base/win/events_win.cc372
-rw-r--r--chromium/ui/base/win/extra_sdk_defines.h39
-rw-r--r--chromium/ui/base/win/foreground_helper.h1
-rw-r--r--chromium/ui/base/win/lock_state.cc26
-rw-r--r--chromium/ui/base/win/lock_state.h18
-rw-r--r--chromium/ui/base/win/shell.cc70
-rw-r--r--chromium/ui/base/win/shell.h9
9 files changed, 129 insertions, 447 deletions
diff --git a/chromium/ui/base/win/dpi_setup.cc b/chromium/ui/base/win/dpi_setup.cc
new file mode 100644
index 00000000000..ad4e6e8616e
--- /dev/null
+++ b/chromium/ui/base/win/dpi_setup.cc
@@ -0,0 +1,19 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/win/dpi_setup.h"
+
+#include "ui/base/layout.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/win/dpi.h"
+
+namespace ui {
+namespace win {
+
+void InitDeviceScaleFactor() {
+ gfx::InitDeviceScaleFactor(gfx::GetDPIScale());
+}
+
+} // namespace win
+} // namespace ui
diff --git a/chromium/ui/base/win/dpi_setup.h b/chromium/ui/base/win/dpi_setup.h
new file mode 100644
index 00000000000..a88584996f0
--- /dev/null
+++ b/chromium/ui/base/win/dpi_setup.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_WIN_DPI_SETUP_H_
+#define UI_BASE_WIN_DPI_SETUP_H_
+
+#include "ui/base/ui_export.h"
+
+namespace ui {
+namespace win {
+
+// Initializes the device scale factor. If support is enabled, this will set
+// the best available scale based on the screen's pixel density. This can be
+// affected (overridden) by --force-device-scale-factor=x
+// This function can be called only once for the lifetime of a process.
+UI_EXPORT void InitDeviceScaleFactor();
+
+} // namespace win
+} // namespace ui
+
+#endif // UI_BASE_WIN_DPI_SETUP_H_
diff --git a/chromium/ui/base/win/events_win.cc b/chromium/ui/base/win/events_win.cc
deleted file mode 100644
index 04b9cd058aa..00000000000
--- a/chromium/ui/base/win/events_win.cc
+++ /dev/null
@@ -1,372 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <windowsx.h>
-
-#include "ui/events/event_constants.h"
-
-#include "base/logging.h"
-#include "base/time/time.h"
-#include "base/win/win_util.h"
-#include "ui/events/event_utils.h"
-#include "ui/events/keycodes/keyboard_code_conversion_win.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/win/dpi.h"
-
-namespace ui {
-
-namespace {
-
-// From MSDN: "Mouse" events are flagged with 0xFF515700 if they come
-// from a touch or stylus device. In Vista or later, they are also flagged
-// with 0x80 if they come from touch.
-#define MOUSEEVENTF_FROMTOUCH (0xFF515700 | 0x80)
-
-// Get the native mouse key state from the native event message type.
-int GetNativeMouseKey(const base::NativeEvent& native_event) {
- switch (native_event.message) {
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_NCLBUTTONDBLCLK:
- case WM_NCLBUTTONDOWN:
- case WM_NCLBUTTONUP:
- return MK_LBUTTON;
- case WM_MBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_NCMBUTTONDBLCLK:
- case WM_NCMBUTTONDOWN:
- case WM_NCMBUTTONUP:
- return MK_MBUTTON;
- case WM_RBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_NCRBUTTONDBLCLK:
- case WM_NCRBUTTONDOWN:
- case WM_NCRBUTTONUP:
- return MK_RBUTTON;
- case WM_NCXBUTTONDBLCLK:
- case WM_NCXBUTTONDOWN:
- case WM_NCXBUTTONUP:
- case WM_XBUTTONDBLCLK:
- case WM_XBUTTONDOWN:
- case WM_XBUTTONUP:
- return MK_XBUTTON1;
- }
- return 0;
-}
-
-bool IsButtonDown(const base::NativeEvent& native_event) {
- return ((MK_LBUTTON | MK_MBUTTON | MK_RBUTTON | MK_XBUTTON1 | MK_XBUTTON2) &
- native_event.wParam) != 0;
-}
-
-bool IsClientMouseEvent(const base::NativeEvent& native_event) {
- return native_event.message == WM_MOUSELEAVE ||
- native_event.message == WM_MOUSEHOVER ||
- (native_event.message >= WM_MOUSEFIRST &&
- native_event.message <= WM_MOUSELAST);
-}
-
-bool IsNonClientMouseEvent(const base::NativeEvent& native_event) {
- return native_event.message == WM_NCMOUSELEAVE ||
- native_event.message == WM_NCMOUSEHOVER ||
- (native_event.message >= WM_NCMOUSEMOVE &&
- native_event.message <= WM_NCXBUTTONDBLCLK);
-}
-
-bool IsMouseWheelEvent(const base::NativeEvent& native_event) {
- return native_event.message == WM_MOUSEWHEEL ||
- native_event.message == WM_MOUSEHWHEEL;
-}
-
-bool IsKeyEvent(const base::NativeEvent& native_event) {
- return native_event.message == WM_KEYDOWN ||
- native_event.message == WM_SYSKEYDOWN ||
- native_event.message == WM_CHAR ||
- native_event.message == WM_KEYUP ||
- native_event.message == WM_SYSKEYUP;
-}
-
-// Returns a mask corresponding to the set of pressed modifier keys.
-// Checks the current global state and the state sent by client mouse messages.
-int KeyStateFlagsFromNative(const base::NativeEvent& native_event) {
- int flags = 0;
- flags |= base::win::IsAltPressed() ? EF_ALT_DOWN : EF_NONE;
- flags |= base::win::IsShiftPressed() ? EF_SHIFT_DOWN : EF_NONE;
- flags |= base::win::IsCtrlPressed() ? EF_CONTROL_DOWN : EF_NONE;
-
- // Check key messages for the extended key flag.
- if (IsKeyEvent(native_event))
- flags |= (HIWORD(native_event.lParam) & KF_EXTENDED) ? EF_EXTENDED : 0;
-
- // Most client mouse messages include key state information.
- if (IsClientMouseEvent(native_event)) {
- int win_flags = GET_KEYSTATE_WPARAM(native_event.wParam);
- flags |= (win_flags & MK_SHIFT) ? EF_SHIFT_DOWN : 0;
- flags |= (win_flags & MK_CONTROL) ? EF_CONTROL_DOWN : 0;
- }
-
- return flags;
-}
-
-// Returns a mask corresponding to the set of pressed mouse buttons.
-// This includes the button of the given message, even if it is being released.
-int MouseStateFlagsFromNative(const base::NativeEvent& native_event) {
- int win_flags = GetNativeMouseKey(native_event);
-
- // Client mouse messages provide key states in their WPARAMs.
- if (IsClientMouseEvent(native_event))
- win_flags |= GET_KEYSTATE_WPARAM(native_event.wParam);
-
- int flags = 0;
- flags |= (win_flags & MK_LBUTTON) ? EF_LEFT_MOUSE_BUTTON : 0;
- flags |= (win_flags & MK_MBUTTON) ? EF_MIDDLE_MOUSE_BUTTON : 0;
- flags |= (win_flags & MK_RBUTTON) ? EF_RIGHT_MOUSE_BUTTON : 0;
- flags |= IsNonClientMouseEvent(native_event) ? EF_IS_NON_CLIENT : 0;
- return flags;
-}
-
-} // namespace
-
-void UpdateDeviceList() {
- NOTIMPLEMENTED();
-}
-
-EventType EventTypeFromNative(const base::NativeEvent& native_event) {
- switch (native_event.message) {
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- case WM_CHAR:
- return ET_KEY_PRESSED;
- case WM_KEYUP:
- case WM_SYSKEYUP:
- return ET_KEY_RELEASED;
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- case WM_MBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_NCLBUTTONDBLCLK:
- case WM_NCLBUTTONDOWN:
- case WM_NCMBUTTONDBLCLK:
- case WM_NCMBUTTONDOWN:
- case WM_NCRBUTTONDBLCLK:
- case WM_NCRBUTTONDOWN:
- case WM_NCXBUTTONDBLCLK:
- case WM_NCXBUTTONDOWN:
- case WM_RBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_XBUTTONDBLCLK:
- case WM_XBUTTONDOWN:
- return ET_MOUSE_PRESSED;
- case WM_LBUTTONUP:
- case WM_MBUTTONUP:
- case WM_NCLBUTTONUP:
- case WM_NCMBUTTONUP:
- case WM_NCRBUTTONUP:
- case WM_NCXBUTTONUP:
- case WM_RBUTTONUP:
- case WM_XBUTTONUP:
- return ET_MOUSE_RELEASED;
- case WM_MOUSEMOVE:
- return IsButtonDown(native_event) ? ET_MOUSE_DRAGGED : ET_MOUSE_MOVED;
- case WM_NCMOUSEMOVE:
- return ET_MOUSE_MOVED;
- case WM_MOUSEWHEEL:
- return ET_MOUSEWHEEL;
- case WM_MOUSELEAVE:
- case WM_NCMOUSELEAVE:
- return ET_MOUSE_EXITED;
- default:
- // We can't NOTREACHED() here, since this function can be called for any
- // message.
- break;
- }
- return ET_UNKNOWN;
-}
-
-int EventFlagsFromNative(const base::NativeEvent& native_event) {
- int flags = KeyStateFlagsFromNative(native_event);
- if (IsMouseEvent(native_event))
- flags |= MouseStateFlagsFromNative(native_event);
-
- return flags;
-}
-
-base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) {
- return base::TimeDelta::FromMilliseconds(native_event.time);
-}
-
-gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) {
- // Note: Wheel events are considered client, but their position is in screen
- // coordinates.
- // Client message. The position is contained in the LPARAM.
- if (IsClientMouseEvent(native_event) && !IsMouseWheelEvent(native_event))
- return gfx::Point(native_event.lParam);
- DCHECK(IsNonClientMouseEvent(native_event) ||
- IsMouseWheelEvent(native_event));
- // Non-client message. The position is contained in a POINTS structure in
- // LPARAM, and is in screen coordinates so we have to convert to client.
- POINT native_point = { GET_X_LPARAM(native_event.lParam),
- GET_Y_LPARAM(native_event.lParam) };
- ScreenToClient(native_event.hwnd, &native_point);
- gfx::Point location(native_point);
- location = gfx::win::ScreenToDIPPoint(location);
- return location;
-}
-
-gfx::Point EventSystemLocationFromNative(
- const base::NativeEvent& native_event) {
- // TODO(ben): Needs to always return screen position here. Returning normal
- // origin for now since that's obviously wrong.
- return gfx::Point(0, 0);
-}
-
-KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
- return KeyboardCodeForWindowsKeyCode(native_event.wParam);
-}
-
-bool IsMouseEvent(const base::NativeEvent& native_event) {
- return IsClientMouseEvent(native_event) ||
- IsNonClientMouseEvent(native_event);
-}
-
-int GetChangedMouseButtonFlagsFromNative(
- const base::NativeEvent& native_event) {
- switch (GetNativeMouseKey(native_event)) {
- case MK_LBUTTON:
- return EF_LEFT_MOUSE_BUTTON;
- case MK_MBUTTON:
- return EF_MIDDLE_MOUSE_BUTTON;
- case MK_RBUTTON:
- return EF_RIGHT_MOUSE_BUTTON;
- // TODO: add support for MK_XBUTTON1.
- default:
- break;
- }
- return 0;
-}
-
-gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) {
- DCHECK(native_event.message == WM_MOUSEWHEEL);
- return gfx::Vector2d(0, GET_WHEEL_DELTA_WPARAM(native_event.wParam));
-}
-
-void ClearTouchIdIfReleased(const base::NativeEvent& xev) {
- NOTIMPLEMENTED();
-}
-
-int GetTouchId(const base::NativeEvent& xev) {
- NOTIMPLEMENTED();
- return 0;
-}
-
-float GetTouchRadiusX(const base::NativeEvent& native_event) {
- NOTIMPLEMENTED();
- return 1.0;
-}
-
-float GetTouchRadiusY(const base::NativeEvent& native_event) {
- NOTIMPLEMENTED();
- return 1.0;
-}
-
-float GetTouchAngle(const base::NativeEvent& native_event) {
- NOTIMPLEMENTED();
- return 0.0;
-}
-
-float GetTouchForce(const base::NativeEvent& native_event) {
- NOTIMPLEMENTED();
- return 0.0;
-}
-
-bool GetScrollOffsets(const base::NativeEvent& native_event,
- float* x_offset,
- float* y_offset,
- float* x_offset_ordinal,
- float* y_offset_ordinal,
- int* finger_count) {
- // Not supported in Windows.
- NOTIMPLEMENTED();
- return false;
-}
-
-bool GetFlingData(const base::NativeEvent& native_event,
- float* vx,
- float* vy,
- float* vx_ordinal,
- float* vy_ordinal,
- bool* is_cancel) {
- // Not supported in Windows.
- NOTIMPLEMENTED();
- return false;
-}
-
-bool GetGestureTimes(const base::NativeEvent& native_event,
- double* start_time,
- double* end_time) {
- // Not supported in Windows.
- *start_time = 0;
- *end_time = 0;
- return false;
-}
-
-void SetNaturalScroll(bool enabled) {
- NOTIMPLEMENTED();
-}
-
-bool IsNaturalScrollEnabled() {
- NOTIMPLEMENTED();
- return false;
-}
-
-bool IsTouchpadEvent(const base::NativeEvent& event) {
- NOTIMPLEMENTED();
- return false;
-}
-
-bool IsNoopEvent(const base::NativeEvent& event) {
- return event.message == WM_USER + 310;
-}
-
-base::NativeEvent CreateNoopEvent() {
- MSG event = { NULL };
- event.message = WM_USER + 310;
- return event;
-}
-
-int GetModifiersFromACCEL(const ACCEL& accel) {
- int modifiers = EF_NONE;
- if (accel.fVirt & FSHIFT)
- modifiers |= EF_SHIFT_DOWN;
- if (accel.fVirt & FCONTROL)
- modifiers |= EF_CONTROL_DOWN;
- if (accel.fVirt & FALT)
- modifiers |= EF_ALT_DOWN;
- return modifiers;
-}
-
-int GetModifiersFromKeyState() {
- int modifiers = EF_NONE;
- if (base::win::IsShiftPressed())
- modifiers |= EF_SHIFT_DOWN;
- if (base::win::IsCtrlPressed())
- modifiers |= EF_CONTROL_DOWN;
- if (base::win::IsAltPressed())
- modifiers |= EF_ALT_DOWN;
- if (base::win::IsAltGrPressed())
- modifiers |= EF_ALTGR_DOWN;
- return modifiers;
-}
-
-// Windows emulates mouse messages for touch events.
-bool IsMouseEventFromTouch(UINT message) {
- return (message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST) &&
- (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) ==
- MOUSEEVENTF_FROMTOUCH;
-}
-
-} // namespace ui
diff --git a/chromium/ui/base/win/extra_sdk_defines.h b/chromium/ui/base/win/extra_sdk_defines.h
deleted file mode 100644
index 455791ed053..00000000000
--- a/chromium/ui/base/win/extra_sdk_defines.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_BASE_WIN_EXTRA_SDK_DEFINES_H_
-#define UI_BASE_WIN_EXTRA_SDK_DEFINES_H_
-
-#include <windows.h>
-#include <winuser.h>
-
-// TODO(tommi): These should be removed once we switch over to version 8 of the
-// Windows SDK.
-#if !defined(WM_POINTERDOWN)
-#define WM_POINTERDOWN 0x0246
-#endif // WM_POINTERDOWN
-
-#if !defined(WM_POINTERUP)
-#define WM_POINTERUP 0x0247
-#endif // WM_POINTERUP
-
-#ifndef POINTER_MESSAGE_FLAG_FIRSTBUTTON
-#define POINTER_MESSAGE_FLAG_FIRSTBUTTON 0x00000010
-#endif // POINTER_MESSAGE_FLAG_FIRSTBUTTON
-
-#ifndef IS_POINTER_FLAG_SET_WPARAM
-#define IS_POINTER_FLAG_SET_WPARAM(wParam, flag) \
- (((DWORD)HIWORD(wParam) & (flag)) == (flag))
-#endif // IS_POINTER_FLAG_SET_WPARAM
-
-#ifndef IS_POINTER_FIRSTBUTTON_WPARAM
-#define IS_POINTER_FIRSTBUTTON_WPARAM(wParam) \
- IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_FIRSTBUTTON)
-#endif // IS_POINTER_FIRSTBUTTON_WPARAM
-
-#if !defined(WM_POINTERUPDATE)
-#define WM_POINTERUPDATE 0x0245
-#endif // WM_POINTERUPDATE
-
-#endif // UI_BASE_WIN_EXTRA_SDK_DEFINES_H_
diff --git a/chromium/ui/base/win/foreground_helper.h b/chromium/ui/base/win/foreground_helper.h
index e8101a05b5f..a2d9ea2a541 100644
--- a/chromium/ui/base/win/foreground_helper.h
+++ b/chromium/ui/base/win/foreground_helper.h
@@ -6,6 +6,7 @@
#define UI_BASE_WIN_FOREGROUND_HELPER_H_
#include "base/logging.h"
+#include "ui/base/ui_export.h"
#include "ui/gfx/win/window_impl.h"
namespace ui {
diff --git a/chromium/ui/base/win/lock_state.cc b/chromium/ui/base/win/lock_state.cc
new file mode 100644
index 00000000000..c56eae429fc
--- /dev/null
+++ b/chromium/ui/base/win/lock_state.cc
@@ -0,0 +1,26 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/win/lock_state.h"
+
+#include <windows.h>
+
+namespace ui {
+
+bool IsWorkstationLocked() {
+ bool is_locked = true;
+ HDESK input_desk = ::OpenInputDesktop(0, 0, GENERIC_READ);
+ if (input_desk) {
+ wchar_t name[256] = {0};
+ DWORD needed = 0;
+ if (::GetUserObjectInformation(
+ input_desk, UOI_NAME, name, sizeof(name), &needed)) {
+ is_locked = lstrcmpi(name, L"default") != 0;
+ }
+ ::CloseDesktop(input_desk);
+ }
+ return is_locked;
+}
+
+} // namespace ui
diff --git a/chromium/ui/base/win/lock_state.h b/chromium/ui/base/win/lock_state.h
new file mode 100644
index 00000000000..637be034a50
--- /dev/null
+++ b/chromium/ui/base/win/lock_state.h
@@ -0,0 +1,18 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_WIN_LOCK_STATE_H_
+#define UI_BASE_WIN_LOCK_STATE_H_
+
+#include "base/basictypes.h"
+#include "ui/base/ui_export.h"
+
+namespace ui {
+
+// Returns true if the screen is currently locked.
+UI_EXPORT bool IsWorkstationLocked();
+
+} // namespace ui
+
+#endif // UI_BASE_WIN_LOCK_STATE_H_
diff --git a/chromium/ui/base/win/shell.cc b/chromium/ui/base/win/shell.cc
index 0f955375e52..ff1a4ffec41 100644
--- a/chromium/ui/base/win/shell.cc
+++ b/chromium/ui/base/win/shell.cc
@@ -22,42 +22,6 @@
namespace ui {
namespace win {
-namespace {
-
-void SetAppDetailsForWindow(const string16& app_id,
- const string16& app_icon,
- const string16& relaunch_command,
- const string16& relaunch_display_name,
- HWND hwnd) {
- // This functionality is only available on Win7+. It also doesn't make sense
- // to do this for Chrome Metro.
- if (base::win::GetVersion() < base::win::VERSION_WIN7 ||
- base::win::IsMetroProcess())
- return;
- base::win::ScopedComPtr<IPropertyStore> pps;
- HRESULT result = SHGetPropertyStoreForWindow(
- hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive()));
- if (S_OK == result) {
- if (!app_id.empty())
- base::win::SetAppIdForPropertyStore(pps, app_id.c_str());
- if (!app_icon.empty()) {
- base::win::SetStringValueForPropertyStore(
- pps, PKEY_AppUserModel_RelaunchIconResource, app_icon.c_str());
- }
- if (!relaunch_command.empty()) {
- base::win::SetStringValueForPropertyStore(
- pps, PKEY_AppUserModel_RelaunchCommand, relaunch_command.c_str());
- }
- if (!relaunch_display_name.empty()) {
- base::win::SetStringValueForPropertyStore(
- pps, PKEY_AppUserModel_RelaunchDisplayNameResource,
- relaunch_display_name.c_str());
- }
- }
-}
-
-} // namespace
-
// Show the Windows "Open With" dialog box to ask the user to pick an app to
// open the file with.
bool OpenItemWithExternalApp(const string16& full_path) {
@@ -114,6 +78,40 @@ bool PreventWindowFromPinning(HWND hwnd) {
pps, PKEY_AppUserModel_PreventPinning, true);
}
+// TODO(calamity): investigate moving this out of the UI thread as COM
+// operations may spawn nested message loops which can cause issues.
+void SetAppDetailsForWindow(const string16& app_id,
+ const string16& app_icon,
+ const string16& relaunch_command,
+ const string16& relaunch_display_name,
+ HWND hwnd) {
+ // This functionality is only available on Win7+. It also doesn't make sense
+ // to do this for Chrome Metro.
+ if (base::win::GetVersion() < base::win::VERSION_WIN7 ||
+ base::win::IsMetroProcess())
+ return;
+ base::win::ScopedComPtr<IPropertyStore> pps;
+ HRESULT result = SHGetPropertyStoreForWindow(
+ hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive()));
+ if (S_OK == result) {
+ if (!app_id.empty())
+ base::win::SetAppIdForPropertyStore(pps, app_id.c_str());
+ if (!app_icon.empty()) {
+ base::win::SetStringValueForPropertyStore(
+ pps, PKEY_AppUserModel_RelaunchIconResource, app_icon.c_str());
+ }
+ if (!relaunch_command.empty()) {
+ base::win::SetStringValueForPropertyStore(
+ pps, PKEY_AppUserModel_RelaunchCommand, relaunch_command.c_str());
+ }
+ if (!relaunch_display_name.empty()) {
+ base::win::SetStringValueForPropertyStore(
+ pps, PKEY_AppUserModel_RelaunchDisplayNameResource,
+ relaunch_display_name.c_str());
+ }
+ }
+}
+
void SetAppIdForWindow(const string16& app_id, HWND hwnd) {
SetAppDetailsForWindow(app_id, string16(), string16(), string16(), hwnd);
}
diff --git a/chromium/ui/base/win/shell.h b/chromium/ui/base/win/shell.h
index 31dbb889c2c..e85d2b43fdc 100644
--- a/chromium/ui/base/win/shell.h
+++ b/chromium/ui/base/win/shell.h
@@ -16,6 +16,7 @@ class FilePath;
namespace ui {
namespace win {
+
// Open or run a file via the Windows shell. In the event that there is no
// default application registered for the file specified by 'full_path',
// ask the user, via the Windows "Open With" dialog.
@@ -46,6 +47,14 @@ bool OpenItemWithExternalApp(const string16& full_path);
// taskbar menu of the specified window.
UI_EXPORT bool PreventWindowFromPinning(HWND hwnd);
+// Sets the application id, app icon, relaunch command and relaunch display name
+// for the given window.
+UI_EXPORT void SetAppDetailsForWindow(const string16& app_id,
+ const string16& app_icon,
+ const string16& relaunch_command,
+ const string16& relaunch_display_name,
+ HWND hwnd);
+
// Sets the application id given as the Application Model ID for the window
// specified. This method is used to insure that different web applications
// do not group together on the Win7 task bar.