|
|
@@ -5,10 +5,13 @@
|
|
|
|
|
|
#include "base/base64.h"
|
|
|
#include "base/command_line.h"
|
|
|
+#include "base/functional/bind.h"
|
|
|
+#include "base/functional/callback.h"
|
|
|
#include "base/json/json_reader.h"
|
|
|
|
|
|
#include "chrome/browser/profiles/profile.h"
|
|
|
#include "chrome/browser/sessions/session_restore.h"
|
|
|
+#include "chrome/browser/sessions/session_service_factory.h"
|
|
|
#include "chrome/browser/ui/browser.h"
|
|
|
#include "chrome/browser/ui/browser_finder.h"
|
|
|
|
|
|
@@ -115,5 +118,23 @@ ExtensionFunction::ResponseAction WisdomSvcRestoreTabsFunction::Run() {
|
|
|
return RespondNow(NoArguments());
|
|
|
}
|
|
|
|
|
|
+// WisdomSvcGetLastSessionTabsCountFunction
|
|
|
+ExtensionFunction::ResponseAction
|
|
|
+WisdomSvcGetLastSessionTabsCountFunction::Run() {
|
|
|
+ Profile* profile = Profile::FromBrowserContext(browser_context());
|
|
|
+ SessionServiceBase* service =
|
|
|
+ SessionServiceFactory::GetForProfileForSessionRestore(profile);
|
|
|
+ service->GetLastSession(base::BindOnce(
|
|
|
+ &WisdomSvcGetLastSessionTabsCountFunction::OnGotLastSession, this));
|
|
|
+
|
|
|
+ return RespondLater();
|
|
|
+}
|
|
|
+
|
|
|
+void WisdomSvcGetLastSessionTabsCountFunction::OnGotLastSession(
|
|
|
+ std::vector<std::unique_ptr<sessions::SessionWindow>> sessionWindows,
|
|
|
+ SessionID sessionId,
|
|
|
+ bool no_use) {
|
|
|
+ Respond(WithArguments((int)sessionWindows.size()));
|
|
|
+}
|
|
|
|
|
|
} // namespace extensions
|