Commit ab12c6e3 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

[CCA WebUI] Don't capture navigation other than main page URL for CCA

We have the following requirements:
1. We prefer loading CCA UI in the app window rather than browser tab
  => Therefore we added "capture_navigation=true" for CCA
2. We don't want to load resource URLs or invalid URL in the app window
  => Short term: Landing this CL to filter out unwanted URLs

  We decide not to support URL filtering feature for capture navigation
  since only camera app has such requirement at this moment.
  (crbug.com/1132151)

Bug: 980846
Test: Type CCA url other than chrome://camera-app/views/main.html and
the page is loaded in browser tab

Change-Id: I467aa1498aa9fe975d34bdf82adee7f6dff6a14c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440076
Commit-Queue: Wei Lee <wtlee@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarJiewei Qian  <qjw@chromium.org>
Auto-Submit: Wei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814557}
parent c2644621
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "chrome/browser/chromeos/web_applications/system_web_app_integration_test.h" #include "chrome/browser/chromeos/web_applications/system_web_app_integration_test.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/web_applications/system_web_app_manager_browsertest.h" #include "chrome/browser/web_applications/system_web_app_manager_browsertest.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
#include "content/public/test/test_navigation_observer.h"
class CameraAppIntegrationTest : public SystemWebAppIntegrationTest { class CameraAppIntegrationTest : public SystemWebAppIntegrationTest {
public: public:
...@@ -32,5 +35,42 @@ IN_PROC_BROWSER_TEST_P(CameraAppIntegrationTest, WindowNotResizeable) { ...@@ -32,5 +35,42 @@ IN_PROC_BROWSER_TEST_P(CameraAppIntegrationTest, WindowNotResizeable) {
EXPECT_FALSE(browser_view->CanResize()); EXPECT_FALSE(browser_view->CanResize());
} }
IN_PROC_BROWSER_TEST_P(CameraAppIntegrationTest, MainUrlNavigation) {
WaitForTestSystemAppInstall();
GURL main_camera_app_url("chrome://camera-app/views/main.html");
content::TestNavigationObserver navigation_observer(main_camera_app_url);
navigation_observer.StartWatchingNewWebContents();
ASSERT_EQ(1u, chrome::GetTotalBrowserCount());
ui_test_utils::SendToOmniboxAndSubmit(browser(), main_camera_app_url.spec());
navigation_observer.Wait();
// We now have two browsers, one for the chrome window, one for the Camera
// app.
EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
EXPECT_EQ(main_camera_app_url, chrome::FindLastActive()
->tab_strip_model()
->GetActiveWebContents()
->GetVisibleURL());
}
IN_PROC_BROWSER_TEST_P(CameraAppIntegrationTest, OtherPageUrlNavigation) {
WaitForTestSystemAppInstall();
// TODO(crbug.com/980846): Change it to test page once the corresponding CL is
// merged.
GURL other_page_camera_app_url("chrome://camera-app/js/main.js");
ASSERT_EQ(1u, chrome::GetTotalBrowserCount());
ui_test_utils::SendToOmniboxAndSubmit(browser(),
other_page_camera_app_url.spec());
EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
EXPECT_EQ(
other_page_camera_app_url,
browser()->tab_strip_model()->GetActiveWebContents()->GetVisibleURL());
}
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P( INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
CameraAppIntegrationTest); CameraAppIntegrationTest);
...@@ -44,6 +44,7 @@ source_set("common") { ...@@ -44,6 +44,7 @@ source_set("common") {
if (is_chromeos) { if (is_chromeos) {
deps += [ deps += [
"//ash/public/cpp", "//ash/public/cpp",
"//chromeos/components/camera_app_ui",
"//chromeos/components/diagnostics_ui", "//chromeos/components/diagnostics_ui",
"//chromeos/components/help_app_ui", "//chromeos/components/help_app_ui",
"//chromeos/components/media_app_ui", "//chromeos/components/media_app_ui",
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "chrome/browser/chromeos/web_applications/scanning_system_web_app_info.h" #include "chrome/browser/chromeos/web_applications/scanning_system_web_app_info.h"
#include "chrome/browser/chromeos/web_applications/terminal_source.h" #include "chrome/browser/chromeos/web_applications/terminal_source.h"
#include "chrome/browser/chromeos/web_applications/terminal_system_web_app_info.h" #include "chrome/browser/chromeos/web_applications/terminal_system_web_app_info.h"
#include "chromeos/components/camera_app_ui/url_constants.h"
#include "chromeos/components/help_app_ui/url_constants.h" #include "chromeos/components/help_app_ui/url_constants.h"
#include "chromeos/components/media_app_ui/url_constants.h" #include "chromeos/components/media_app_ui/url_constants.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
...@@ -624,6 +625,12 @@ base::Optional<SystemAppType> SystemWebAppManager::GetCapturingSystemAppForURL( ...@@ -624,6 +625,12 @@ base::Optional<SystemAppType> SystemWebAppManager::GetCapturingSystemAppForURL(
if (!it->second.capture_navigations) if (!it->second.capture_navigations)
return base::nullopt; return base::nullopt;
#if defined(OS_CHROMEOS)
if (type == SystemAppType::CAMERA &&
url.spec() != chromeos::kChromeUICameraAppMainURL)
return base::nullopt;
#endif // defined(OS_CHROMEOS)
return type; return type;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment