Add WebContentsPreferences::From that checks parameter
This commit is contained in:
parent
9772777919
commit
887bc12350
7 changed files with 21 additions and 15 deletions
|
@ -115,7 +115,7 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
||||||
// These preferences will be used when the webContent launches new
|
// These preferences will be used when the webContent launches new
|
||||||
// render processes.
|
// render processes.
|
||||||
auto* existing_preferences =
|
auto* existing_preferences =
|
||||||
WebContentsPreferences::FromWebContents(web_contents->web_contents());
|
WebContentsPreferences::From(web_contents->web_contents());
|
||||||
base::DictionaryValue web_preferences_dict;
|
base::DictionaryValue web_preferences_dict;
|
||||||
if (mate::ConvertFromV8(isolate, web_preferences.GetHandle(),
|
if (mate::ConvertFromV8(isolate, web_preferences.GetHandle(),
|
||||||
&web_preferences_dict)) {
|
&web_preferences_dict)) {
|
||||||
|
|
|
@ -1122,8 +1122,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||||
// created after loading a page.
|
// created after loading a page.
|
||||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||||
if (view) {
|
if (view) {
|
||||||
WebContentsPreferences* web_preferences =
|
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||||
WebContentsPreferences::FromWebContents(web_contents());
|
|
||||||
std::string color_name;
|
std::string color_name;
|
||||||
if (web_preferences->dict()->GetString(options::kBackgroundColor,
|
if (web_preferences->dict()->GetString(options::kBackgroundColor,
|
||||||
&color_name)) {
|
&color_name)) {
|
||||||
|
@ -1840,8 +1839,7 @@ void WebContents::OnGetZoomLevel(content::RenderFrameHost* rfh,
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
||||||
WebContentsPreferences* web_preferences =
|
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||||
WebContentsPreferences::FromWebContents(web_contents());
|
|
||||||
if (!web_preferences)
|
if (!web_preferences)
|
||||||
return v8::Null(isolate);
|
return v8::Null(isolate);
|
||||||
return mate::ConvertToV8(isolate, *web_preferences->dict());
|
return mate::ConvertToV8(isolate, *web_preferences->dict());
|
||||||
|
|
|
@ -34,7 +34,7 @@ void AddGuest(int guest_instance_id,
|
||||||
->SetDefaultZoomFactor(zoom_factor);
|
->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) {
|
void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
|
||||||
|
|
|
@ -235,8 +235,7 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
||||||
// Do we have an affinity site to manage ?
|
// Do we have an affinity site to manage ?
|
||||||
std::string affinity;
|
std::string affinity;
|
||||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||||
auto* web_preferences = web_contents ?
|
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||||
WebContentsPreferences::FromWebContents(web_contents) : nullptr;
|
|
||||||
if (web_preferences &&
|
if (web_preferences &&
|
||||||
web_preferences->dict()->GetString("affinity", &affinity) &&
|
web_preferences->dict()->GetString("affinity", &affinity) &&
|
||||||
!affinity.empty()) {
|
!affinity.empty()) {
|
||||||
|
|
|
@ -1370,14 +1370,12 @@ void NativeWindowViews::ShowAutofillPopup(
|
||||||
bool is_offsceen = false;
|
bool is_offsceen = false;
|
||||||
bool is_embedder_offscreen = false;
|
bool is_embedder_offscreen = false;
|
||||||
|
|
||||||
auto* web_contents_preferences =
|
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||||
WebContentsPreferences::FromWebContents(web_contents);
|
if (web_preferences) {
|
||||||
if (web_contents_preferences) {
|
web_preferences->dict()->GetBoolean("offscreen", &is_offsceen);
|
||||||
const auto* web_preferences = web_contents_preferences->dict();
|
|
||||||
|
|
||||||
web_preferences->GetBoolean("offscreen", &is_offsceen);
|
|
||||||
int guest_instance_id = 0;
|
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) {
|
if (guest_instance_id) {
|
||||||
auto manager = WebViewManager::GetWebViewManager(web_contents);
|
auto manager = WebViewManager::GetWebViewManager(web_contents);
|
||||||
|
|
|
@ -105,6 +105,14 @@ content::WebContents* WebContentsPreferences::GetWebContentsFromProcessID(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
WebContentsPreferences* WebContentsPreferences::From(
|
||||||
|
content::WebContents* web_contents) {
|
||||||
|
if (!web_contents)
|
||||||
|
return nullptr;
|
||||||
|
return FromWebContents(web_contents);
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||||
content::WebContents* web_contents, base::CommandLine* command_line) {
|
content::WebContents* web_contents, base::CommandLine* command_line) {
|
||||||
|
|
|
@ -33,6 +33,9 @@ class WebContentsPreferences
|
||||||
// FIXME(zcbenz): This method does not belong here.
|
// FIXME(zcbenz): This method does not belong here.
|
||||||
static content::WebContents* GetWebContentsFromProcessID(int process_id);
|
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.
|
// Append command paramters according to |web_contents|'s preferences.
|
||||||
static void AppendExtraCommandLineSwitches(
|
static void AppendExtraCommandLineSwitches(
|
||||||
content::WebContents* web_contents, base::CommandLine* command_line);
|
content::WebContents* web_contents, base::CommandLine* command_line);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue