-
Notifications
You must be signed in to change notification settings - Fork 868
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
Omnibox Command Palette #16947
Omnibox Command Palette #16947
Conversation
f802607
to
e81a566
Compare
df482e4
to
a3605a3
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.
@fallaciousreasoning , this is a awesome work! I've been craving for a feature like this on omnibox. I'm still loading the context of codes here so might be wrong about some comments.
chromium_src/chrome/browser/ui/views/commander_frontend_views.cc
Outdated
Show resolved
Hide resolved
Sorry ssangwoo, I've only got to about half your feedback so far! |
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.
Sorry ssangwoo, I've only got to about half your feedback so far!
No worries, I know I commented a lot 😭 I hope my new comments doesn't feel overwhelming.
Nah, thanks heaps for all your feedback @sangwoo108! You're my primary source of C++ tips & tricks 😆 |
84cba7f
to
27903c4
Compare
27903c4
to
b033c30
Compare
7ec1c06
to
c5c5d25
Compare
34e6702
to
29a96ae
Compare
29a96ae
to
e1dcee6
Compare
if (!browser) { | ||
return nullptr; | ||
} | ||
return browser->window()->GetLocationBar()->GetOmniboxView(); |
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.
does window()
always valid on MacOS?
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.
The only comment I see on window
is this one:
// |window()| will return NULL if called before |CreateBrowserWindow()|
// is done.
but that doesn't mean it can't be. Maybe I'll add a CHECK?
e1dcee6
to
5ff2672
Compare
AutocompleteController* controller) { | ||
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) | ||
if (commander::CommanderEnabled()) { | ||
providers.push_back(new commander::CommanderProvider( |
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.
std::make_unique
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.
I've changed this to base::MakeRefCounted
but all the other providers are added via new ....
. Should they be updated (in a future PR)? In the Chromium file they're all added/created via new too, so I almost feel this should be left as is?
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, usually we should prefer make_foo
over bare "new" if possible.
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.
I almost forgot why, but this post reminded me why 😄
https://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/
- make_unique is more robust to exceptions
- Potential leak, which can be caused by expression order, can be prevented
e43bc83
to
b03c25a
Compare
b03c25a
to
3619b8c
Compare
|
||
#include "base/strings/string_util.h" | ||
|
||
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) |
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.
please replace all of these !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
guards with a dedicated buildflag for this feature
@@ -36,3 +38,15 @@ brave_components_omnibox_browser_deps = [ | |||
"//components/prefs", | |||
"//url", | |||
] | |||
|
|||
if (!is_android && !is_ios) { |
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.
Same as above, please add a dedicated buildflag
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
assert(!is_android && !is_ios) |
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.
replace with dedicated buildflag. In general os guards should only be used directly when you are guarding os-specific code. In other cases you should use them indirectly to set the dedicated buildflag value
|
||
namespace commander { | ||
|
||
bool CommanderEnabled() { |
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.
IsCommanderEnabled
, but this pattern is generally only used when there are more conditions than just a single buildflag so I would probably remove this
|
||
#include "brave/components/commander/common/constants.h" | ||
|
||
#include "base/strings/string_piece.h" |
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.
this is unused
#include <string> | ||
#include <utility> | ||
|
||
#include "base/functional/bind.h" |
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.
a lot of these includes don't appear to be used
#include "base/memory/weak_ptr.h" | ||
#include "base/scoped_observation.h" | ||
#include "brave/components/commander/browser/commander_frontend_delegate.h" | ||
#include "brave/components/commander/browser/commander_item_model.h" |
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.
Is this include used here? Also it seems like many of these could be forward declarations
Resolves brave/brave-browser#28178
Adds a prototype command palette in the Omnibox. Behind the Chromium brave://flags/#quick-commands flag. Note: This flag is set to expire in M111 so you might need to also enable the brave://flags/#temporary-unexpire-flags-m110 flag if you're running a recent version of Brave.
The crbug issue for this feature is here: https://bugs.chromium.org/p/chromium/issues/detail?id=1014639
commander-demo.webm
Submitter Checklist:
no security/privacy review is needed, or thatI have requested oneQA/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
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
brave://flags#quick-commands
flag (if not present enable theTemporarily Enable M110 flags
)Create tab
and select theCreate new tab
command. A new tab should openMove window
and selectMove tab to new window
. The tab should move to a new windowhttps://readr.nz
Move window
and selectMove tabs to window...
New tab
(or whatever your original window was called).