refactor: remove base::Value from WebContentsPreferences (#30193)
This commit is contained in:
parent
64ba8feb93
commit
385d0f590f
10 changed files with 433 additions and 415 deletions
|
@ -908,8 +908,7 @@ void WebContents::InitWithWebContents(content::WebContents* web_contents,
|
|||
|
||||
// Determine whether the WebContents is offscreen.
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||
offscreen_ =
|
||||
web_preferences && web_preferences->IsEnabled(options::kOffscreen);
|
||||
offscreen_ = web_preferences && web_preferences->IsOffscreen();
|
||||
|
||||
// Create InspectableWebContents.
|
||||
inspectable_web_contents_ = std::make_unique<InspectableWebContents>(
|
||||
|
@ -1193,8 +1192,7 @@ bool WebContents::PlatformHandleKeyboardEvent(
|
|||
|
||||
// Check if the webContents has preferences and to ignore shortcuts
|
||||
auto* web_preferences = WebContentsPreferences::From(source);
|
||||
if (web_preferences &&
|
||||
web_preferences->IsEnabled("ignoreMenuShortcuts", false))
|
||||
if (web_preferences && web_preferences->ShouldIgnoreMenuShortcuts())
|
||||
return false;
|
||||
|
||||
// Let the NativeWindow handle other parts.
|
||||
|
@ -1378,12 +1376,7 @@ void WebContents::HandleNewRenderFrame(
|
|||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
if (web_preferences) {
|
||||
std::string color_name;
|
||||
if (web_preferences->GetPreference(options::kBackgroundColor,
|
||||
&color_name)) {
|
||||
rwhv->SetBackgroundColor(ParseHexColor(color_name));
|
||||
} else {
|
||||
rwhv->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
rwhv->SetBackgroundColor(web_preferences->GetBackgroundColor());
|
||||
}
|
||||
|
||||
if (!background_throttling_)
|
||||
|
@ -1514,8 +1507,7 @@ void WebContents::DidStartLoading() {
|
|||
|
||||
void WebContents::DidStopLoading() {
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
if (web_preferences &&
|
||||
web_preferences->IsEnabled(options::kEnablePreferredSizeMode))
|
||||
if (web_preferences && web_preferences->ShouldUsePreferredSizeMode())
|
||||
web_contents()->GetRenderViewHost()->EnablePreferredSizeMode();
|
||||
|
||||
Emit("did-stop-loading");
|
||||
|
@ -2344,8 +2336,7 @@ void WebContents::InspectServiceWorker() {
|
|||
void WebContents::SetIgnoreMenuShortcuts(bool ignore) {
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
DCHECK(web_preferences);
|
||||
web_preferences->preference()->SetKey("ignoreMenuShortcuts",
|
||||
base::Value(ignore));
|
||||
web_preferences->SetIgnoreMenuShortcuts(ignore);
|
||||
}
|
||||
|
||||
void WebContents::SetAudioMuted(bool muted) {
|
||||
|
@ -3141,8 +3132,7 @@ void WebContents::NotifyUserActivation() {
|
|||
|
||||
void WebContents::SetImageAnimationPolicy(const std::string& new_policy) {
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
web_preferences->preference()->SetKey(options::kImageAnimationPolicy,
|
||||
base::Value(new_policy));
|
||||
web_preferences->SetImageAnimationPolicy(new_policy);
|
||||
web_contents()->OnWebPreferencesChanged();
|
||||
}
|
||||
|
||||
|
@ -3561,9 +3551,9 @@ void WebContents::SetHtmlApiFullscreen(bool enter_fullscreen) {
|
|||
// Set fullscreen on window if allowed.
|
||||
auto* web_preferences = WebContentsPreferences::From(GetWebContents());
|
||||
bool html_fullscreenable =
|
||||
web_preferences ? !web_preferences->IsEnabled(
|
||||
options::kDisableHtmlFullscreenWindowResize)
|
||||
: true;
|
||||
web_preferences
|
||||
? !web_preferences->ShouldDisableHtmlFullscreenWindowResize()
|
||||
: true;
|
||||
|
||||
if (html_fullscreenable) {
|
||||
owner_window_->SetFullScreen(enter_fullscreen);
|
||||
|
@ -3818,11 +3808,10 @@ gin::Handle<WebContents> WebContents::CreateFromWebPreferences(
|
|||
// render processes.
|
||||
auto* existing_preferences =
|
||||
WebContentsPreferences::From(web_contents->web_contents());
|
||||
base::DictionaryValue web_preferences_dict;
|
||||
gin_helper::Dictionary web_preferences_dict;
|
||||
if (gin::ConvertFromV8(isolate, web_preferences.GetHandle(),
|
||||
&web_preferences_dict)) {
|
||||
existing_preferences->Clear();
|
||||
existing_preferences->Merge(web_preferences_dict);
|
||||
existing_preferences->SetFromDictionary(web_preferences_dict);
|
||||
}
|
||||
} else {
|
||||
// Create one if not.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue