also format missing .cc files
This commit is contained in:
parent
53bdf22c85
commit
c6f4bbd143
181 changed files with 4102 additions and 4254 deletions
|
@ -11,8 +11,8 @@
|
|||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||
|
||||
using content::RenderFrame;
|
||||
using blink::WebLocalFrame;
|
||||
using content::RenderFrame;
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -59,8 +59,10 @@ base::string16 SendSync(mate::Arguments* args,
|
|||
return json;
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("send", &Send);
|
||||
dict.SetMethod("sendSync", &SendSync);
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include "chrome/renderer/spellchecker/spellcheck_worditerator.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/icu/source/common/unicode/uscript.h"
|
||||
#include "third_party/WebKit/public/web/WebTextCheckingCompletion.h"
|
||||
#include "third_party/WebKit/public/web/WebTextCheckingResult.h"
|
||||
#include "third_party/icu/source/common/unicode/uscript.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "content/public/renderer/render_view.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
|
||||
#include "third_party/WebKit/public/platform/WebCache.h"
|
||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||
#include "third_party/WebKit/public/web/WebElement.h"
|
||||
|
@ -27,7 +28,6 @@
|
|||
#include "third_party/WebKit/public/web/WebScriptExecutionCallback.h"
|
||||
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
||||
#include "third_party/WebKit/public/web/WebView.h"
|
||||
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
|
@ -43,8 +43,7 @@ struct Converter<blink::WebLocalFrame::ScriptExecutionType> {
|
|||
return false;
|
||||
if (execution_type == "asynchronous") {
|
||||
*out = blink::WebLocalFrame::kAsynchronous;
|
||||
} else if (execution_type ==
|
||||
"asynchronousBlockingOnload") {
|
||||
} else if (execution_type == "asynchronousBlockingOnload") {
|
||||
*out = blink::WebLocalFrame::kAsynchronousBlockingOnload;
|
||||
} else if (execution_type == "synchronous") {
|
||||
*out = blink::WebLocalFrame::kSynchronous;
|
||||
|
@ -66,8 +65,7 @@ namespace {
|
|||
class ScriptExecutionCallback : public blink::WebScriptExecutionCallback {
|
||||
public:
|
||||
using CompletionCallback =
|
||||
base::Callback<void(
|
||||
const v8::Local<v8::Value>& result)>;
|
||||
base::Callback<void(const v8::Local<v8::Value>& result)>;
|
||||
|
||||
explicit ScriptExecutionCallback(const CompletionCallback& callback)
|
||||
: callback_(callback) {}
|
||||
|
@ -123,8 +121,7 @@ WebFrame::WebFrame(v8::Isolate* isolate, blink::WebLocalFrame* blink_frame)
|
|||
Init(isolate);
|
||||
}
|
||||
|
||||
WebFrame::~WebFrame() {
|
||||
}
|
||||
WebFrame::~WebFrame() {}
|
||||
|
||||
void WebFrame::SetName(const std::string& name) {
|
||||
web_frame_->SetName(blink::WebString::FromUTF8(name));
|
||||
|
@ -149,8 +146,8 @@ double WebFrame::GetZoomLevel() const {
|
|||
}
|
||||
|
||||
double WebFrame::SetZoomFactor(double factor) {
|
||||
return blink::WebView::ZoomLevelToZoomFactor(SetZoomLevel(
|
||||
blink::WebView::ZoomFactorToZoomLevel(factor)));
|
||||
return blink::WebView::ZoomLevelToZoomFactor(
|
||||
SetZoomLevel(blink::WebView::ZoomFactorToZoomLevel(factor)));
|
||||
}
|
||||
|
||||
double WebFrame::GetZoomFactor() const {
|
||||
|
@ -167,7 +164,8 @@ void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) {
|
|||
}
|
||||
|
||||
v8::Local<v8::Value> WebFrame::RegisterEmbedderCustomElement(
|
||||
const base::string16& name, v8::Local<v8::Object> options) {
|
||||
const base::string16& name,
|
||||
v8::Local<v8::Object> options) {
|
||||
return web_frame_->GetDocument().RegisterEmbedderCustomElement(
|
||||
blink::WebString::FromUTF16(name), options);
|
||||
}
|
||||
|
@ -267,12 +265,9 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
|||
}
|
||||
|
||||
void WebFrame::InsertText(const std::string& text) {
|
||||
web_frame_->FrameWidget()
|
||||
->GetActiveWebInputMethodController()
|
||||
->CommitText(blink::WebString::FromUTF8(text),
|
||||
blink::WebVector<blink::WebImeTextSpan>(),
|
||||
blink::WebRange(),
|
||||
0);
|
||||
web_frame_->FrameWidget()->GetActiveWebInputMethodController()->CommitText(
|
||||
blink::WebString::FromUTF8(text),
|
||||
blink::WebVector<blink::WebImeTextSpan>(), blink::WebRange(), 0);
|
||||
}
|
||||
|
||||
void WebFrame::InsertCSS(const std::string& css) {
|
||||
|
@ -289,8 +284,7 @@ void WebFrame::ExecuteJavaScript(const base::string16& code,
|
|||
new ScriptExecutionCallback(completion_callback));
|
||||
web_frame_->RequestExecuteScriptAndReturnValue(
|
||||
blink::WebScriptSource(blink::WebString::FromUTF16(code)),
|
||||
has_user_gesture,
|
||||
callback.release());
|
||||
has_user_gesture, callback.release());
|
||||
}
|
||||
|
||||
void WebFrame::ExecuteJavaScriptInIsolatedWorld(
|
||||
|
@ -311,9 +305,9 @@ void WebFrame::ExecuteJavaScriptInIsolatedWorld(
|
|||
return;
|
||||
}
|
||||
|
||||
sources.emplace_back(blink::WebScriptSource(
|
||||
blink::WebString::FromUTF16(code),
|
||||
blink::WebURL(GURL(url)), start_line));
|
||||
sources.emplace_back(
|
||||
blink::WebScriptSource(blink::WebString::FromUTF16(code),
|
||||
blink::WebURL(GURL(url)), start_line));
|
||||
}
|
||||
|
||||
bool has_user_gesture = false;
|
||||
|
@ -333,13 +327,11 @@ void WebFrame::ExecuteJavaScriptInIsolatedWorld(
|
|||
scriptExecutionType, callback.release());
|
||||
}
|
||||
|
||||
void WebFrame::SetIsolatedWorldSecurityOrigin(
|
||||
int world_id,
|
||||
const std::string& origin_url) {
|
||||
void WebFrame::SetIsolatedWorldSecurityOrigin(int world_id,
|
||||
const std::string& origin_url) {
|
||||
web_frame_->SetIsolatedWorldSecurityOrigin(
|
||||
world_id,
|
||||
blink::WebSecurityOrigin::CreateFromString(
|
||||
blink::WebString::FromUTF8(origin_url)));
|
||||
world_id, blink::WebSecurityOrigin::CreateFromString(
|
||||
blink::WebString::FromUTF8(origin_url)));
|
||||
}
|
||||
|
||||
void WebFrame::SetIsolatedWorldContentSecurityPolicy(
|
||||
|
@ -349,9 +341,8 @@ void WebFrame::SetIsolatedWorldContentSecurityPolicy(
|
|||
world_id, blink::WebString::FromUTF8(security_policy));
|
||||
}
|
||||
|
||||
void WebFrame::SetIsolatedWorldHumanReadableName(
|
||||
int world_id,
|
||||
const std::string& name) {
|
||||
void WebFrame::SetIsolatedWorldHumanReadableName(int world_id,
|
||||
const std::string& name) {
|
||||
web_frame_->SetIsolatedWorldHumanReadableName(
|
||||
world_id, blink::WebString::FromUTF8(name));
|
||||
}
|
||||
|
@ -372,15 +363,15 @@ void WebFrame::ClearCache(v8::Isolate* isolate) {
|
|||
isolate->IdleNotificationDeadline(0.5);
|
||||
blink::WebCache::Clear();
|
||||
base::MemoryPressureListener::NotifyMemoryPressure(
|
||||
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
|
||||
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebFrame::Opener() const {
|
||||
blink::WebFrame* frame = web_frame_->Opener();
|
||||
if (frame && frame->IsWebLocalFrame())
|
||||
return mate::CreateHandle(isolate(),
|
||||
new WebFrame(isolate(),
|
||||
frame->ToWebLocalFrame())).ToV8();
|
||||
new WebFrame(isolate(), frame->ToWebLocalFrame()))
|
||||
.ToV8();
|
||||
else
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
|
@ -389,8 +380,8 @@ v8::Local<v8::Value> WebFrame::Parent() const {
|
|||
blink::WebFrame* frame = web_frame_->Parent();
|
||||
if (frame && frame->IsWebLocalFrame())
|
||||
return mate::CreateHandle(isolate(),
|
||||
new WebFrame(isolate(),
|
||||
frame->ToWebLocalFrame())).ToV8();
|
||||
new WebFrame(isolate(), frame->ToWebLocalFrame()))
|
||||
.ToV8();
|
||||
else
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
|
@ -399,8 +390,8 @@ v8::Local<v8::Value> WebFrame::Top() const {
|
|||
blink::WebFrame* frame = web_frame_->Top();
|
||||
if (frame && frame->IsWebLocalFrame())
|
||||
return mate::CreateHandle(isolate(),
|
||||
new WebFrame(isolate(),
|
||||
frame->ToWebLocalFrame())).ToV8();
|
||||
new WebFrame(isolate(), frame->ToWebLocalFrame()))
|
||||
.ToV8();
|
||||
else
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
|
@ -409,8 +400,8 @@ v8::Local<v8::Value> WebFrame::FirstChild() const {
|
|||
blink::WebFrame* frame = web_frame_->FirstChild();
|
||||
if (frame && frame->IsWebLocalFrame())
|
||||
return mate::CreateHandle(isolate(),
|
||||
new WebFrame(isolate(),
|
||||
frame->ToWebLocalFrame())).ToV8();
|
||||
new WebFrame(isolate(), frame->ToWebLocalFrame()))
|
||||
.ToV8();
|
||||
else
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
|
@ -419,8 +410,8 @@ v8::Local<v8::Value> WebFrame::NextSibling() const {
|
|||
blink::WebFrame* frame = web_frame_->NextSibling();
|
||||
if (frame && frame->IsWebLocalFrame())
|
||||
return mate::CreateHandle(isolate(),
|
||||
new WebFrame(isolate(),
|
||||
frame->ToWebLocalFrame())).ToV8();
|
||||
new WebFrame(isolate(), frame->ToWebLocalFrame()))
|
||||
.ToV8();
|
||||
else
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
|
@ -432,25 +423,26 @@ v8::Local<v8::Value> WebFrame::GetFrameForSelector(
|
|||
blink::WebLocalFrame* element_frame =
|
||||
blink::WebLocalFrame::FromFrameOwnerElement(element);
|
||||
if (element_frame)
|
||||
return mate::CreateHandle(isolate(),
|
||||
new WebFrame(isolate(), element_frame)).ToV8();
|
||||
return mate::CreateHandle(isolate(), new WebFrame(isolate(), element_frame))
|
||||
.ToV8();
|
||||
else
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebFrame::FindFrameByName(const std::string& name) const {
|
||||
blink::WebLocalFrame* local_frame = web_frame_->FindFrameByName(
|
||||
blink::WebString::FromUTF8(name))->ToWebLocalFrame();
|
||||
blink::WebLocalFrame* local_frame =
|
||||
web_frame_->FindFrameByName(blink::WebString::FromUTF8(name))
|
||||
->ToWebLocalFrame();
|
||||
if (local_frame)
|
||||
return mate::CreateHandle(isolate(),
|
||||
new WebFrame(isolate(), local_frame)).ToV8();
|
||||
return mate::CreateHandle(isolate(), new WebFrame(isolate(), local_frame))
|
||||
.ToV8();
|
||||
else
|
||||
return v8::Null(isolate());
|
||||
}
|
||||
|
||||
// static
|
||||
void WebFrame::BuildPrototype(
|
||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
||||
void WebFrame::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "WebFrame"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("setName", &WebFrame::SetName)
|
||||
|
@ -505,8 +497,10 @@ namespace {
|
|||
|
||||
using atom::api::WebFrame;
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("webFrame", WebFrame::Create(isolate));
|
||||
|
|
|
@ -25,8 +25,8 @@ const size_t kMaxDataLength = 1024;
|
|||
const size_t kMaxListSize = 512;
|
||||
|
||||
void GetDataListSuggestions(const blink::WebInputElement& element,
|
||||
std::vector<base::string16>* values,
|
||||
std::vector<base::string16>* labels) {
|
||||
std::vector<base::string16>* values,
|
||||
std::vector<base::string16>* labels) {
|
||||
for (const auto& option : element.FilteredDataListOptions()) {
|
||||
values->push_back(option.Value().Utf16());
|
||||
if (option.Value() != option.Label())
|
||||
|
@ -49,12 +49,11 @@ void TrimStringVectorForIPC(std::vector<base::string16>* strings) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
AutofillAgent::AutofillAgent(
|
||||
content::RenderFrame* frame)
|
||||
: content::RenderFrameObserver(frame),
|
||||
focused_node_was_last_clicked_(false),
|
||||
was_focused_before_now_(false),
|
||||
weak_ptr_factory_(this) {
|
||||
AutofillAgent::AutofillAgent(content::RenderFrame* frame)
|
||||
: content::RenderFrameObserver(frame),
|
||||
focused_node_was_last_clicked_(false),
|
||||
was_focused_before_now_(false),
|
||||
weak_ptr_factory_(this) {
|
||||
render_frame()->GetWebFrame()->SetAutofillClient(this);
|
||||
}
|
||||
|
||||
|
@ -72,8 +71,7 @@ void AutofillAgent::FocusedNodeChanged(const blink::WebNode&) {
|
|||
HidePopup();
|
||||
}
|
||||
|
||||
void AutofillAgent::TextFieldDidEndEditing(
|
||||
const blink::WebInputElement&) {
|
||||
void AutofillAgent::TextFieldDidEndEditing(const blink::WebInputElement&) {
|
||||
HidePopup();
|
||||
}
|
||||
|
||||
|
@ -125,13 +123,10 @@ void AutofillAgent::DataListOptionsChanged(
|
|||
}
|
||||
|
||||
AutofillAgent::ShowSuggestionsOptions::ShowSuggestionsOptions()
|
||||
: autofill_on_empty_values(false),
|
||||
requires_caret_at_end(false) {
|
||||
}
|
||||
: autofill_on_empty_values(false), requires_caret_at_end(false) {}
|
||||
|
||||
void AutofillAgent::ShowSuggestions(
|
||||
const blink::WebFormControlElement& element,
|
||||
const ShowSuggestionsOptions& options) {
|
||||
void AutofillAgent::ShowSuggestions(const blink::WebFormControlElement& element,
|
||||
const ShowSuggestionsOptions& options) {
|
||||
if (!element.IsEnabled() || element.IsReadOnly())
|
||||
return;
|
||||
const blink::WebInputElement* input_element = ToWebInputElement(&element);
|
||||
|
@ -153,8 +148,8 @@ void AutofillAgent::ShowSuggestions(
|
|||
std::vector<base::string16> data_list_values;
|
||||
std::vector<base::string16> data_list_labels;
|
||||
if (input_element) {
|
||||
GetDataListSuggestions(
|
||||
*input_element, &data_list_values, &data_list_labels);
|
||||
GetDataListSuggestions(*input_element, &data_list_values,
|
||||
&data_list_labels);
|
||||
TrimStringVectorForIPC(&data_list_values);
|
||||
TrimStringVectorForIPC(&data_list_labels);
|
||||
}
|
||||
|
@ -175,7 +170,7 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
|
|||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message)
|
||||
IPC_MESSAGE_HANDLER(AtomAutofillFrameMsg_AcceptSuggestion,
|
||||
OnAcceptSuggestion)
|
||||
OnAcceptSuggestion)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
||||
|
@ -190,21 +185,20 @@ void AutofillAgent::HidePopup() {
|
|||
Send(new AtomAutofillFrameHostMsg_HidePopup(render_frame()->GetRoutingID()));
|
||||
}
|
||||
|
||||
void AutofillAgent::ShowPopup(
|
||||
const blink::WebFormControlElement& element,
|
||||
const std::vector<base::string16>& values,
|
||||
const std::vector<base::string16>& labels) {
|
||||
void AutofillAgent::ShowPopup(const blink::WebFormControlElement& element,
|
||||
const std::vector<base::string16>& values,
|
||||
const std::vector<base::string16>& labels) {
|
||||
gfx::RectF bounds =
|
||||
render_frame()->GetRenderView()->ElementBoundsInWindow(element);
|
||||
Send(new AtomAutofillFrameHostMsg_ShowPopup(
|
||||
render_frame()->GetRoutingID(), bounds, values, labels));
|
||||
render_frame()->GetRenderView()->ElementBoundsInWindow(element);
|
||||
Send(new AtomAutofillFrameHostMsg_ShowPopup(render_frame()->GetRoutingID(),
|
||||
bounds, values, labels));
|
||||
}
|
||||
|
||||
void AutofillAgent::OnAcceptSuggestion(base::string16 suggestion) {
|
||||
auto element = render_frame()->GetWebFrame()->GetDocument().FocusedElement();
|
||||
if (element.IsFormControlElement()) {
|
||||
ToWebInputElement(&element)->SetAutofillValue(
|
||||
blink::WebString::FromUTF16(suggestion));
|
||||
blink::WebString::FromUTF16(suggestion));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ void AtomRenderFrameObserver::DidCreateScriptContext(
|
|||
if (ShouldNotifyClient(world_id))
|
||||
renderer_client_->DidCreateScriptContext(context, render_frame_);
|
||||
|
||||
if (renderer_client_->isolated_world() && IsMainWorld(world_id)
|
||||
&& render_frame_->IsMainFrame()) {
|
||||
if (renderer_client_->isolated_world() && IsMainWorld(world_id) &&
|
||||
render_frame_->IsMainFrame()) {
|
||||
CreateIsolatedWorldContext();
|
||||
renderer_client_->SetupMainWorldOverrides(context);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ void AtomRenderFrameObserver::CreateIsolatedWorldContext() {
|
|||
|
||||
// Setup document's origin policy in isolated world
|
||||
frame->SetIsolatedWorldSecurityOrigin(
|
||||
World::ISOLATED_WORLD, frame->GetDocument().GetSecurityOrigin());
|
||||
World::ISOLATED_WORLD, frame->GetDocument().GetSecurityOrigin());
|
||||
|
||||
// Create initial script context in isolated world
|
||||
blink::WebScriptSource source("void 0");
|
||||
|
@ -196,8 +196,8 @@ void AtomRenderFrameObserver::OnBrowserMessage(bool send_to_all,
|
|||
}
|
||||
|
||||
void AtomRenderFrameObserver::EmitIPCEvent(blink::WebLocalFrame* frame,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args) {
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args) {
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@ namespace atom {
|
|||
AtomRenderViewObserver::AtomRenderViewObserver(content::RenderView* render_view)
|
||||
: content::RenderViewObserver(render_view) {}
|
||||
|
||||
AtomRenderViewObserver::~AtomRenderViewObserver() {
|
||||
}
|
||||
AtomRenderViewObserver::~AtomRenderViewObserver() {}
|
||||
|
||||
bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
|
|
|
@ -39,8 +39,7 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) {
|
|||
AtomRendererClient::AtomRendererClient()
|
||||
: node_integration_initialized_(false),
|
||||
node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)),
|
||||
atom_bindings_(new AtomBindings(uv_default_loop())) {
|
||||
}
|
||||
atom_bindings_(new AtomBindings(uv_default_loop())) {}
|
||||
|
||||
AtomRendererClient::~AtomRendererClient() {
|
||||
asar::ClearArchives();
|
||||
|
@ -79,7 +78,8 @@ void AtomRendererClient::RunScriptsAtDocumentEnd(
|
|||
}
|
||||
|
||||
void AtomRendererClient::DidCreateScriptContext(
|
||||
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
|
||||
v8::Handle<v8::Context> context,
|
||||
content::RenderFrame* render_frame) {
|
||||
// Only allow node integration for the main frame, unless it is a devtools
|
||||
// extension page.
|
||||
if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame))
|
||||
|
@ -120,7 +120,8 @@ void AtomRendererClient::DidCreateScriptContext(
|
|||
}
|
||||
|
||||
void AtomRendererClient::WillReleaseScriptContext(
|
||||
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
|
||||
v8::Handle<v8::Context> context,
|
||||
content::RenderFrame* render_frame) {
|
||||
injected_frames_.erase(render_frame);
|
||||
|
||||
node::Environment* env = node::Environment::GetCurrent(context);
|
||||
|
@ -187,8 +188,8 @@ void AtomRendererClient::SetupMainWorldOverrides(
|
|||
mate::ConvertToV8(isolate, left)->ToString(),
|
||||
v8::String::Concat(node::isolated_bundle_value.ToStringChecked(isolate),
|
||||
mate::ConvertToV8(isolate, right)->ToString())));
|
||||
auto func = v8::Handle<v8::Function>::Cast(
|
||||
script->Run(context).ToLocalChecked());
|
||||
auto func =
|
||||
v8::Handle<v8::Function>::Cast(script->Run(context).ToLocalChecked());
|
||||
|
||||
auto binding = v8::Object::New(isolate);
|
||||
api::Initialize(binding, v8::Null(isolate), context, nullptr);
|
||||
|
@ -206,7 +207,7 @@ void AtomRendererClient::SetupMainWorldOverrides(
|
|||
dict.Set("nativeWindowOpen",
|
||||
command_line->HasSwitch(switches::kNativeWindowOpen));
|
||||
|
||||
v8::Local<v8::Value> args[] = { binding };
|
||||
v8::Local<v8::Value> args[] = {binding};
|
||||
ignore_result(func->Call(context, v8::Null(isolate), 1, args));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ const std::string kIpcKey = "ipcNative";
|
|||
const std::string kModuleCacheKey = "native-module-cache";
|
||||
|
||||
bool IsDevTools(content::RenderFrame* render_frame) {
|
||||
return render_frame->GetWebFrame()->GetDocument().Url()
|
||||
.ProtocolIs("chrome-devtools");
|
||||
return render_frame->GetWebFrame()->GetDocument().Url().ProtocolIs(
|
||||
"chrome-devtools");
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
|
||||
|
@ -49,8 +49,9 @@ v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
|
|||
}
|
||||
|
||||
// adapted from node.cc
|
||||
v8::Local<v8::Value> GetBinding(v8::Isolate* isolate, v8::Local<v8::String> key,
|
||||
mate::Arguments* margs) {
|
||||
v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
|
||||
v8::Local<v8::String> key,
|
||||
mate::Arguments* margs) {
|
||||
v8::Local<v8::Object> exports;
|
||||
std::string module_key = mate::V8ToString(key);
|
||||
mate::Dictionary cache(isolate, GetModuleCache(isolate));
|
||||
|
@ -72,7 +73,7 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate, v8::Local<v8::String> key,
|
|||
DCHECK_EQ(mod->nm_register_func, nullptr);
|
||||
DCHECK_NE(mod->nm_context_register_func, nullptr);
|
||||
mod->nm_context_register_func(exports, v8::Null(isolate),
|
||||
isolate->GetCurrentContext(), mod->nm_priv);
|
||||
isolate->GetCurrentContext(), mod->nm_priv);
|
||||
cache.Set(module_key.c_str(), exports);
|
||||
return exports;
|
||||
}
|
||||
|
@ -114,13 +115,10 @@ class AtomSandboxedRenderFrameObserver : public AtomRenderFrameObserver {
|
|||
v8::HandleScope handle_scope(isolate);
|
||||
auto context = frame->MainWorldScriptContext();
|
||||
v8::Context::Scope context_scope(context);
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
mate::ConvertToV8(isolate, channel),
|
||||
v8_converter_->ToV8Value(&args, context)
|
||||
};
|
||||
v8::Local<v8::Value> argv[] = {mate::ConvertToV8(isolate, channel),
|
||||
v8_converter_->ToV8Value(&args, context)};
|
||||
renderer_client_->InvokeIpcCallback(
|
||||
context,
|
||||
"onMessage",
|
||||
context, "onMessage",
|
||||
std::vector<v8::Local<v8::Value>>(argv, argv + 2));
|
||||
}
|
||||
|
||||
|
@ -132,14 +130,12 @@ class AtomSandboxedRenderFrameObserver : public AtomRenderFrameObserver {
|
|||
|
||||
} // namespace
|
||||
|
||||
|
||||
AtomSandboxedRendererClient::AtomSandboxedRendererClient() {
|
||||
// Explicitly register electron's builtin modules.
|
||||
NodeBindings::RegisterBuiltinModules();
|
||||
}
|
||||
|
||||
AtomSandboxedRendererClient::~AtomSandboxedRendererClient() {
|
||||
}
|
||||
AtomSandboxedRendererClient::~AtomSandboxedRendererClient() {}
|
||||
|
||||
void AtomSandboxedRendererClient::RenderFrameCreated(
|
||||
content::RenderFrame* render_frame) {
|
||||
|
@ -153,16 +149,16 @@ void AtomSandboxedRendererClient::RenderViewCreated(
|
|||
}
|
||||
|
||||
void AtomSandboxedRendererClient::DidCreateScriptContext(
|
||||
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
|
||||
|
||||
v8::Handle<v8::Context> context,
|
||||
content::RenderFrame* render_frame) {
|
||||
// Only allow preload for the main frame or
|
||||
// For devtools we still want to run the preload_bundle script
|
||||
if (!render_frame->IsMainFrame() && !IsDevTools(render_frame))
|
||||
return;
|
||||
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
base::FilePath preload_script_path = command_line->GetSwitchValuePath(
|
||||
switches::kPreloadScript);
|
||||
base::FilePath preload_script_path =
|
||||
command_line->GetSwitchValuePath(switches::kPreloadScript);
|
||||
|
||||
auto isolate = context->GetIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
@ -176,23 +172,21 @@ void AtomSandboxedRendererClient::DidCreateScriptContext(
|
|||
mate::ConvertToV8(isolate, left)->ToString(),
|
||||
v8::String::Concat(node::preload_bundle_value.ToStringChecked(isolate),
|
||||
mate::ConvertToV8(isolate, right)->ToString())));
|
||||
auto func = v8::Handle<v8::Function>::Cast(
|
||||
script->Run(context).ToLocalChecked());
|
||||
auto func =
|
||||
v8::Handle<v8::Function>::Cast(script->Run(context).ToLocalChecked());
|
||||
// Create and initialize the binding object
|
||||
auto binding = v8::Object::New(isolate);
|
||||
InitializeBindings(binding, context);
|
||||
AddRenderBindings(isolate, binding);
|
||||
v8::Local<v8::Value> args[] = {
|
||||
binding,
|
||||
mate::ConvertToV8(isolate, preload_script_path.value())
|
||||
};
|
||||
binding, mate::ConvertToV8(isolate, preload_script_path.value())};
|
||||
// Execute the function with proper arguments
|
||||
ignore_result(func->Call(context, v8::Null(isolate), 2, args));
|
||||
}
|
||||
|
||||
void AtomSandboxedRendererClient::WillReleaseScriptContext(
|
||||
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
|
||||
|
||||
v8::Handle<v8::Context> context,
|
||||
content::RenderFrame* render_frame) {
|
||||
// Only allow preload for the main frame
|
||||
if (!render_frame->IsMainFrame())
|
||||
return;
|
||||
|
|
|
@ -17,8 +17,7 @@ ContentSettingsObserver::ContentSettingsObserver(
|
|||
render_frame->GetWebFrame()->SetContentSettingsClient(this);
|
||||
}
|
||||
|
||||
ContentSettingsObserver::~ContentSettingsObserver() {
|
||||
}
|
||||
ContentSettingsObserver::~ContentSettingsObserver() {}
|
||||
|
||||
bool ContentSettingsObserver::AllowDatabase(
|
||||
const blink::WebString& name,
|
||||
|
|
|
@ -22,8 +22,7 @@ static base::LazyInstance<GuestViewContainerMap>::DestructorAtExit
|
|||
} // namespace
|
||||
|
||||
GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame)
|
||||
: weak_ptr_factory_(this) {
|
||||
}
|
||||
: weak_ptr_factory_(this) {}
|
||||
|
||||
GuestViewContainer::~GuestViewContainer() {
|
||||
if (element_instance_id_ > 0)
|
||||
|
|
|
@ -13,11 +13,9 @@ PreferencesManager::PreferencesManager() {
|
|||
content::RenderThread::Get()->AddObserver(this);
|
||||
}
|
||||
|
||||
PreferencesManager::~PreferencesManager() {
|
||||
}
|
||||
PreferencesManager::~PreferencesManager() {}
|
||||
|
||||
bool PreferencesManager::OnControlMessageReceived(
|
||||
const IPC::Message& message) {
|
||||
bool PreferencesManager::OnControlMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(PreferencesManager, message)
|
||||
IPC_MESSAGE_HANDLER(AtomMsg_UpdatePreferences, OnUpdatePreferences)
|
||||
|
|
|
@ -51,7 +51,8 @@ namespace atom {
|
|||
namespace {
|
||||
|
||||
v8::Local<v8::Value> GetRenderProcessPreferences(
|
||||
const PreferencesManager* preferences_manager, v8::Isolate* isolate) {
|
||||
const PreferencesManager* preferences_manager,
|
||||
v8::Isolate* isolate) {
|
||||
if (preferences_manager->preferences())
|
||||
return mate::ConvertToV8(isolate, *preferences_manager->preferences());
|
||||
else
|
||||
|
@ -61,8 +62,8 @@ v8::Local<v8::Value> GetRenderProcessPreferences(
|
|||
std::vector<std::string> ParseSchemesCLISwitch(const char* switch_name) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
std::string custom_schemes = command_line->GetSwitchValueASCII(switch_name);
|
||||
return base::SplitString(
|
||||
custom_schemes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
return base::SplitString(custom_schemes, ",", base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -73,12 +74,11 @@ RendererClientBase::RendererClientBase() {
|
|||
ParseSchemesCLISwitch(switches::kStandardSchemes);
|
||||
for (const std::string& scheme : standard_schemes_list)
|
||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
||||
isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kContextIsolation);
|
||||
isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kContextIsolation);
|
||||
}
|
||||
|
||||
RendererClientBase::~RendererClientBase() {
|
||||
}
|
||||
RendererClientBase::~RendererClientBase() {}
|
||||
|
||||
void RendererClientBase::AddRenderBindings(
|
||||
v8::Isolate* isolate,
|
||||
|
@ -137,7 +137,7 @@ void RendererClientBase::RenderThreadStarted() {
|
|||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
bool scroll_bounce = command_line->HasSwitch(switches::kScrollBounce);
|
||||
base::ScopedCFTypeRef<CFStringRef> rubber_banding_key(
|
||||
base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding"));
|
||||
base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding"));
|
||||
CFPreferencesSetAppValue(rubber_banding_key,
|
||||
scroll_bounce ? kCFBooleanTrue : kCFBooleanFalse,
|
||||
kCFPreferencesCurrentApplication);
|
||||
|
@ -225,7 +225,8 @@ void RendererClientBase::AddSupportedKeySystems(
|
|||
}
|
||||
|
||||
v8::Local<v8::Context> RendererClientBase::GetContext(
|
||||
blink::WebLocalFrame* frame, v8::Isolate* isolate) {
|
||||
blink::WebLocalFrame* frame,
|
||||
v8::Isolate* isolate) {
|
||||
if (isolated_world())
|
||||
return frame->WorldScriptContext(isolate, World::ISOLATED_WORLD);
|
||||
else
|
||||
|
|
|
@ -17,8 +17,9 @@ namespace atom {
|
|||
|
||||
namespace {
|
||||
|
||||
static base::LazyInstance<base::ThreadLocalPointer<WebWorkerObserver>>::
|
||||
DestructorAtExit lazy_tls = LAZY_INSTANCE_INITIALIZER;
|
||||
static base::LazyInstance<
|
||||
base::ThreadLocalPointer<WebWorkerObserver>>::DestructorAtExit lazy_tls =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue