-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pin Brave to taskbar from FirstRun dialog #14311
Conversation
05514ff
to
2ef34d3
Compare
2ef34d3
to
ecaaa9d
Compare
ecaaa9d
to
4962476
Compare
if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) | ||
return; | ||
|
||
ShellUtil::ShortcutProperties properties(ShellUtil::CURRENT_USER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q. If we call properties.set_pin_to_taskbar(true)
, then ShellUtil::PinShortcut() will be called. https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/util/shell_util.h;l=865
To me, Chromium's implementation looks quite similar to FF's implementation but more modern as they're using ComPtr(RAII obj?). Doesn't Chromium's implementation work and is it why you brought implementation from FF?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q. If we call
properties.set_pin_to_taskbar(true)
, then ShellUtil::PinShortcut() will be called. https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/util/shell_util.h;l=865
properties.set_pin_to_taskbar(true)
will not work for Win10 and later version.
AFAIK, taskbarpin
is disabled by MS from Win10.
bool CanPinShortcutToTaskbar() {
// "Pin to taskbar" stopped being supported in Windows 10.
return GetVersion() < Version::WIN10;
}
bool PinShortcutToTaskbar(const FilePath& shortcut) {
ScopedBlockingCall scoped_blocking_call(FROM_HERE, BlockingType::MAY_BLOCK);
DCHECK(CanPinShortcutToTaskbar());
intptr_t result = reinterpret_cast<intptr_t>(ShellExecute(
nullptr, L"taskbarpin", shortcut.value().c_str(), nullptr, nullptr, 0));
return result > 32;
}
To me, Chromium's implementation looks quite similar to FF's implementation but more modern as they're using ComPtr(RAII obj?). Doesn't Chromium's implementation work and is it why you brought implementation from FF?
Hmm, it's not yet available for our master. Should we copy and test in advance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to test chromium's method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, there's another implementation in base::win::shortcut.cc , which uses "ShellExecute()" . Maybe this has been stopped working from Win10.
Hmm, it's not yet available for our master
Aha, What I found was the latest one and we don't have it yet. Thanks.
if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) | ||
return; | ||
|
||
ShellUtil::ShortcutProperties properties(ShellUtil::CURRENT_USER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, there's another implementation in base::win::shortcut.cc , which uses "ShellExecute()" . Maybe this has been stopped working from Win10.
Hmm, it's not yet available for our master
Aha, What I found was the latest one and we don't have it yet. Thanks.
// See PinCurrentAppToTaskbarAsyncImpl() at | ||
// https://github.com/mozilla/gecko-dev/blob/master/browser/components/shell/nsWindowsShellService.cpp | ||
if (base::win::GetVersion() < base::win::Version::WIN10_RS5) | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, can we try something like this as fallback?
return; | |
if (base::win::CanPinShortcut()) { | |
...// call ShellExecute version base::win::PinShortcutToTaskbar() in callback | |
} | |
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test with upstream methods (IsPinned/Pin) works nicely. Copied them used.
We can delete copied one when it's available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base::win::CanPinShortcutToTaskbar()
uses different condition with this one.
base::win::GetVersion() < base::win::Version::WIN10
vs.
base::win::GetVersion() >= base::win::Version::WIN10_RS5
It seems IPinnedList3
is availble from base::win::Version::WIN10_RS5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so what i mean is
if (base::win::GetVersion() >= WIN10_RS5)
PinTaskBar with IPinnedList3 - ShellUtill's implemntation
else if (base::win::GetVersion() < base::win::Version::WIN10)
PinTaskBar with ShellExecute() - Shorcut's implementation.
so that we can cover more versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see what you mean. How about handling it as a next step?
As this PR is for pinning from first run dialog, we don't need to care about win7/8.
The reason is windows installer tries to pin to taskbar and it works on win7/8. So, don't need to try to pin again on Win7/8. I planned to handle it as a next task for pinning when user set Brave as a default from settings menu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sure! Fair enough. Didn't know that 7/8 already works. You can skip it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sangwoo108 Thanks for review! 👍🏼
4962476
to
09340f4
Compare
When user set Brave as a default browser from FirstRun dialog, try to pin it to taskbar also. Resolves brave/brave-browser#24241
09340f4
to
e2c2872
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
fix brave/brave-browser#24363 This is f/u PR for #14311. I accidently omitted calling pin method while rebasing from above PR.
When user set Brave as a default browser from FirstRun dialog,
try to pin it to taskbar also.
Resolves brave/brave-browser#24241
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
NOTE: This pin feature is supported from Win10 RS5.