Commit ad7f9d20 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

MacPWAs BMO: Remove some uses of extensions::Extension

The general plan here is to make ExtensionAppShimHandler not know
about extensions, but be able to interact with either apps or
extensions via its ExtensionAppShimHandler::Delegate interface.

To this end, start changing the interface to take app ids instead of
extensions::Extensions. Most of this is mechanical, but a few
aren't quite:
* The Delegate::GetWindows method can't return an extensions type
  anymore, so inline its usage into new ShowAppWindows and
  CloseAppWindows methods (which, internally, will be able to).
* Remove RequestUserAttentionForWindow, and have the caller (which
  is extensions-based app code) make the appropriate calls.

Update tests to behave reasonably.

Bug: 1057195
Change-Id: Ife8f37b608a9a601eafd38da44c2ad50b99f41c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080487Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746502}
parent 346ef5e4
......@@ -35,7 +35,6 @@ class BrowserContext;
} // namespace content
namespace extensions {
class AppWindow;
class Extension;
} // namespace extensions
......@@ -65,10 +64,12 @@ class ExtensionAppShimHandler : public AppShimHostBootstrap::Client,
// locked.
virtual bool IsProfileLockedForPath(const base::FilePath& path);
// Return the app windows (not browser windows) for a legacy app.
virtual extensions::AppWindowRegistry::AppWindowList GetWindows(
Profile* profile,
const std::string& extension_id);
// Show all app windows (for non-PWA apps). Return true if there existed any
// windows.
virtual bool ShowAppWindows(Profile* profile, const std::string& app_id);
// Close all app windows (for non-PWA apps).
virtual void CloseAppWindows(Profile* profile, const std::string& app_id);
// Look up an extension from its id.
virtual const extensions::Extension* MaybeGetAppExtension(
......@@ -78,7 +79,7 @@ class ExtensionAppShimHandler : public AppShimHostBootstrap::Client,
// Return true if the specified app should use an app shim (false, e.g, for
// bookmark apps that open in tabs).
virtual bool AllowShimToConnect(Profile* profile,
const extensions::Extension* extension);
const std::string& app_id);
// Create an AppShimHost for the specified parameters (intercept-able for
// tests).
......@@ -96,7 +97,7 @@ class ExtensionAppShimHandler : public AppShimHostBootstrap::Client,
// Launch the app in Chrome. This will (often) create a new window.
virtual void LaunchApp(Profile* profile,
const extensions::Extension* extension,
const std::string& app_id,
const std::vector<base::FilePath>& files);
// Open the specified URL in a new Chrome window. This is the fallback when
......@@ -108,7 +109,7 @@ class ExtensionAppShimHandler : public AppShimHostBootstrap::Client,
// Launch the shim process for an app.
virtual void LaunchShim(Profile* profile,
const extensions::Extension* extension,
const std::string& app_id,
bool recreate_shims,
ShimLaunchedCallback launched_callback,
ShimTerminatedCallback terminated_callback);
......@@ -145,12 +146,6 @@ class ExtensionAppShimHandler : public AppShimHostBootstrap::Client,
static const extensions::Extension* MaybeGetAppForBrowser(Browser* browser);
// Instructs the shim to request user attention. Returns false if there is no
// shim for this window.
void RequestUserAttentionForWindow(
extensions::AppWindow* app_window,
chrome::mojom::AppShimAttentionType attention_type);
// AppShimHostBootstrap::Client:
void OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) override;
......@@ -250,14 +245,12 @@ class ExtensionAppShimHandler : public AppShimHostBootstrap::Client,
std::unique_ptr<AppShimHostBootstrap> bootstrap);
// Continuation of OnShimSelectedProfile, once the profile has loaded.
void OnShimSelectedProfileAndAppLoaded(
Profile* profile,
const extensions::Extension* extension);
void OnShimSelectedProfileAndAppLoaded(const std::string& app_id,
Profile* profile);
// Load the specified profile and extension, and run |callback| with
// the result. The callback's arguments may be nullptr on failure.
using LoadProfileAppCallback =
base::OnceCallback<void(Profile*, const extensions::Extension*)>;
using LoadProfileAppCallback = base::OnceCallback<void(Profile*)>;
void LoadProfileAndApp(const base::FilePath& profile_path,
const std::string& app_id,
LoadProfileAppCallback callback);
......
......@@ -8,6 +8,7 @@
#import "base/mac/scoped_nsobject.h"
#include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
#include "chrome/browser/profiles/profile.h"
#import "chrome/browser/ui/views/apps/app_window_native_widget_mac.h"
#import "chrome/browser/ui/views/apps/native_app_window_frame_view_mac.h"
#import "ui/gfx/mac/coordinate_conversion.h"
......@@ -165,8 +166,14 @@ void ChromeNativeAppWindowViewsMac::Restore() {
}
void ChromeNativeAppWindowViewsMac::FlashFrame(bool flash) {
apps::ExtensionAppShimHandler::Get()->RequestUserAttentionForWindow(
app_window(), flash ? chrome::mojom::AppShimAttentionType::kCritical
Profile* profile =
Profile::FromBrowserContext(app_window()->browser_context());
AppShimHost* shim_host = apps::ExtensionAppShimHandler::Get()->FindHost(
profile, app_window()->extension_id());
if (!shim_host)
return;
shim_host->GetAppShim()->SetUserAttention(
flash ? chrome::mojom::AppShimAttentionType::kCritical
: chrome::mojom::AppShimAttentionType::kCancel);
}
......
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