Commit 7c289942 authored by Dominick Ng's avatar Dominick Ng Committed by Commit Bot

Introduce AppsNavigationThrottle, and move ArcNavigationThrottle creation into it.

This CL creates the chrome/browser/chromeos/apps directory, which will
contain code to facilitate the different apps platforms on Chrome OS
interoperating with each other and the Chrome OS system.

Much of the initial work will be to take existing integrations for
ARC++, and make them sufficiently generic so that other app platforms
can use them. We first focus on the ARC++ intent helper, which allows
users to open an app from the omnibox.

This CL moves construction of the ArcNavigationThrottle, which controls
the appearance of the intent helper, from ChromeContentBrowserClient
into a new AppsNavigationThrottle. Follow-up CLs will begin to split
ArcNavigationThrottle so that the throttle-specific code is moved to
AppsNavigationThrottle. The change in this CL means that the follow-up
refactoring will not need to change ChromeContentBrowserClient again.

BUG=824598

Change-Id: I4062a198b631215709deeab80fe669e0aea53857
Reviewed-on: https://chromium-review.googlesource.com/974761Reviewed-by: default avatarSatoru Takabayashi <satorux@chromium.org>
Reviewed-by: default avatarElijah Taylor <elijahtaylor@chromium.org>
Reviewed-by: default avatarDavid Jacobo <djacobo@chromium.org>
Commit-Queue: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546036}
parent ecc13498
...@@ -274,10 +274,9 @@ ...@@ -274,10 +274,9 @@
#include "chrome/browser/chrome_browser_main_mac.h" #include "chrome/browser/chrome_browser_main_mac.h"
#elif defined(OS_CHROMEOS) #elif defined(OS_CHROMEOS)
#include "ash/public/interfaces/constants.mojom.h" #include "ash/public/interfaces/constants.mojom.h"
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/apps/intent_helper/apps_navigation_throttle.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_backend_delegate.h" #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_backend_delegate.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_delegate.h" #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_delegate.h"
#include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h"
#include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
#include "chrome/browser/chromeos/chrome_service_name.h" #include "chrome/browser/chromeos/chrome_service_name.h"
#include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.h" #include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.h"
...@@ -3557,18 +3556,10 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( ...@@ -3557,18 +3556,10 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation(
throttles.push_back(MergeSessionNavigationThrottle::Create(handle)); throttles.push_back(MergeSessionNavigationThrottle::Create(handle));
} }
if (arc::IsArcPlayStoreEnabledForProfile(Profile::FromBrowserContext( auto url_to_apps_throttle =
handle->GetWebContents()->GetBrowserContext())) && chromeos::AppsNavigationThrottle::MaybeCreate(handle);
!handle->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) { if (url_to_apps_throttle)
prerender::PrerenderContents* prerender_contents = throttles.push_back(std::move(url_to_apps_throttle));
prerender::PrerenderContents::FromWebContents(
handle->GetWebContents());
if (!prerender_contents) {
auto url_to_arc_throttle =
std::make_unique<arc::ArcNavigationThrottle>(handle);
throttles.push_back(std::move(url_to_arc_throttle));
}
}
} }
#endif #endif
......
...@@ -300,6 +300,8 @@ source_set("chromeos") { ...@@ -300,6 +300,8 @@ source_set("chromeos") {
"app_mode/startup_app_launcher.h", "app_mode/startup_app_launcher.h",
"app_mode/startup_app_launcher_update_checker.cc", "app_mode/startup_app_launcher_update_checker.cc",
"app_mode/startup_app_launcher_update_checker.h", "app_mode/startup_app_launcher_update_checker.h",
"apps/intent_helper/apps_navigation_throttle.cc",
"apps/intent_helper/apps_navigation_throttle.h",
"arc/accessibility/arc_accessibility_helper_bridge.cc", "arc/accessibility/arc_accessibility_helper_bridge.cc",
"arc/accessibility/arc_accessibility_helper_bridge.h", "arc/accessibility/arc_accessibility_helper_bridge.h",
"arc/accessibility/ax_tree_source_arc.cc", "arc/accessibility/ax_tree_source_arc.cc",
......
benwells@chromium.org
dominickn@chromium.org
# Chrome OS Apps Platform
Chrome OS features multiple app platforms, such as ARC++ and desktop PWAs,
that are based on different underlying technologies. UX-wise, it is an
explicit goal to minimise the differences between them and give users the
feeling that all apps have as similar properties, management, and features as
possible.
This directory contains generic code to facilitate app platforms on Chrome OS
communicating with the browser and each other. This layer consists of
app-platform-agnostic code, which each app platform's custom implementation
then plugs into. Example features include:
* `chromeos/apps/intent_helper` - allows installed apps that handle particular
URLs to be opened by users from the omnibox. For ARC++, custom code queries
the ARC++ container; for desktop PWAs, data is contained in the browser
itself.
# For ARC++ related code
djacobo@chromium.org
yusukes@chromium.org
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/apps/intent_helper/apps_navigation_throttle.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h"
#include "chrome/browser/prerender/prerender_contents.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/web_contents.h"
namespace chromeos {
// static
std::unique_ptr<content::NavigationThrottle>
AppsNavigationThrottle::MaybeCreate(content::NavigationHandle* handle) {
if (arc::IsArcPlayStoreEnabledForProfile(Profile::FromBrowserContext(
handle->GetWebContents()->GetBrowserContext())) &&
!handle->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) {
prerender::PrerenderContents* prerender_contents =
prerender::PrerenderContents::FromWebContents(handle->GetWebContents());
if (!prerender_contents)
return std::make_unique<arc::ArcNavigationThrottle>(handle);
}
return nullptr;
}
} // namespace chromeos
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_APPS_INTENT_HELPER_APPS_NAVIGATION_THROTTLE_H_
#define CHROME_BROWSER_CHROMEOS_APPS_INTENT_HELPER_APPS_NAVIGATION_THROTTLE_H_
#include <memory>
namespace content {
class NavigationHandle;
class NavigationThrottle;
} // namespace content
namespace chromeos {
// TODO(crbug.com/824598): make this class inherit from
// content::NavigationThrottle, and move the throttle functionality from
// ArcNavigationThrottle into here.
class AppsNavigationThrottle {
public:
// Possibly creates a navigation throttle that checks if any installed ARC++
// apps can handle the URL being navigated to. The user is prompted if they
// wish to open the app or remain in the browser.
static std::unique_ptr<content::NavigationThrottle> MaybeCreate(
content::NavigationHandle* handle);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_APPS_INTENT_HELPER_APPS_NAVIGATION_THROTTLE_H_
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