Commit 01d66472 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

sessions: removes SessionTabHelper::SetTabExtensionAppID

And puts the implementation in the single place that needs it.
SessionTabHelper is really intended to forward WebContentsObserver
related calls to SessionService. SetTabExtensionAppID() isn't that.
As SetTabExtensionAppID() was called in a single place, I moved
the implementation there.

This is part of a larger refactoring I'm doing in hopes of moving
SessionTabHelper to a shared location.

BUG=1033924
TEST=none

Change-Id: Ia70af33908593839d4a22b4ebbc5f9f48c8abc30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994527
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#730200}
parent 289311cf
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/render_messages.h" #include "chrome/common/render_messages.h"
...@@ -59,6 +60,11 @@ ...@@ -59,6 +60,11 @@
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "url/url_constants.h" #include "url/url_constants.h"
#if BUILDFLAG(ENABLE_SESSION_SERVICE)
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_service_factory.h"
#endif
using content::NavigationController; using content::NavigationController;
using content::NavigationEntry; using content::NavigationEntry;
using content::WebContents; using content::WebContents;
...@@ -113,10 +119,19 @@ void TabHelper::SetExtensionApp(const Extension* extension) { ...@@ -113,10 +119,19 @@ void TabHelper::SetExtensionApp(const Extension* extension) {
UpdateExtensionAppIcon(extension_app_); UpdateExtensionAppIcon(extension_app_);
#if BUILDFLAG(ENABLE_SESSION_SERVICE)
if (extension_app_) { if (extension_app_) {
SessionTabHelper::FromWebContents(web_contents()) SessionService* session_service = SessionServiceFactory::GetForProfile(
->SetTabExtensionAppID(GetAppId()); Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
if (session_service) {
SessionTabHelper* session_tab_helper =
SessionTabHelper::FromWebContents(web_contents());
session_service->SetTabExtensionAppID(session_tab_helper->window_id(),
session_tab_helper->session_id(),
GetAppId());
}
} }
#endif
} }
void TabHelper::SetExtensionAppById(const ExtensionId& extension_app_id) { void TabHelper::SetExtensionAppById(const ExtensionId& extension_app_id) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "components/sessions/content/content_serialized_navigation_builder.h" #include "components/sessions/content/content_serialized_navigation_builder.h"
#include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_details.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
#include "extensions/common/extension_messages.h" #include "extensions/common/extension_messages.h"
...@@ -23,8 +24,7 @@ SessionTabHelper::SessionTabHelper(content::WebContents* contents) ...@@ -23,8 +24,7 @@ SessionTabHelper::SessionTabHelper(content::WebContents* contents)
session_id_(SessionID::NewUnique()), session_id_(SessionID::NewUnique()),
window_id_(SessionID::InvalidValue()) {} window_id_(SessionID::InvalidValue()) {}
SessionTabHelper::~SessionTabHelper() { SessionTabHelper::~SessionTabHelper() = default;
}
void SessionTabHelper::SetWindowID(const SessionID& id) { void SessionTabHelper::SetWindowID(const SessionID& id) {
window_id_ = id; window_id_ = id;
...@@ -114,19 +114,5 @@ void SessionTabHelper::NavigationEntryChanged( ...@@ -114,19 +114,5 @@ void SessionTabHelper::NavigationEntryChanged(
session_service->UpdateTabNavigation(window_id(), session_id(), navigation); session_service->UpdateTabNavigation(window_id(), session_id(), navigation);
} }
#endif #endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
void SessionTabHelper::SetTabExtensionAppID(
const std::string& extension_app_id) {
#if BUILDFLAG(ENABLE_SESSION_SERVICE)
SessionService* session_service = SessionServiceFactory::GetForProfile(
Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
if (!session_service)
return;
session_service->SetTabExtensionAppID(window_id(), session_id(),
extension_app_id);
#endif
}
#endif
WEB_CONTENTS_USER_DATA_KEY_IMPL(SessionTabHelper) WEB_CONTENTS_USER_DATA_KEY_IMPL(SessionTabHelper)
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "components/sessions/core/session_id.h" #include "components/sessions/core/session_id.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "extensions/buildflags/buildflags.h"
// This class keeps the extension API's windowID up to date with the current // This class keeps the extension API's windowID up to date with the current
// window of the tab and observes navigation events. // window of the tab and observes navigation events.
...@@ -56,10 +55,6 @@ class SessionTabHelper : public content::WebContentsObserver, ...@@ -56,10 +55,6 @@ class SessionTabHelper : public content::WebContentsObserver,
const content::EntryChangedDetails& change_details) override; const content::EntryChangedDetails& change_details) override;
#endif #endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
void SetTabExtensionAppID(const std::string& extension_app_id);
#endif
private: private:
explicit SessionTabHelper(content::WebContents* contents); explicit SessionTabHelper(content::WebContents* contents);
friend class content::WebContentsUserData<SessionTabHelper>; friend class content::WebContentsUserData<SessionTabHelper>;
......
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