Commit 094762b7 authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

HostedApp: Plumb install callback for extensions::TabHelper.

It is not used for now.

Bug: 875698
Change-Id: I2de44ec120deccebb36a2f031843122963bd13f4
Reviewed-on: https://chromium-review.googlesource.com/c/1295759Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601874}
parent 1244a504
...@@ -107,11 +107,14 @@ TabHelper::TabHelper(content::WebContents* web_contents) ...@@ -107,11 +107,14 @@ TabHelper::TabHelper(content::WebContents* web_contents)
BookmarkManagerPrivateDragEventRouter::CreateForWebContents(web_contents); BookmarkManagerPrivateDragEventRouter::CreateForWebContents(web_contents);
} }
void TabHelper::CreateHostedAppFromWebContents(bool shortcut_app_requested) { void TabHelper::CreateHostedAppFromWebContents(bool shortcut_app_requested,
OnceInstallCallback callback) {
DCHECK(CanCreateBookmarkApp()); DCHECK(CanCreateBookmarkApp());
if (pending_web_app_action_ != NONE) if (pending_web_app_action_ != NONE)
return; return;
install_callback_ = std::move(callback);
// Start fetching web app info for CreateApplicationShortcut dialog and show // Start fetching web app info for CreateApplicationShortcut dialog and show
// the dialog when the data is available in OnDidGetWebApplicationInfo. // the dialog when the data is available in OnDidGetWebApplicationInfo.
GetApplicationInfo(CREATE_HOSTED_APP, shortcut_app_requested); GetApplicationInfo(CREATE_HOSTED_APP, shortcut_app_requested);
...@@ -198,6 +201,10 @@ void TabHelper::FinishCreateBookmarkApp( ...@@ -198,6 +201,10 @@ void TabHelper::FinishCreateBookmarkApp(
blink::kWebDisplayModeStandalone); blink::kWebDisplayModeStandalone);
} }
pending_web_app_action_ = NONE; pending_web_app_action_ = NONE;
const bool success = !!extension;
const ExtensionId app_id = extension ? extension->id() : ExtensionId();
std::move(install_callback_).Run(app_id, success);
} }
void TabHelper::RenderFrameCreated(content::RenderFrameHost* host) { void TabHelper::RenderFrameCreated(content::RenderFrameHost* host) {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <set> #include <set>
#include <string> #include <string>
#include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
...@@ -49,7 +50,11 @@ class TabHelper : public content::WebContentsObserver, ...@@ -49,7 +50,11 @@ class TabHelper : public content::WebContentsObserver,
public: public:
~TabHelper() override; ~TabHelper() override;
void CreateHostedAppFromWebContents(bool shortcut_app_requested); using OnceInstallCallback =
base::OnceCallback<void(const ExtensionId& app_id, bool success)>;
void CreateHostedAppFromWebContents(bool shortcut_app_requested,
OnceInstallCallback callback);
bool CanCreateBookmarkApp() const; bool CanCreateBookmarkApp() const;
// Sets the extension denoting this as an app. If |extension| is non-null this // Sets the extension denoting this as an app. If |extension| is non-null this
...@@ -192,6 +197,9 @@ class TabHelper : public content::WebContentsObserver, ...@@ -192,6 +197,9 @@ class TabHelper : public content::WebContentsObserver,
std::unique_ptr<BookmarkAppHelper> bookmark_app_helper_; std::unique_ptr<BookmarkAppHelper> bookmark_app_helper_;
// Reponse to CreateHostedAppFromWebContents request.
OnceInstallCallback install_callback_;
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
registry_observer_; registry_observer_;
......
...@@ -24,7 +24,7 @@ void BookmarkAppInstallManager::InstallWebApp( ...@@ -24,7 +24,7 @@ void BookmarkAppInstallManager::InstallWebApp(
content::WebContents* web_contents, content::WebContents* web_contents,
bool force_shortcut_app) { bool force_shortcut_app) {
extensions::TabHelper::FromWebContents(web_contents) extensions::TabHelper::FromWebContents(web_contents)
->CreateHostedAppFromWebContents(force_shortcut_app); ->CreateHostedAppFromWebContents(force_shortcut_app, base::DoNothing());
} }
} // namespace extensions } // namespace extensions
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