-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Link Capturing: Enable app-to-app capturing for target="_self" on CrOS
When App-to-App link capturing flags are enabled on ChromeOS, this allows link clicks within an app window to link capture, even without the link capturing setting being enabled. This CL only works for target="_self" links, which are the simplest case to handle. Future CLs will apply the same business logic to target="_blank" links. Bug: 1480903, b/303350482 Change-Id: I85162d849c9b0c634cdfeec93e61634f92e64347 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4963142 Auto-Submit: Tim Sergeant <tsergeant@chromium.org> Reviewed-by: Alan Cutter <alancutter@chromium.org> Commit-Queue: Tim Sergeant <tsergeant@chromium.org> Cr-Commit-Position: refs/heads/main@{#1216799}
- Loading branch information
1 parent
912dd8d
commit b5dcf4a
Showing
9 changed files
with
177 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
chrome/browser/apps/link_capturing/chromeos_link_capturing_delegate_browsertest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/test/scoped_feature_list.h" | ||
#include "chrome/browser/apps/link_capturing/link_capturing_features.h" | ||
#include "chrome/browser/ui/tabs/tab_strip_model.h" | ||
#include "chrome/browser/ui/views/frame/browser_view.h" | ||
#include "chrome/browser/ui/web_applications/app_browser_controller.h" | ||
#include "chrome/browser/ui/web_applications/test/web_app_navigation_browsertest.h" | ||
#include "chrome/test/base/ui_test_utils.h" | ||
#include "content/public/test/browser_test.h" | ||
|
||
namespace apps { | ||
namespace { | ||
|
||
using ui_test_utils::BrowserChangeObserver; | ||
|
||
// Test for ChromeOS-specific link capturing features. Features which are shared | ||
// between ChromeOS and Windows/Mac/Linux are tested in | ||
// WebAppLinkCapturingBrowserTest. | ||
class ChromeOsLinkCapturingDelegateBrowserTest | ||
: public web_app::WebAppNavigationBrowserTest { | ||
public: | ||
Browser* NavigateExpectingNewBrowser(Browser* source, | ||
const GURL& url, | ||
LinkTarget target) { | ||
BrowserChangeObserver observer(nullptr, | ||
BrowserChangeObserver::ChangeType::kAdded); | ||
ClickLinkAndWait(source->tab_strip_model()->GetActiveWebContents(), url, | ||
target, /*rel=*/""); | ||
return observer.Wait(); | ||
} | ||
|
||
private: | ||
base::test::ScopedFeatureList features_{ | ||
apps::features::kAppToAppLinkCapturing}; | ||
}; | ||
|
||
// Verifies that target="_self" links clicked in a web app window are link | ||
// captured, when AppToAppLinkCapturing is enabled. | ||
IN_PROC_BROWSER_TEST_F(ChromeOsLinkCapturingDelegateBrowserTest, | ||
AppToAppLinkCaptureTargetSelf) { | ||
InstallTestWebApp(); | ||
webapps::AppId target_app = InstallTestWebApp("www.foo.com", "/"); | ||
|
||
Browser* app_browser = OpenTestWebApp(); | ||
Browser* result_browser = NavigateExpectingNewBrowser( | ||
app_browser, https_server().GetURL("www.foo.com", "/launch"), | ||
LinkTarget::SELF); | ||
|
||
EXPECT_TRUE( | ||
web_app::AppBrowserController::IsForWebApp(result_browser, target_app)); | ||
} | ||
|
||
} // namespace | ||
} // namespace apps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters