#include "content/public/browser/browser_context.h"
#include "native_mate/dictionary.h"
+using atom::WebContentsPreferences;
+
namespace mate {
template<>
manager->AddGuest(guest_instance_id, element_instance_id, embedder,
guest_web_contents);
- atom::WebContentsPreferences::From(guest_web_contents)->Merge(options);
+ WebContentsPreferences::FromWebContents(guest_web_contents)->Merge(options);
}
void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
#include "ui/gfx/switches.h"
#endif
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::WebContentsPreferences);
+
namespace atom {
namespace {
-// Pointer as WebContents's user data key.
-const char* kWebPreferencesKey = "WebContentsPreferences";
-
// Array of available web runtime features.
const char* kWebRuntimeFeatures[] = {
switches::kExperimentalFeatures,
content::WebContents* web_contents,
base::DictionaryValue* web_preferences) {
web_preferences_.Swap(web_preferences);
- web_contents->SetUserData(kWebPreferencesKey, this);
+ web_contents->SetUserData(UserDataKey(), this);
}
WebContentsPreferences::~WebContentsPreferences() {
web_preferences_.MergeDictionary(&extend);
}
-// static
-WebContentsPreferences* WebContentsPreferences::From(
- content::WebContents* web_contents) {
- return static_cast<WebContentsPreferences*>(
- web_contents->GetUserData(kWebPreferencesKey));
-}
-
// static
void WebContentsPreferences::AppendExtraCommandLineSwitches(
content::WebContents* web_contents, base::CommandLine* command_line) {
- WebContentsPreferences* self = From(web_contents);
+ WebContentsPreferences* self = FromWebContents(web_contents);
if (!self)
return;
// static
void WebContentsPreferences::OverrideWebkitPrefs(
content::WebContents* web_contents, content::WebPreferences* prefs) {
- WebContentsPreferences* self = From(web_contents);
+ WebContentsPreferences* self = FromWebContents(web_contents);
if (!self)
return;
class WebContentsPreferences
: public content::WebContentsUserData<WebContentsPreferences> {
public:
- // Get the preferences of |web_contents|.
- 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);