[code-health] Update shortcut_properties.py for python3
Bug: 941669 Change-Id: I204abfe771e2e8d143d698f45df09d3c4c990d48 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3892284 Auto-Submit: Fabrice de Gans <fdegans@chromium.org> Commit-Queue: Greg Thompson <grt@chromium.org> Reviewed-by: Greg Thompson <grt@chromium.org> Cr-Commit-Position: refs/heads/main@{#1046294}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
388556db0d
commit
027bd31ec4
15
chrome/installer/tools/shortcut_properties.py
Normal file → Executable file
15
chrome/installer/tools/shortcut_properties.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env vpython3
|
||||
# Copyright 2015 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
@ -8,7 +9,7 @@ This is required to confirm correctness of properties that aren't readily
|
||||
available in Windows UI.
|
||||
|
||||
If you run into "ImportError: No module named pywintypes":
|
||||
Run this script with vpython instead.
|
||||
Run this script with vpython3 instead.
|
||||
"""
|
||||
|
||||
import optparse
|
||||
@ -24,7 +25,7 @@ def BuildPKeyToNameMapping():
|
||||
# The pscon module contains a number of well-known PKey values. Scan through
|
||||
# the module picking out anything that looks plausibly like a PROPERTYKEY (a
|
||||
# tuple of a PyIID and an int), and map it to its name in the module.
|
||||
return {item: name for (name, item) in pscon.__dict__.iteritems() if (
|
||||
return {item: name for (name, item) in pscon.__dict__.items() if (
|
||||
isinstance(item, tuple) and
|
||||
len(item) == 2 and
|
||||
isinstance(item[1], int))}
|
||||
@ -33,23 +34,23 @@ def BuildPKeyToNameMapping():
|
||||
def PrintShortcutProperties(shortcut_path, dump_all):
|
||||
properties = propsys.SHGetPropertyStoreFromParsingName(shortcut_path)
|
||||
|
||||
print 'Known properties (--dump-all for more):'
|
||||
print('Known properties (--dump-all for more):')
|
||||
|
||||
app_id = properties.GetValue(pscon.PKEY_AppUserModel_ID).GetValue()
|
||||
print '\tAppUserModelId => "%s"' % app_id
|
||||
print('\tAppUserModelId => "%s"' % app_id)
|
||||
|
||||
# Hard code PKEY_AppUserModel_IsDualMode as pscon doesn't support it.
|
||||
PKEY_AppUserModel_IsDualMode = (IID('{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}'),
|
||||
11)
|
||||
dual_mode = properties.GetValue(PKEY_AppUserModel_IsDualMode).GetValue()
|
||||
print '\tDual Mode => "%s"' % dual_mode
|
||||
print('\tDual Mode => "%s"' % dual_mode)
|
||||
|
||||
# Dump all other properties with their raw ID if requested, add them above
|
||||
# over time as we explicitly care about more properties, see propkey.h or
|
||||
# pscon.py for a reference of existing PKEYs' meaning.
|
||||
if dump_all:
|
||||
key_to_name = BuildPKeyToNameMapping()
|
||||
print '\nOther properties:'
|
||||
print('\nOther properties:')
|
||||
for i in range(0, properties.GetCount()):
|
||||
property_key = properties.GetAt(i)
|
||||
# |property_key| is a tuple of an IID identifying the format and an int
|
||||
@ -59,7 +60,7 @@ def PrintShortcutProperties(shortcut_path, dump_all):
|
||||
# propkey.h.
|
||||
key_name = key_to_name.get(property_key, str(property_key))
|
||||
property_value = properties.GetValue(property_key).GetValue()
|
||||
print '\t%s => "%s"' % (key_name, property_value)
|
||||
print('\t%s => "%s"' % (key_name, property_value))
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -3,7 +3,7 @@
|
||||
When Chrome is installed on Windows, it creates a shortcut on the desktop that
|
||||
launches Chrome. It also adds the same shortcut to the start menu. These
|
||||
shortcuts do not specify a profile, so they launch Chrome with the most recently
|
||||
used profile.
|
||||
used profile.
|
||||
|
||||
Windows allows users to pin applications to the taskbar. When a user
|
||||
pins an application to the taskbar, Windows looks for a desktop shortcut that
|
||||
@ -67,9 +67,12 @@ This badged icon is also used in the tab preview for a Chrome window.
|
||||
## Diagnosing Issues
|
||||
To dump a taskbar icon's properties, run this command:
|
||||
|
||||
`python \src\chromium\src\chrome\installer\tools\shortcut_properties.py --dump-all <user dir>\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar`
|
||||
```
|
||||
vpython3 \src\chromium\src\chrome\installer\tools\shortcut_properties.py \
|
||||
--dump-all \
|
||||
"%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
|
||||
```
|
||||
|
||||
This shows you the properties of all the taskbar pinned icons. If the taskbar
|
||||
icon is in a subdirectory of ImplicitApps, pass that directory to
|
||||
shortcut_properties.py.
|
||||
|
||||
|
Reference in New Issue
Block a user