Merge pull request #8542 from yamgent/webpref-numeric
Fix webpreferences not accepting numeric options
This commit is contained in:
commit
c3c5470a7c
2 changed files with 20 additions and 3 deletions
|
@ -254,15 +254,28 @@ void WebContentsPreferences::OverrideWebkitPrefs(
|
||||||
prefs->fantasy_font_family_map[content::kCommonScript] = font;
|
prefs->fantasy_font_family_map[content::kCommonScript] = font;
|
||||||
}
|
}
|
||||||
int size;
|
int size;
|
||||||
if (self->web_preferences_.GetInteger("defaultFontSize", &size))
|
if (self->GetInteger("defaultFontSize", &size))
|
||||||
prefs->default_font_size = size;
|
prefs->default_font_size = size;
|
||||||
if (self->web_preferences_.GetInteger("defaultMonospaceFontSize", &size))
|
if (self->GetInteger("defaultMonospaceFontSize", &size))
|
||||||
prefs->default_fixed_font_size = size;
|
prefs->default_fixed_font_size = size;
|
||||||
if (self->web_preferences_.GetInteger("minimumFontSize", &size))
|
if (self->GetInteger("minimumFontSize", &size))
|
||||||
prefs->minimum_font_size = size;
|
prefs->minimum_font_size = size;
|
||||||
std::string encoding;
|
std::string encoding;
|
||||||
if (self->web_preferences_.GetString("defaultEncoding", &encoding))
|
if (self->web_preferences_.GetString("defaultEncoding", &encoding))
|
||||||
prefs->default_encoding = encoding;
|
prefs->default_encoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebContentsPreferences::GetInteger(const std::string& attributeName,
|
||||||
|
int* intValue) {
|
||||||
|
// if it is already an integer, no conversion needed
|
||||||
|
if (web_preferences_.GetInteger(attributeName, intValue))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
base::string16 stringValue;
|
||||||
|
if (web_preferences_.GetString(attributeName, &stringValue))
|
||||||
|
return base::StringToInt(stringValue, intValue);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#ifndef ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
|
#ifndef ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
|
||||||
#define ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
|
#define ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
@ -60,6 +61,9 @@ class WebContentsPreferences
|
||||||
content::WebContents* web_contents_;
|
content::WebContents* web_contents_;
|
||||||
base::DictionaryValue web_preferences_;
|
base::DictionaryValue web_preferences_;
|
||||||
|
|
||||||
|
// Get preferences value as integer possibly coercing it from a string
|
||||||
|
bool GetInteger(const std::string& attributeName, int* intValue);
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);
|
DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue