зеркало из https://github.com/electron/electron.git
Add WebContentsPreferences::From that checks parameter
This commit is contained in:
Родитель
9772777919
Коммит
887bc12350
|
@ -115,7 +115,7 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
|||
// These preferences will be used when the webContent launches new
|
||||
// render processes.
|
||||
auto* existing_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents->web_contents());
|
||||
WebContentsPreferences::From(web_contents->web_contents());
|
||||
base::DictionaryValue web_preferences_dict;
|
||||
if (mate::ConvertFromV8(isolate, web_preferences.GetHandle(),
|
||||
&web_preferences_dict)) {
|
||||
|
|
|
@ -1122,8 +1122,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
|||
// created after loading a page.
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
if (view) {
|
||||
WebContentsPreferences* web_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents());
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
std::string color_name;
|
||||
if (web_preferences->dict()->GetString(options::kBackgroundColor,
|
||||
&color_name)) {
|
||||
|
@ -1840,8 +1839,7 @@ void WebContents::OnGetZoomLevel(content::RenderFrameHost* rfh,
|
|||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
||||
WebContentsPreferences* web_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents());
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
if (!web_preferences)
|
||||
return v8::Null(isolate);
|
||||
return mate::ConvertToV8(isolate, *web_preferences->dict());
|
||||
|
|
|
@ -34,7 +34,7 @@ void AddGuest(int guest_instance_id,
|
|||
->SetDefaultZoomFactor(zoom_factor);
|
||||
}
|
||||
|
||||
WebContentsPreferences::FromWebContents(guest_web_contents)->Merge(options);
|
||||
WebContentsPreferences::From(guest_web_contents)->Merge(options);
|
||||
}
|
||||
|
||||
void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
|
||||
|
|
|
@ -235,8 +235,7 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
|||
// Do we have an affinity site to manage ?
|
||||
std::string affinity;
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
auto* web_preferences = web_contents ?
|
||||
WebContentsPreferences::FromWebContents(web_contents) : nullptr;
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||
if (web_preferences &&
|
||||
web_preferences->dict()->GetString("affinity", &affinity) &&
|
||||
!affinity.empty()) {
|
||||
|
|
|
@ -1370,14 +1370,12 @@ void NativeWindowViews::ShowAutofillPopup(
|
|||
bool is_offsceen = false;
|
||||
bool is_embedder_offscreen = false;
|
||||
|
||||
auto* web_contents_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents);
|
||||
if (web_contents_preferences) {
|
||||
const auto* web_preferences = web_contents_preferences->dict();
|
||||
|
||||
web_preferences->GetBoolean("offscreen", &is_offsceen);
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||
if (web_preferences) {
|
||||
web_preferences->dict()->GetBoolean("offscreen", &is_offsceen);
|
||||
int guest_instance_id = 0;
|
||||
web_preferences->GetInteger(options::kGuestInstanceID, &guest_instance_id);
|
||||
web_preferences->dict()->GetInteger(options::kGuestInstanceID,
|
||||
&guest_instance_id);
|
||||
|
||||
if (guest_instance_id) {
|
||||
auto manager = WebViewManager::GetWebViewManager(web_contents);
|
||||
|
|
|
@ -105,6 +105,14 @@ content::WebContents* WebContentsPreferences::GetWebContentsFromProcessID(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
WebContentsPreferences* WebContentsPreferences::From(
|
||||
content::WebContents* web_contents) {
|
||||
if (!web_contents)
|
||||
return nullptr;
|
||||
return FromWebContents(web_contents);
|
||||
}
|
||||
|
||||
// static
|
||||
void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
content::WebContents* web_contents, base::CommandLine* command_line) {
|
||||
|
|
|
@ -33,6 +33,9 @@ class WebContentsPreferences
|
|||
// FIXME(zcbenz): This method does not belong here.
|
||||
static content::WebContents* GetWebContentsFromProcessID(int process_id);
|
||||
|
||||
// Get self from WebContents.
|
||||
static WebContentsPreferences* From(content::WebContents* web_contents);
|
||||
|
||||
// Append command paramters according to |web_contents|'s preferences.
|
||||
static void AppendExtraCommandLineSwitches(
|
||||
content::WebContents* web_contents, base::CommandLine* command_line);
|
||||
|
|
Загрузка…
Ссылка в новой задаче