refactor: ginify Session (#23569)
This commit is contained in:
parent
3f3a760a01
commit
de44d28c8e
11 changed files with 135 additions and 111 deletions
|
@ -12,9 +12,13 @@
|
|||
#include "content/public/browser/download_manager.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "gin/handle.h"
|
||||
#include "gin/wrappable.h"
|
||||
#include "shell/browser/event_emitter_mixin.h"
|
||||
#include "shell/browser/net/resolve_proxy_helper.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/function_template_extensions.h"
|
||||
#include "shell/common/gin_helper/pinnable.h"
|
||||
#include "shell/common/gin_helper/promise.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
#include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" // nogncheck
|
||||
|
@ -30,6 +34,10 @@ namespace gin_helper {
|
|||
class Dictionary;
|
||||
}
|
||||
|
||||
namespace gin {
|
||||
class Arguments;
|
||||
}
|
||||
|
||||
namespace net {
|
||||
class ProxyConfig;
|
||||
}
|
||||
|
@ -40,7 +48,9 @@ class ElectronBrowserContext;
|
|||
|
||||
namespace api {
|
||||
|
||||
class Session : public gin_helper::TrackableObject<Session>,
|
||||
class Session : public gin::Wrappable<Session>,
|
||||
public gin_helper::Pinnable<Session>,
|
||||
public gin_helper::EventEmitterMixin<Session>,
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
public SpellcheckHunspellDictionary::Observer,
|
||||
#endif
|
||||
|
@ -51,6 +61,8 @@ class Session : public gin_helper::TrackableObject<Session>,
|
|||
v8::Isolate* isolate,
|
||||
ElectronBrowserContext* browser_context);
|
||||
|
||||
static Session* FromBrowserContext(content::BrowserContext* context);
|
||||
|
||||
// Gets the Session of |partition|.
|
||||
static gin::Handle<Session> FromPartition(
|
||||
v8::Isolate* isolate,
|
||||
|
@ -61,30 +73,31 @@ class Session : public gin_helper::TrackableObject<Session>,
|
|||
return browser_context_.get();
|
||||
}
|
||||
|
||||
// gin_helper::TrackableObject:
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
// gin::Wrappable
|
||||
static gin::WrapperInfo kWrapperInfo;
|
||||
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) override;
|
||||
const char* GetTypeName() override;
|
||||
|
||||
// Methods.
|
||||
v8::Local<v8::Promise> ResolveProxy(gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> ResolveProxy(gin::Arguments* args);
|
||||
v8::Local<v8::Promise> GetCacheSize();
|
||||
v8::Local<v8::Promise> ClearCache();
|
||||
v8::Local<v8::Promise> ClearStorageData(gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> ClearStorageData(gin::Arguments* args);
|
||||
void FlushStorageData();
|
||||
v8::Local<v8::Promise> SetProxy(gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> SetProxy(gin::Arguments* args);
|
||||
void SetDownloadPath(const base::FilePath& path);
|
||||
void EnableNetworkEmulation(const gin_helper::Dictionary& options);
|
||||
void DisableNetworkEmulation();
|
||||
void SetCertVerifyProc(v8::Local<v8::Value> proc,
|
||||
gin_helper::Arguments* args);
|
||||
void SetCertVerifyProc(v8::Local<v8::Value> proc, gin::Arguments* args);
|
||||
void SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||
gin_helper::Arguments* args);
|
||||
gin::Arguments* args);
|
||||
void SetPermissionCheckHandler(v8::Local<v8::Value> val,
|
||||
gin_helper::Arguments* args);
|
||||
v8::Local<v8::Promise> ClearHostResolverCache(gin_helper::Arguments* args);
|
||||
gin::Arguments* args);
|
||||
v8::Local<v8::Promise> ClearHostResolverCache(gin::Arguments* args);
|
||||
v8::Local<v8::Promise> ClearAuthCache();
|
||||
void AllowNTLMCredentialsForDomains(const std::string& domains);
|
||||
void SetUserAgent(const std::string& user_agent, gin_helper::Arguments* args);
|
||||
void SetUserAgent(const std::string& user_agent, gin::Arguments* args);
|
||||
std::string GetUserAgent();
|
||||
bool IsPersistent();
|
||||
v8::Local<v8::Promise> GetBlobData(v8::Isolate* isolate,
|
||||
|
@ -98,8 +111,7 @@ class Session : public gin_helper::TrackableObject<Session>,
|
|||
v8::Local<v8::Value> ServiceWorkerContext(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> NetLog(v8::Isolate* isolate);
|
||||
void Preconnect(const gin_helper::Dictionary& options,
|
||||
gin_helper::Arguments* args);
|
||||
void Preconnect(const gin_helper::Dictionary& options, gin::Arguments* args);
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
base::Value GetSpellCheckerLanguages();
|
||||
void SetSpellCheckerLanguages(gin_helper::ErrorThrower thrower,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue