Commit da858d82 authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

Extension App Launch: Extract UMA code into platform_apps.

Extensions shouldn't leak into chrome/browser/sessions/ code.

No behavior changes.

Bug: 774918
Change-Id: I5c35749362914bdb3ea46c160abcd4ab36a74957
Reviewed-on: https://chromium-review.googlesource.com/1229722
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592315}
parent 6bb8534f
......@@ -9,6 +9,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/extensions/app_launch_params.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_metrics.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_prefs.h"
......@@ -148,4 +149,16 @@ bool OpenExtensionAppShortcutWindow(Profile* profile, const GURL& url) {
return app_tab != nullptr;
}
void RecordExtensionAppLaunchOnTabRestored(Profile* profile, const GURL& url) {
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile)
->enabled_extensions()
.GetAppByURL(url);
if (!extension)
return;
extensions::RecordAppLaunchType(
extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, extension->GetType());
}
} // namespace apps
......@@ -44,6 +44,9 @@ bool OpenExtensionApplicationWithReenablePrompt(
// otherwise.
bool OpenExtensionAppShortcutWindow(Profile* profile, const GURL& url);
// Records the restored app launch for UMA.
void RecordExtensionAppLaunchOnTabRestored(Profile* profile, const GURL& url);
} // namespace apps
#endif // CHROME_BROWSER_APPS_PLATFORM_APPS_PLATFORM_APP_LAUNCH_H_
......@@ -13,12 +13,8 @@
#include "extensions/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/apps/platform_apps/platform_app_launch.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_metrics.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#endif
#if !defined(OS_ANDROID)
......@@ -27,24 +23,6 @@
#include "chrome/browser/ui/android/tab_model/android_live_tab_context.h"
#endif
namespace {
void RecordAppLaunch(Profile* profile, const GURL& url) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile)
->enabled_extensions()
.GetAppByURL(url);
if (!extension)
return;
extensions::RecordAppLaunchType(
extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, extension->GetType());
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
}
} // namespace
ChromeTabRestoreServiceClient::ChromeTabRestoreServiceClient(Profile* profile)
: profile_(profile) {}
......@@ -142,5 +120,7 @@ void ChromeTabRestoreServiceClient::GetLastSession(
}
void ChromeTabRestoreServiceClient::OnTabRestored(const GURL& url) {
RecordAppLaunch(profile_, url);
#if BUILDFLAG(ENABLE_EXTENSIONS)
apps::RecordExtensionAppLaunchOnTabRestored(profile_, url);
#endif // BUILDFLAG(ENABLE_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