2015-09-04 16:44:22 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "atom/browser/web_contents_preferences.h"
|
|
|
|
|
2016-03-09 12:34:51 +00:00
|
|
|
#include <algorithm>
|
2015-09-05 11:47:44 +00:00
|
|
|
#include <string>
|
2016-03-09 12:34:51 +00:00
|
|
|
#include <vector>
|
2015-09-05 11:47:44 +00:00
|
|
|
|
2016-04-14 01:50:07 +00:00
|
|
|
#include "atom/browser/native_window.h"
|
2016-05-25 17:13:12 +00:00
|
|
|
#include "atom/browser/web_view_manager.h"
|
2015-11-11 02:32:25 +00:00
|
|
|
#include "atom/common/native_mate_converters/value_converter.h"
|
2015-09-04 17:04:09 +00:00
|
|
|
#include "atom/common/options_switches.h"
|
|
|
|
#include "base/command_line.h"
|
2017-08-07 20:30:03 +00:00
|
|
|
#include "base/memory/ptr_util.h"
|
2015-09-04 17:33:13 +00:00
|
|
|
#include "base/strings/string_number_conversions.h"
|
2016-08-26 22:30:02 +00:00
|
|
|
#include "cc/base/switches.h"
|
2018-03-12 08:27:43 +00:00
|
|
|
#include "content/public/browser/render_frame_host.h"
|
2016-03-09 12:34:51 +00:00
|
|
|
#include "content/public/browser/render_process_host.h"
|
2016-01-07 04:49:00 +00:00
|
|
|
#include "content/public/common/content_switches.h"
|
2015-09-04 17:12:32 +00:00
|
|
|
#include "content/public/common/web_preferences.h"
|
2015-11-11 02:32:25 +00:00
|
|
|
#include "native_mate/dictionary.h"
|
2015-09-05 01:57:39 +00:00
|
|
|
#include "net/base/filename_util.h"
|
2015-09-04 17:04:09 +00:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "ui/gfx/switches.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-07 07:55:08 +00:00
|
|
|
DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::WebContentsPreferences);
|
|
|
|
|
2015-09-04 16:44:22 +00:00
|
|
|
namespace atom {
|
|
|
|
|
2016-03-09 12:34:51 +00:00
|
|
|
// static
|
|
|
|
std::vector<WebContentsPreferences*> WebContentsPreferences::instances_;
|
|
|
|
|
2015-09-04 16:44:22 +00:00
|
|
|
WebContentsPreferences::WebContentsPreferences(
|
|
|
|
content::WebContents* web_contents,
|
2016-03-09 12:34:51 +00:00
|
|
|
const mate::Dictionary& web_preferences)
|
|
|
|
: web_contents_(web_contents) {
|
2015-11-11 02:32:25 +00:00
|
|
|
v8::Isolate* isolate = web_preferences.isolate();
|
|
|
|
mate::Dictionary copied(isolate, web_preferences.GetHandle()->Clone());
|
|
|
|
// Following fields should not be stored.
|
|
|
|
copied.Delete("embedder");
|
|
|
|
copied.Delete("isGuest");
|
|
|
|
copied.Delete("session");
|
|
|
|
|
2018-03-08 07:05:12 +00:00
|
|
|
mate::ConvertFromV8(isolate, copied.GetHandle(), &dict_);
|
2017-08-07 20:30:03 +00:00
|
|
|
web_contents->SetUserData(UserDataKey(), base::WrapUnique(this));
|
2016-03-09 12:34:51 +00:00
|
|
|
|
|
|
|
instances_.push_back(this);
|
2018-03-15 04:56:46 +00:00
|
|
|
|
|
|
|
// Set WebPreferences defaults onto the JS object
|
|
|
|
SetDefaultBoolIfUndefined("plugins", false);
|
|
|
|
SetDefaultBoolIfUndefined(options::kExperimentalFeatures, false);
|
|
|
|
SetDefaultBoolIfUndefined(options::kExperimentalCanvasFeatures, false);
|
|
|
|
bool node = SetDefaultBoolIfUndefined(options::kNodeIntegration, true);
|
|
|
|
SetDefaultBoolIfUndefined(options::kNodeIntegrationInWorker, false);
|
|
|
|
SetDefaultBoolIfUndefined(options::kWebviewTag, node);
|
|
|
|
SetDefaultBoolIfUndefined("sandbox", false);
|
|
|
|
SetDefaultBoolIfUndefined("nativeWindowOpen", false);
|
|
|
|
SetDefaultBoolIfUndefined(options::kContextIsolation, false);
|
|
|
|
SetDefaultBoolIfUndefined("javascript", true);
|
|
|
|
SetDefaultBoolIfUndefined("images", true);
|
|
|
|
SetDefaultBoolIfUndefined("textAreasAreResizable", true);
|
|
|
|
SetDefaultBoolIfUndefined("webgl", true);
|
|
|
|
SetDefaultBoolIfUndefined("webSecurity", true);
|
|
|
|
SetDefaultBoolIfUndefined("allowRunningInsecureContent", false);
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
SetDefaultBoolIfUndefined(options::kScrollBounce, false);
|
|
|
|
#endif
|
|
|
|
SetDefaultBoolIfUndefined("offscreen", false);
|
2018-03-08 07:05:12 +00:00
|
|
|
|
2018-03-22 06:29:20 +00:00
|
|
|
last_dict_ = std::move(*dict_.CreateDeepCopy());
|
2015-09-04 16:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WebContentsPreferences::~WebContentsPreferences() {
|
2016-03-09 12:34:51 +00:00
|
|
|
instances_.erase(
|
|
|
|
std::remove(instances_.begin(), instances_.end(), this),
|
|
|
|
instances_.end());
|
2015-09-04 16:44:22 +00:00
|
|
|
}
|
|
|
|
|
2018-03-08 07:36:21 +00:00
|
|
|
bool WebContentsPreferences::SetDefaultBoolIfUndefined(
|
|
|
|
const base::StringPiece& key, bool val) {
|
2018-03-15 04:56:46 +00:00
|
|
|
bool existing;
|
2018-03-08 07:36:21 +00:00
|
|
|
if (!dict_.GetBoolean(key, &existing)) {
|
|
|
|
dict_.SetBoolean(key, val);
|
2018-03-15 04:56:46 +00:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
return existing;
|
|
|
|
}
|
|
|
|
|
2018-03-08 07:36:21 +00:00
|
|
|
bool WebContentsPreferences::IsEnabled(const base::StringPiece& name,
|
|
|
|
bool default_value) {
|
|
|
|
bool bool_value = default_value;
|
|
|
|
dict_.GetBoolean(name, &bool_value);
|
|
|
|
return bool_value;
|
|
|
|
}
|
|
|
|
|
2015-09-05 02:43:30 +00:00
|
|
|
void WebContentsPreferences::Merge(const base::DictionaryValue& extend) {
|
2018-03-08 07:05:12 +00:00
|
|
|
dict_.MergeDictionary(&extend);
|
2015-09-05 02:43:30 +00:00
|
|
|
}
|
|
|
|
|
2016-03-09 12:34:51 +00:00
|
|
|
// static
|
|
|
|
content::WebContents* WebContentsPreferences::GetWebContentsFromProcessID(
|
|
|
|
int process_id) {
|
|
|
|
for (WebContentsPreferences* preferences : instances_) {
|
|
|
|
content::WebContents* web_contents = preferences->web_contents_;
|
2017-12-18 02:46:23 +00:00
|
|
|
if (web_contents->GetMainFrame()->GetProcess()->GetID() == process_id)
|
2016-03-09 12:34:51 +00:00
|
|
|
return web_contents;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-03-08 07:12:45 +00:00
|
|
|
// static
|
|
|
|
WebContentsPreferences* WebContentsPreferences::From(
|
|
|
|
content::WebContents* web_contents) {
|
|
|
|
if (!web_contents)
|
|
|
|
return nullptr;
|
|
|
|
return FromWebContents(web_contents);
|
|
|
|
}
|
|
|
|
|
2018-03-08 08:01:54 +00:00
|
|
|
void WebContentsPreferences::AppendCommandLineSwitches(
|
|
|
|
base::CommandLine* command_line) {
|
2015-09-04 17:04:09 +00:00
|
|
|
bool b;
|
|
|
|
// Check if plugins are enabled.
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("plugins", &b) && b)
|
2015-09-04 17:04:09 +00:00
|
|
|
command_line->AppendSwitch(switches::kEnablePlugins);
|
|
|
|
|
2016-01-07 04:49:00 +00:00
|
|
|
// Experimental flags.
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean(options::kExperimentalFeatures, &b) && b)
|
2016-01-07 04:49:00 +00:00
|
|
|
command_line->AppendSwitch(
|
|
|
|
::switches::kEnableExperimentalWebPlatformFeatures);
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean(options::kExperimentalCanvasFeatures, &b) && b)
|
2016-01-07 04:49:00 +00:00
|
|
|
command_line->AppendSwitch(::switches::kEnableExperimentalCanvasFeatures);
|
2015-09-04 17:33:13 +00:00
|
|
|
|
|
|
|
// Check if we have node integration specified.
|
|
|
|
bool node_integration = true;
|
2018-03-08 08:01:54 +00:00
|
|
|
dict_.GetBoolean(options::kNodeIntegration, &node_integration);
|
2015-09-04 17:33:13 +00:00
|
|
|
command_line->AppendSwitchASCII(switches::kNodeIntegration,
|
|
|
|
node_integration ? "true" : "false");
|
|
|
|
|
2017-03-15 09:51:21 +00:00
|
|
|
// Whether to enable node integration in Worker.
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean(options::kNodeIntegrationInWorker, &b) && b)
|
2017-03-15 09:51:21 +00:00
|
|
|
command_line->AppendSwitch(switches::kNodeIntegrationInWorker);
|
|
|
|
|
2017-05-17 20:09:24 +00:00
|
|
|
// Check if webview tag creation is enabled, default to nodeIntegration value.
|
|
|
|
// TODO(kevinsawicki): Default to false in 2.0
|
|
|
|
bool webview_tag = node_integration;
|
2018-03-08 08:01:54 +00:00
|
|
|
dict_.GetBoolean(options::kWebviewTag, &webview_tag);
|
2017-05-17 20:09:24 +00:00
|
|
|
command_line->AppendSwitchASCII(switches::kWebviewTag,
|
|
|
|
webview_tag ? "true" : "false");
|
2017-05-07 05:10:42 +00:00
|
|
|
|
2016-08-15 10:59:08 +00:00
|
|
|
// If the `sandbox` option was passed to the BrowserWindow's webPreferences,
|
|
|
|
// pass `--enable-sandbox` to the renderer so it won't have any node.js
|
|
|
|
// integration.
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("sandbox", &b) && b)
|
2016-08-15 10:59:08 +00:00
|
|
|
command_line->AppendSwitch(switches::kEnableSandbox);
|
2018-03-08 08:01:54 +00:00
|
|
|
else if (!command_line->HasSwitch(switches::kEnableSandbox))
|
2017-06-14 01:45:24 +00:00
|
|
|
command_line->AppendSwitch(::switches::kNoSandbox);
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("nativeWindowOpen", &b) && b)
|
2017-03-19 08:41:20 +00:00
|
|
|
command_line->AppendSwitch(switches::kNativeWindowOpen);
|
2016-08-15 10:59:08 +00:00
|
|
|
|
2015-09-04 17:33:13 +00:00
|
|
|
// The preload script.
|
|
|
|
base::FilePath::StringType preload;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetString(options::kPreloadScript, &preload)) {
|
2015-09-05 01:57:39 +00:00
|
|
|
if (base::FilePath(preload).IsAbsolute())
|
|
|
|
command_line->AppendSwitchNative(switches::kPreloadScript, preload);
|
|
|
|
else
|
2015-09-19 21:11:29 +00:00
|
|
|
LOG(ERROR) << "preload script must have absolute path.";
|
2018-03-08 08:01:54 +00:00
|
|
|
} else if (dict_.GetString(options::kPreloadURL, &preload)) {
|
2015-09-05 01:57:39 +00:00
|
|
|
// Translate to file path if there is "preload-url" option.
|
|
|
|
base::FilePath preload_path;
|
|
|
|
if (net::FileURLToFilePath(GURL(preload), &preload_path))
|
|
|
|
command_line->AppendSwitchPath(switches::kPreloadScript, preload_path);
|
|
|
|
else
|
|
|
|
LOG(ERROR) << "preload url must be file:// protocol.";
|
|
|
|
}
|
2015-09-04 17:33:13 +00:00
|
|
|
|
2018-02-12 17:54:31 +00:00
|
|
|
// Custom args for renderer process
|
|
|
|
base::Value* customArgs;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.Get(options::kCustomArgs, &customArgs) &&
|
|
|
|
customArgs->is_list()) {
|
2018-02-12 17:54:31 +00:00
|
|
|
for (const base::Value& customArg : customArgs->GetList()) {
|
2018-03-08 08:01:54 +00:00
|
|
|
if (customArg.is_string())
|
2018-02-12 17:54:31 +00:00
|
|
|
command_line->AppendArg(customArg.GetString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-08 23:33:51 +00:00
|
|
|
// Run Electron APIs and preload script in isolated world
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean(options::kContextIsolation, &b) && b)
|
2016-12-15 21:20:17 +00:00
|
|
|
command_line->AppendSwitch(switches::kContextIsolation);
|
2016-12-08 23:33:51 +00:00
|
|
|
|
2016-04-02 11:35:57 +00:00
|
|
|
// --background-color.
|
2018-03-08 08:01:54 +00:00
|
|
|
std::string s;
|
|
|
|
if (dict_.GetString(options::kBackgroundColor, &s))
|
|
|
|
command_line->AppendSwitchASCII(switches::kBackgroundColor, s);
|
2016-04-02 11:35:57 +00:00
|
|
|
|
2015-09-05 02:43:30 +00:00
|
|
|
// --guest-instance-id, which is used to identify guest WebContents.
|
2016-05-26 01:05:37 +00:00
|
|
|
int guest_instance_id = 0;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetInteger(options::kGuestInstanceID, &guest_instance_id))
|
2016-04-13 13:56:11 +00:00
|
|
|
command_line->AppendSwitchASCII(switches::kGuestInstanceID,
|
|
|
|
base::IntToString(guest_instance_id));
|
2015-12-17 13:27:14 +00:00
|
|
|
|
|
|
|
// Pass the opener's window id.
|
|
|
|
int opener_id;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetInteger(options::kOpenerID, &opener_id))
|
2016-04-13 13:56:11 +00:00
|
|
|
command_line->AppendSwitchASCII(switches::kOpenerID,
|
|
|
|
base::IntToString(opener_id));
|
2016-01-07 06:10:18 +00:00
|
|
|
|
2016-05-06 05:57:43 +00:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
// Enable scroll bounce.
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean(options::kScrollBounce, &b) && b)
|
2016-05-06 05:57:43 +00:00
|
|
|
command_line->AppendSwitch(switches::kScrollBounce);
|
|
|
|
#endif
|
|
|
|
|
2016-05-29 01:34:53 +00:00
|
|
|
// Custom command line switches.
|
|
|
|
const base::ListValue* args;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetList("commandLineSwitches", &args)) {
|
2016-05-29 01:34:53 +00:00
|
|
|
for (size_t i = 0; i < args->GetSize(); ++i) {
|
|
|
|
std::string arg;
|
|
|
|
if (args->GetString(i, &arg) && !arg.empty())
|
|
|
|
command_line->AppendSwitch(arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-07 06:10:18 +00:00
|
|
|
// Enable blink features.
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetString(options::kBlinkFeatures, &s))
|
|
|
|
command_line->AppendSwitchASCII(::switches::kEnableBlinkFeatures, s);
|
2016-04-13 13:56:11 +00:00
|
|
|
|
2016-06-07 20:42:42 +00:00
|
|
|
// Disable blink features.
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetString(options::kDisableBlinkFeatures, &s))
|
|
|
|
command_line->AppendSwitchASCII(::switches::kDisableBlinkFeatures, s);
|
2016-06-07 20:42:42 +00:00
|
|
|
|
2017-05-22 18:10:10 +00:00
|
|
|
if (guest_instance_id) {
|
|
|
|
// Webview `document.visibilityState` tracks window visibility so we need
|
|
|
|
// to let it know if the window happens to be hidden right now.
|
2018-03-08 08:01:54 +00:00
|
|
|
auto* manager = WebViewManager::GetWebViewManager(web_contents_);
|
2016-05-25 17:13:12 +00:00
|
|
|
if (manager) {
|
2018-03-08 08:01:54 +00:00
|
|
|
auto* embedder = manager->GetEmbedder(guest_instance_id);
|
2017-05-22 18:10:10 +00:00
|
|
|
if (embedder) {
|
2018-03-08 08:01:54 +00:00
|
|
|
auto* relay = NativeWindowRelay::FromWebContents(embedder);
|
2018-03-06 06:18:45 +00:00
|
|
|
if (relay) {
|
|
|
|
auto* window = relay->window.get();
|
|
|
|
if (window) {
|
|
|
|
const bool visible = window->IsVisible() && !window->IsMinimized();
|
|
|
|
if (!visible) {
|
|
|
|
command_line->AppendSwitch(switches::kHiddenPage);
|
|
|
|
}
|
2017-06-07 00:02:23 +00:00
|
|
|
}
|
2017-05-22 18:10:10 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-25 17:13:12 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-08 08:01:54 +00:00
|
|
|
|
|
|
|
// We are appending args to a webContents so let's save the current state
|
|
|
|
// of our preferences object so that during the lifetime of the WebContents
|
|
|
|
// we can fetch the options used to initally configure the WebContents
|
2018-03-22 06:29:20 +00:00
|
|
|
last_dict_ = std::move(*dict_.CreateDeepCopy());
|
2015-09-04 17:04:09 +00:00
|
|
|
}
|
|
|
|
|
2015-09-04 17:12:32 +00:00
|
|
|
void WebContentsPreferences::OverrideWebkitPrefs(
|
2018-03-08 08:01:54 +00:00
|
|
|
content::WebPreferences* prefs) {
|
2015-09-04 17:12:32 +00:00
|
|
|
bool b;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("javascript", &b))
|
2015-09-04 17:12:32 +00:00
|
|
|
prefs->javascript_enabled = b;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("images", &b))
|
2015-09-04 17:12:32 +00:00
|
|
|
prefs->images_enabled = b;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("textAreasAreResizable", &b))
|
2015-09-04 17:12:32 +00:00
|
|
|
prefs->text_areas_are_resizable = b;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("webgl", &b)) {
|
2017-12-18 01:47:10 +00:00
|
|
|
prefs->webgl1_enabled = b;
|
|
|
|
prefs->webgl2_enabled = b;
|
|
|
|
}
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("webSecurity", &b)) {
|
2015-09-04 17:12:32 +00:00
|
|
|
prefs->web_security_enabled = b;
|
|
|
|
prefs->allow_running_insecure_content = !b;
|
|
|
|
}
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetBoolean("allowRunningInsecureContent", &b))
|
2015-09-04 17:12:32 +00:00
|
|
|
prefs->allow_running_insecure_content = b;
|
2016-01-19 14:13:23 +00:00
|
|
|
const base::DictionaryValue* fonts = nullptr;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetDictionary("defaultFontFamily", &fonts)) {
|
2016-01-19 14:13:23 +00:00
|
|
|
base::string16 font;
|
|
|
|
if (fonts->GetString("standard", &font))
|
|
|
|
prefs->standard_font_family_map[content::kCommonScript] = font;
|
|
|
|
if (fonts->GetString("serif", &font))
|
|
|
|
prefs->serif_font_family_map[content::kCommonScript] = font;
|
|
|
|
if (fonts->GetString("sansSerif", &font))
|
|
|
|
prefs->sans_serif_font_family_map[content::kCommonScript] = font;
|
|
|
|
if (fonts->GetString("monospace", &font))
|
|
|
|
prefs->fixed_font_family_map[content::kCommonScript] = font;
|
2016-12-28 18:29:55 +00:00
|
|
|
if (fonts->GetString("cursive", &font))
|
|
|
|
prefs->cursive_font_family_map[content::kCommonScript] = font;
|
|
|
|
if (fonts->GetString("fantasy", &font))
|
|
|
|
prefs->fantasy_font_family_map[content::kCommonScript] = font;
|
2016-01-19 14:13:23 +00:00
|
|
|
}
|
|
|
|
int size;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (GetInteger("defaultFontSize", &size))
|
2016-01-19 14:13:23 +00:00
|
|
|
prefs->default_font_size = size;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (GetInteger("defaultMonospaceFontSize", &size))
|
2016-01-19 14:13:23 +00:00
|
|
|
prefs->default_fixed_font_size = size;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (GetInteger("minimumFontSize", &size))
|
2016-01-19 14:13:23 +00:00
|
|
|
prefs->minimum_font_size = size;
|
|
|
|
std::string encoding;
|
2018-03-08 08:01:54 +00:00
|
|
|
if (dict_.GetString("defaultEncoding", &encoding))
|
2016-01-19 14:13:23 +00:00
|
|
|
prefs->default_encoding = encoding;
|
2015-09-04 17:12:32 +00:00
|
|
|
}
|
|
|
|
|
2018-03-08 07:36:21 +00:00
|
|
|
bool WebContentsPreferences::GetInteger(const base::StringPiece& attribute_name,
|
|
|
|
int* val) {
|
2017-02-07 17:13:42 +00:00
|
|
|
// if it is already an integer, no conversion needed
|
2018-03-08 07:36:21 +00:00
|
|
|
if (dict_.GetInteger(attribute_name, val))
|
2017-02-07 17:13:42 +00:00
|
|
|
return true;
|
|
|
|
|
2018-03-08 07:36:21 +00:00
|
|
|
std::string str;
|
|
|
|
if (dict_.GetString(attribute_name, &str))
|
|
|
|
return base::StringToInt(str, val);
|
2017-02-07 17:13:42 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-04 16:44:22 +00:00
|
|
|
} // namespace atom
|