raw_ptr<Profile> profile_;Nit: this member could be marked as const.
if (!base::FeatureList::IsEnabled(features::kGlicExperimentalTriggering)) {Can this be a CHECK instead? With the feature disabled this code should be unreachable.
DCHECK(message.has_glic_experimental_triggering());For new code CHECK should be favored over DCHECK, see https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/checks.md#invariant_verification-mechanisms
GetLastActiveBrowserWindowInterfaceWithAnyProfile();How come any profile? I think you'd want to narrow this down to `profile_`?
If there are good reasons for this, please add a comment explaining why this makes sense.
<< "No active browser window found for GlicExperimentalTriggering";Wouldn't you want to open a window in this case?
if (!glic_service) {This one and the one above should ideally be CHECK failures too. Otherwise, I fear this device may be advertising a capability that it doesn't actually have. Unfortunately I am not familiar with the details of how capabilities are evaluated and whether there would be a way to achieve this nicely, but a drastic approach would be to not even register the message handler in such a case?
base::test::ScopedFeatureList feature_list_;Nit: you could do `feature_list_{features::kGlicExperimentalTriggering}` here and keep the constructor simpler.
std::unique_ptr<GlicExperimentalTriggeringMessageHandler> handler_;Optional: does this need to be a unique_ptr, or could it be: `GlicExperimentalTriggeringMessageHandler handler_(&profile_)`?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Nit: this member could be marked as const.
Done
if (!base::FeatureList::IsEnabled(features::kGlicExperimentalTriggering)) {Can this be a CHECK instead? With the feature disabled this code should be unreachable.
Done
For new code CHECK should be favored over DCHECK, see https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/checks.md#invariant_verification-mechanisms
Done
How come any profile? I think you'd want to narrow this down to `profile_`?
If there are good reasons for this, please add a comment explaining why this makes sense.
Done
I narrowed down to this profile_.
However, this is not the final behavior, we will likely open a new background tab for this.
<< "No active browser window found for GlicExperimentalTriggering";Wouldn't you want to open a window in this case?
Sergio is working on opening a background window/tab for that.
This one and the one above should ideally be CHECK failures too. Otherwise, I fear this device may be advertising a capability that it doesn't actually have. Unfortunately I am not familiar with the details of how capabilities are evaluated and whether there would be a way to achieve this nicely, but a drastic approach would be to not even register the message handler in such a case?
Done
I added the glic_server presence test to the registration site.
I used CHECK here.
But I didn't change to use CHECK(browser) since I am concerned it might be a little too aggressive for some transient cases when browser is null for other reasons. Let me know if you think otherwise.
Nit: you could do `feature_list_{features::kGlicExperimentalTriggering}` here and keep the constructor simpler.
Done
std::unique_ptr<GlicExperimentalTriggeringMessageHandler> handler_;Optional: does this need to be a unique_ptr, or could it be: `GlicExperimentalTriggeringMessageHandler handler_(&profile_)`?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
: profile_(profile) {}Nit: CHECK(profile_), assuming this is legit.
LOG(ERROR) << "No active browser window found for Profile for "Optional: I don't know about the latest guidance on this, but LOG traces increase the binary size and are extremely unlikely to become useful for production builds. I would rather add DLOG, DVLOG and/or histograms.
glic::GlicInvokeOptions options{glic::mojom::InvocationSource::kUnsupported};Optional: the code could read better if the construction of `GlicInvokeOptions` could be refactored to a helper function that returns this object given a request.
std::move(done_callback).Run(nullptr);Can this move below and be the very last step?
It seems more logical to trigger completion once the operation has actually triggered.
EXPECT_CALL(done_callback, Run(testing::_)).Times(1);Can you please avoid fully qualifying `testing::_` via using declarations? Also, related, please wrap the entire file within an unnamed namespace if possible (which makes it obvious that these tests don't have declared friendships).
/*create=*/false)) {This needs to be /*create=*/true, otherwise this logic fulfill its intended purpose.
If this is problematic, and the CHECK can be hit, we may need to make extensions to `SharingHandlerRegistry` to support dynamic capabilities.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Nit: CHECK(profile_), assuming this is legit.
Done
LOG(ERROR) << "No active browser window found for Profile for "Optional: I don't know about the latest guidance on this, but LOG traces increase the binary size and are extremely unlikely to become useful for production builds. I would rather add DLOG, DVLOG and/or histograms.
Done
glic::GlicInvokeOptions options{glic::mojom::InvocationSource::kUnsupported};Optional: the code could read better if the construction of `GlicInvokeOptions` could be refactored to a helper function that returns this object given a request.
Done
Can this move below and be the very last step?
It seems more logical to trigger completion once the operation has actually triggered.
Done
Can you please avoid fully qualifying `testing::_` via using declarations? Also, related, please wrap the entire file within an unnamed namespace if possible (which makes it obvious that these tests don't have declared friendships).
Done
This needs to be /*create=*/true, otherwise this logic fulfill its intended purpose.
If this is problematic, and the CHECK can be hit, we may need to make extensions to `SharingHandlerRegistry` to support dynamic capabilities.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
class GlicExperimentalTriggeringMessageHandler;Nit: sort alphabetically.
namespace {Optional: I would recommend moving this whole block up before any other functions (in this case constructor/destructor). Depending on your team's preferences.
glic::GlicInvokeOptions options = CreateInvokeOptions(request);Optional: I think you could also avoid this variable and inline the call below, which also means you can avoid a `std::move()`.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
class GlicExperimentalTriggeringMessageHandler;Wei GuoNit: sort alphabetically.
Done
Optional: I would recommend moving this whole block up before any other functions (in this case constructor/destructor). Depending on your team's preferences.
Done
glic::GlicInvokeOptions options = CreateInvokeOptions(request);Optional: I think you could also avoid this variable and inline the call below, which also means you can avoid a `std::move()`.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
":glic_experimental_triggering",missing ":impl" here
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
":glic_experimental_triggering",Wei Guomissing ":impl" here
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
Basic scaffolding of GlicExperimentalTriggeringMessageHandler.
Exclude Android out, since Android build doesn't support
glic_service->InvokeWithAutoSubmit().
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
#include "base/feature_list.h"Nit: This and `chrome/common/chrome_features.h` includes are in the wrong place.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
#include "base/feature_list.h"Nit: This and `chrome/common/chrome_features.h` includes are in the wrong place.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |