feat: Upgrade to Chromium 71.0.3578.98 (#15966)
This commit is contained in:
parent
92ddfd0d4c
commit
52fe92d02e
204 changed files with 2291 additions and 1760 deletions
|
@ -231,7 +231,7 @@ void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) {
|
|||
return;
|
||||
|
||||
if (web_contents()->NeedToFireBeforeUnload())
|
||||
web_contents()->DispatchBeforeUnload();
|
||||
web_contents()->DispatchBeforeUnload(false /* auto_cancel */);
|
||||
else
|
||||
web_contents()->Close();
|
||||
}
|
||||
|
|
|
@ -71,20 +71,34 @@ void StopRecording(const base::FilePath& path,
|
|||
GetTraceDataEndpoint(path, callback));
|
||||
}
|
||||
|
||||
bool GetCategories(
|
||||
const base::RepeatingCallback<void(const std::set<std::string>&)>&
|
||||
callback) {
|
||||
return TracingController::GetInstance()->GetCategories(
|
||||
base::BindOnce(callback));
|
||||
}
|
||||
|
||||
bool StartTracing(const base::trace_event::TraceConfig& trace_config,
|
||||
const base::RepeatingCallback<void()>& callback) {
|
||||
return TracingController::GetInstance()->StartTracing(
|
||||
trace_config, base::BindOnce(callback));
|
||||
}
|
||||
|
||||
bool GetTraceBufferUsage(
|
||||
const base::RepeatingCallback<void(float, size_t)>& callback) {
|
||||
return TracingController::GetInstance()->GetTraceBufferUsage(
|
||||
base::BindOnce(callback));
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
auto controller = base::Unretained(TracingController::GetInstance());
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("getCategories",
|
||||
base::Bind(&TracingController::GetCategories, controller));
|
||||
dict.SetMethod("startRecording",
|
||||
base::Bind(&TracingController::StartTracing, controller));
|
||||
dict.SetMethod("getCategories", &GetCategories);
|
||||
dict.SetMethod("startRecording", &StartTracing);
|
||||
dict.SetMethod("stopRecording", &StopRecording);
|
||||
dict.SetMethod(
|
||||
"getTraceBufferUsage",
|
||||
base::Bind(&TracingController::GetTraceBufferUsage, controller));
|
||||
dict.SetMethod("getTraceBufferUsage", &GetTraceBufferUsage);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -12,9 +12,11 @@
|
|||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
|
@ -136,7 +138,7 @@ inline net::CookieStore* GetCookieStore(
|
|||
|
||||
// Run |callback| on UI thread.
|
||||
void RunCallbackInUI(const base::Closure& callback) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, callback);
|
||||
}
|
||||
|
||||
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
|
||||
|
@ -270,8 +272,8 @@ void Cookies::Get(const base::DictionaryValue& filter,
|
|||
auto copy = base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(filter.Clone()));
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(GetCookiesOnIO, base::RetainedRef(getter), std::move(copy),
|
||||
callback));
|
||||
}
|
||||
|
@ -280,8 +282,8 @@ void Cookies::Remove(const GURL& url,
|
|||
const std::string& name,
|
||||
const base::Closure& callback) {
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(RemoveCookieOnIOThread, base::RetainedRef(getter), url,
|
||||
name, callback));
|
||||
}
|
||||
|
@ -291,18 +293,17 @@ void Cookies::Set(const base::DictionaryValue& details,
|
|||
auto copy = base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(details.Clone()));
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(SetCookieOnIO, base::RetainedRef(getter), std::move(copy),
|
||||
callback));
|
||||
}
|
||||
|
||||
void Cookies::FlushStore(const base::Closure& callback) {
|
||||
auto* getter = browser_context_->GetRequestContext();
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::BindOnce(FlushCookieStoreOnIOThread, base::RetainedRef(getter),
|
||||
callback));
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(FlushCookieStoreOnIOThread,
|
||||
base::RetainedRef(getter), callback));
|
||||
}
|
||||
|
||||
void Cookies::OnCookieChanged(const CookieDetails* details) {
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "base/mac/scoped_sending_event.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
||||
|
@ -43,7 +45,7 @@ void MenuMac::PopupAt(TopLevelWindow* window,
|
|||
auto popup = base::Bind(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
|
||||
native_window->GetWeakPtr(), window->weak_map_id(), x,
|
||||
y, positioning_item, callback);
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, popup);
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, popup);
|
||||
}
|
||||
|
||||
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/net/system_network_context_manager.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "base/command_line.h"
|
||||
|
@ -27,7 +28,8 @@ NetLog::NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
|||
: browser_context_(browser_context) {
|
||||
Init(isolate);
|
||||
|
||||
net_log_writer_ = g_browser_process->net_log()->net_export_file_writer();
|
||||
net_log_writer_ = g_browser_process->system_network_context_manager()
|
||||
->GetNetExportFileWriter();
|
||||
net_log_writer_->AddObserver(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,8 @@ void Protocol::UnregisterProtocol(const std::string& scheme,
|
|||
args->GetNext(&callback);
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&Protocol::UnregisterProtocolInIO,
|
||||
base::RetainedRef(getter), scheme),
|
||||
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
|
||||
|
@ -107,8 +107,8 @@ void Protocol::IsProtocolHandled(const std::string& scheme,
|
|||
const BooleanCallback& callback) {
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::Bind(&Protocol::IsProtocolHandledInIO, base::RetainedRef(getter),
|
||||
scheme),
|
||||
callback);
|
||||
|
@ -127,8 +127,8 @@ void Protocol::UninterceptProtocol(const std::string& scheme,
|
|||
args->GetNext(&callback);
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&Protocol::UninterceptProtocolInIO,
|
||||
base::RetainedRef(getter), scheme),
|
||||
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "atom/browser/net/atom_url_request_job_factory.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
@ -104,8 +106,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
|||
args->GetNext(&callback);
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&Protocol::RegisterProtocolInIO<RequestJob>,
|
||||
base::RetainedRef(getter), isolate(), scheme, handler),
|
||||
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
|
||||
|
@ -149,8 +151,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
|||
args->GetNext(&callback);
|
||||
auto* getter = static_cast<URLRequestContextGetter*>(
|
||||
browser_context_->GetRequestContext());
|
||||
content::BrowserThread::PostTaskAndReplyWithResult(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&Protocol::InterceptProtocolInIO<RequestJob>,
|
||||
base::RetainedRef(getter), isolate(), scheme, handler),
|
||||
base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback));
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "base/guid.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/download/public/common/download_danger_type.h"
|
||||
|
@ -39,6 +40,7 @@
|
|||
#include "components/prefs/value_map_pref_store.h"
|
||||
#include "components/proxy_config/proxy_config_dictionary.h"
|
||||
#include "components/proxy_config/proxy_config_pref_names.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_item_utils.h"
|
||||
#include "content/public/browser/download_manager_delegate.h"
|
||||
|
@ -211,12 +213,12 @@ std::map<uint32_t, v8::Global<v8::Object>> g_sessions;
|
|||
|
||||
// Runs the callback in UI thread.
|
||||
void RunCallbackInUI(const base::Callback<void()>& callback) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, callback);
|
||||
}
|
||||
template <typename... T>
|
||||
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::BindOnce(callback, result...));
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(callback, result...));
|
||||
}
|
||||
|
||||
// Callback of HttpCache::GetBackend.
|
||||
|
@ -421,8 +423,8 @@ void Session::ResolveProxy(
|
|||
|
||||
template <Session::CacheAction action>
|
||||
void Session::DoCacheAction(const net::CompletionCallback& callback) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&DoCacheActionInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
action, callback));
|
||||
|
@ -533,8 +535,8 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
|||
return;
|
||||
}
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&SetCertVerifyProcInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
base::Bind(&WrapVerifyProc, proc)));
|
||||
|
@ -568,8 +570,8 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
|
|||
base::Closure callback;
|
||||
args->GetNext(&callback);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&ClearHostResolverCacheInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
callback));
|
||||
|
@ -584,16 +586,16 @@ void Session::ClearAuthCache(mate::Arguments* args) {
|
|||
base::Closure callback;
|
||||
args->GetNext(&callback);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&ClearAuthCacheInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
options, callback));
|
||||
}
|
||||
|
||||
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&AllowNTLMCredentialsForDomainsInIO,
|
||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||
domains));
|
||||
|
@ -623,8 +625,8 @@ void Session::GetBlobData(const std::string& uuid,
|
|||
return;
|
||||
|
||||
AtomBlobReader* blob_reader = browser_context()->GetBlobReader();
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&AtomBlobReader::StartReading,
|
||||
base::Unretained(blob_reader), uuid, callback));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "atom/browser/mac/dict_util.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "base/mac/sdk_forward_declarations.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
|
@ -230,8 +232,8 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
|||
|
||||
template <typename... Args>
|
||||
void EmitEventSoon(base::StringPiece eventName) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(base::IgnoreResult(&TopLevelWindow::Emit<Args...>),
|
||||
weak_factory_.GetWeakPtr(), eventName));
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "content/browser/frame_host/render_frame_host_manager.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/common/widget_messages.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/download_request_utils.h"
|
||||
#include "content/public/browser/favicon_status.h"
|
||||
|
@ -80,8 +80,8 @@
|
|||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
|
||||
#include "third_party/blink/public/platform/web_input_event.h"
|
||||
#include "third_party/blink/public/web/web_find_options.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/base_event_utils.h"
|
||||
|
||||
|
@ -768,7 +768,8 @@ void WebContents::OnAudioStateChanged(bool audible) {
|
|||
Emit("-audio-state-changed", audible);
|
||||
}
|
||||
|
||||
void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
||||
void WebContents::BeforeUnloadFired(bool proceed,
|
||||
const base::TimeTicks& proceed_time) {
|
||||
// Do nothing, we override this method just to avoid compilation error since
|
||||
// there are two virtual functions named BeforeUnloadFired.
|
||||
}
|
||||
|
@ -1052,7 +1053,7 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
|||
bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
|
||||
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
|
||||
IPC_MESSAGE_HANDLER_CODE(WidgetHostMsg_SetCursor, OnCursorChange,
|
||||
handled = false)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
@ -1372,8 +1373,8 @@ void WebContents::EnableDeviceEmulation(
|
|||
frame_host ? frame_host->GetView()->GetRenderWidgetHost() : nullptr;
|
||||
if (!widget_host)
|
||||
return;
|
||||
widget_host->Send(
|
||||
new ViewMsg_EnableDeviceEmulation(widget_host->GetRoutingID(), params));
|
||||
widget_host->Send(new WidgetMsg_EnableDeviceEmulation(
|
||||
widget_host->GetRoutingID(), params));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1388,7 +1389,7 @@ void WebContents::DisableDeviceEmulation() {
|
|||
if (!widget_host)
|
||||
return;
|
||||
widget_host->Send(
|
||||
new ViewMsg_DisableDeviceEmulation(widget_host->GetRoutingID()));
|
||||
new WidgetMsg_DisableDeviceEmulation(widget_host->GetRoutingID()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1597,17 +1598,22 @@ void WebContents::ReplaceMisspelling(const base::string16& word) {
|
|||
}
|
||||
|
||||
uint32_t WebContents::FindInPage(mate::Arguments* args) {
|
||||
uint32_t request_id = GetNextRequestId();
|
||||
base::string16 search_text;
|
||||
blink::WebFindOptions options;
|
||||
if (!args->GetNext(&search_text) || search_text.empty()) {
|
||||
args->ThrowError("Must provide a non-empty search content");
|
||||
return 0;
|
||||
}
|
||||
|
||||
args->GetNext(&options);
|
||||
uint32_t request_id = GetNextRequestId();
|
||||
mate::Dictionary dict;
|
||||
auto options = blink::mojom::FindOptions::New();
|
||||
if (args->GetNext(&dict)) {
|
||||
dict.Get("forward", &options->forward);
|
||||
dict.Get("matchCase", &options->match_case);
|
||||
dict.Get("findNext", &options->find_next);
|
||||
}
|
||||
|
||||
web_contents()->Find(request_id, search_text, options);
|
||||
web_contents()->Find(request_id, search_text, std::move(options));
|
||||
return request_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -406,7 +406,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void OnAudioStateChanged(bool audible) override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||
void BeforeUnloadFired(bool proceed,
|
||||
const base::TimeTicks& proceed_time) override;
|
||||
void RenderViewCreated(content::RenderViewHost*) override;
|
||||
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
||||
content::RenderViewHost* new_host) override;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
|
@ -29,7 +31,7 @@ struct Converter<URLPattern> {
|
|||
if (!ConvertFromV8(isolate, val, &pattern))
|
||||
return false;
|
||||
*out = URLPattern(URLPattern::SCHEME_ALL);
|
||||
return out->Parse(pattern) == URLPattern::PARSE_SUCCESS;
|
||||
return out->Parse(pattern) == URLPattern::ParseResult::kSuccess;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,8 +99,8 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
|
|||
browser_context_->GetRequestContext());
|
||||
if (!url_request_context_getter)
|
||||
return;
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&CallNetworkDelegateMethod<Method, Event, Listener>,
|
||||
base::RetainedRef(url_request_context_getter), method,
|
||||
type, std::move(patterns), std::move(listener)));
|
||||
|
|
|
@ -52,7 +52,7 @@ void FrameSubscriber::AttachToHost(content::RenderWidgetHost* host) {
|
|||
video_capturer_->SetAutoThrottlingEnabled(false);
|
||||
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
|
||||
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB,
|
||||
media::COLOR_SPACE_UNSPECIFIED);
|
||||
gfx::ColorSpace::CreateREC709());
|
||||
video_capturer_->SetMinCapturePeriod(base::TimeDelta::FromSeconds(1) /
|
||||
kMaxFrameRate);
|
||||
video_capturer_->Start(this);
|
||||
|
|
|
@ -107,6 +107,18 @@ void GPUInfoEnumerator::EndOverlayCapability() {
|
|||
value_stack.pop();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::BeginDx12VulkanVersionInfo() {
|
||||
value_stack.push(std::move(current));
|
||||
current = std::make_unique<base::DictionaryValue>();
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::EndDx12VulkanVersionInfo() {
|
||||
auto& top_value = value_stack.top();
|
||||
top_value->SetDictionary(kDx12VulkanVersionInfoKey, std::move(current));
|
||||
current = std::move(top_value);
|
||||
value_stack.pop();
|
||||
}
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> GPUInfoEnumerator::GetDictionary() {
|
||||
return std::move(current);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ class GPUInfoEnumerator final : public gpu::GPUInfo::Enumerator {
|
|||
"videoEncodeAcceleratorSupportedProfile";
|
||||
const char* kAuxAttributesKey = "auxAttributes";
|
||||
const char* kOverlayCapabilityKey = "overlayCapability";
|
||||
const char* kDx12VulkanVersionInfoKey = "dx12VulkanVersionInfo";
|
||||
|
||||
public:
|
||||
GPUInfoEnumerator();
|
||||
|
@ -44,6 +45,8 @@ class GPUInfoEnumerator final : public gpu::GPUInfo::Enumerator {
|
|||
void EndAuxAttributes() override;
|
||||
void BeginOverlayCapability() override;
|
||||
void EndOverlayCapability() override;
|
||||
void BeginDx12VulkanVersionInfo() override;
|
||||
void EndDx12VulkanVersionInfo() override;
|
||||
std::unique_ptr<base::DictionaryValue> GetDictionary();
|
||||
|
||||
private:
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "atom/browser/net/url_request_stream_job.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
|
@ -76,23 +78,21 @@ void StreamSubscriber::OnData(mate::Arguments* args) {
|
|||
|
||||
// Pass the data to the URLJob in IO thread.
|
||||
std::vector<char> buffer(data, data + length);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&atom::URLRequestStreamJob::OnData, url_job_,
|
||||
base::Passed(&buffer)));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::Bind(&atom::URLRequestStreamJob::OnData,
|
||||
url_job_, base::Passed(&buffer)));
|
||||
}
|
||||
|
||||
void StreamSubscriber::OnEnd(mate::Arguments* args) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::Bind(&atom::URLRequestStreamJob::OnEnd, url_job_));
|
||||
}
|
||||
|
||||
void StreamSubscriber::OnError(mate::Arguments* args) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&atom::URLRequestStreamJob::OnError, url_job_,
|
||||
net::ERR_FAILED));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::Bind(&atom::URLRequestStreamJob::OnError,
|
||||
url_job_, net::ERR_FAILED));
|
||||
}
|
||||
|
||||
void StreamSubscriber::RemoveAllListeners() {
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
|
@ -60,8 +62,8 @@ void AtomBlobReader::StartReading(
|
|||
auto blob_data_handle = blob_context_->context()->GetBlobDataFromUUID(uuid);
|
||||
auto callback = base::Bind(&RunCallbackInUI, completion_callback);
|
||||
if (!blob_data_handle) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::BindOnce(callback, nullptr, 0));
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(callback, nullptr, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,8 +118,8 @@ void AtomBlobReader::BlobReadHelper::DidReadBlobData(
|
|||
|
||||
char* data = new char[size];
|
||||
memcpy(data, blob_data->data(), size);
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||
base::BindOnce(completion_callback_, data, size));
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(completion_callback_, data, size));
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,11 @@
|
|||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "components/net_log/chrome_net_log.h"
|
||||
#include "content/public/browser/browser_ppapi_host.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
|
@ -158,8 +160,8 @@ void AtomBrowserClient::SetApplicationLocale(const std::string& locale) {
|
|||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
|
||||
if (!BrowserThread::IsThreadInitialized(BrowserThread::IO) ||
|
||||
!BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
!base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&SetApplicationLocaleOnIOThread, locale))) {
|
||||
g_io_thread_application_locale.Get() = locale;
|
||||
}
|
||||
|
@ -792,8 +794,8 @@ bool AtomBrowserClient::HandleExternalProtocol(
|
|||
bool is_main_frame,
|
||||
ui::PageTransition page_transition,
|
||||
bool has_user_gesture) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(&HandleExternalProtocolInUI, url, web_contents_getter,
|
||||
has_user_gesture));
|
||||
return true;
|
||||
|
|
|
@ -74,7 +74,9 @@
|
|||
#if defined(OS_WIN)
|
||||
#include "ui/base/cursor/cursor_loader_win.h"
|
||||
#include "ui/base/l10n/l10n_util_win.h"
|
||||
#include "ui/display/win/dpi.h"
|
||||
#include "ui/gfx/platform_font_win.h"
|
||||
#include "ui/strings/grit/app_locale_settings.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
@ -102,12 +104,17 @@ void Erase(T* container, typename T::iterator iter) {
|
|||
|
||||
#if defined(OS_WIN)
|
||||
// gfx::Font callbacks
|
||||
void AdjustUIFont(LOGFONT* logfont) {
|
||||
l10n_util::AdjustUIFont(logfont);
|
||||
void AdjustUIFont(gfx::PlatformFontWin::FontAdjustment* font_adjustment) {
|
||||
l10n_util::NeedOverrideDefaultUIFont(&font_adjustment->font_family_override,
|
||||
&font_adjustment->font_scale);
|
||||
font_adjustment->font_scale *= display::win::GetAccessibilityFontScale();
|
||||
}
|
||||
|
||||
int GetMinimumFontSize() {
|
||||
return 10;
|
||||
int min_font_size;
|
||||
base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE),
|
||||
&min_font_size);
|
||||
return min_font_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -276,10 +283,6 @@ void AtomBrowserMainParts::RegisterDestructionCallback(
|
|||
destructors_.insert(destructors_.begin(), std::move(callback));
|
||||
}
|
||||
|
||||
bool AtomBrowserMainParts::ShouldContentCreateFeatureList() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int AtomBrowserMainParts::PreEarlyInitialization() {
|
||||
InitializeFeatureList();
|
||||
OverrideAppLogsPath();
|
||||
|
@ -393,8 +396,8 @@ void AtomBrowserMainParts::ToolkitInitialized() {
|
|||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont;
|
||||
gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize;
|
||||
gfx::PlatformFontWin::SetAdjustFontCallback(&AdjustUIFont);
|
||||
gfx::PlatformFontWin::SetGetMinimumFontSizeCallback(&GetMinimumFontSize);
|
||||
|
||||
wchar_t module_name[MAX_PATH] = {0};
|
||||
if (GetModuleFileName(NULL, module_name, MAX_PATH))
|
||||
|
|
|
@ -73,7 +73,6 @@ class AtomBrowserMainParts : public content::BrowserMainParts {
|
|||
|
||||
protected:
|
||||
// content::BrowserMainParts:
|
||||
bool ShouldContentCreateFeatureList() override;
|
||||
int PreEarlyInitialization() override;
|
||||
void PostEarlyInitialization() override;
|
||||
int PreCreateThreads() override;
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
@ -137,7 +139,7 @@ void ShutdownDetector::ThreadMain() {
|
|||
base::Closure task =
|
||||
base::Bind(&Browser::Quit, base::Unretained(Browser::Get()));
|
||||
|
||||
if (!BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, task)) {
|
||||
if (!base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, task)) {
|
||||
// Without a UI thread to post the exit task to, there aren't many
|
||||
// options. Raise the signal again. The default handler will pick it up
|
||||
// and cause an ungraceful exit.
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
|
@ -90,8 +92,8 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
|||
|
||||
if (mime_type == "application/pdf") {
|
||||
*origin = GURL(kPdfViewerUIOrigin);
|
||||
content::BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::Bind(&OnPdfResourceIntercepted, request->url(),
|
||||
render_process_host_id, render_frame_id,
|
||||
info->GetWebContentsGetterForRequest()));
|
||||
|
|
|
@ -110,7 +110,7 @@ void BrowserProcessImpl::PreCreateThreads(
|
|||
}
|
||||
}
|
||||
// Initialize net log file exporter.
|
||||
net_log_->net_export_file_writer()->Initialize();
|
||||
system_network_context_manager_->GetNetExportFileWriter()->Initialize();
|
||||
|
||||
// Manage global state of net and other IO thread related.
|
||||
io_thread_ = std::make_unique<IOThread>(
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/file_select_listener.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
|
@ -295,18 +296,21 @@ content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
|
|||
|
||||
void CommonWebContentsDelegate::RunFileChooser(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) {
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const blink::mojom::FileChooserParams& params) {
|
||||
if (!web_dialog_helper_)
|
||||
web_dialog_helper_.reset(new WebDialogHelper(owner_window(), offscreen_));
|
||||
web_dialog_helper_->RunFileChooser(render_frame_host, params);
|
||||
web_dialog_helper_->RunFileChooser(render_frame_host, std::move(listener),
|
||||
params);
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,
|
||||
int request_id,
|
||||
const base::FilePath& path) {
|
||||
void CommonWebContentsDelegate::EnumerateDirectory(
|
||||
content::WebContents* guest,
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const base::FilePath& path) {
|
||||
if (!web_dialog_helper_)
|
||||
web_dialog_helper_.reset(new WebDialogHelper(owner_window(), offscreen_));
|
||||
web_dialog_helper_->EnumerateDirectory(guest, request_id, path);
|
||||
web_dialog_helper_->EnumerateDirectory(guest, std::move(listener), path);
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::EnterFullscreenModeForTab(
|
||||
|
|
|
@ -84,9 +84,10 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
|
|||
const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions)
|
||||
override;
|
||||
void RunFileChooser(content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) override;
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const blink::mojom::FileChooserParams& params) override;
|
||||
void EnumerateDirectory(content::WebContents* web_contents,
|
||||
int request_id,
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const base::FilePath& path) override;
|
||||
void EnterFullscreenModeForTab(
|
||||
content::WebContents* source,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h"
|
||||
#include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace atom {
|
|||
|
||||
PowerObserverLinux::PowerObserverLinux()
|
||||
: lock_owner_name_(get_executable_basename()), weak_ptr_factory_(this) {
|
||||
auto* bus = bluez::DBusThreadManagerLinux::Get()->GetSystemBus();
|
||||
auto* bus = bluez::BluezDBusThreadManager::Get()->GetSystemBus();
|
||||
if (!bus) {
|
||||
LOG(WARNING) << "Failed to get system bus connection";
|
||||
return;
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "net/base/auth.h"
|
||||
|
@ -37,8 +39,8 @@ LoginHandler::LoginHandler(
|
|||
web_contents_getter_ =
|
||||
resource_request_info->GetWebContentsGetterForRequest();
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(&Browser::RequestLogin, base::Unretained(Browser::Get()),
|
||||
base::RetainedRef(this), std::move(request_details)));
|
||||
}
|
||||
|
@ -49,8 +51,8 @@ void LoginHandler::Login(const base::string16& username,
|
|||
const base::string16& password) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&LoginHandler::DoLogin, weak_factory_.GetWeakPtr(),
|
||||
username, password));
|
||||
}
|
||||
|
@ -58,8 +60,8 @@ void LoginHandler::Login(const base::string16& username,
|
|||
void LoginHandler::CancelAuth() {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&LoginHandler::DoCancelAuth, weak_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
|
|
|
@ -82,13 +82,6 @@ typedef NS_ENUM(NSInteger, AVAuthorizationStatusMac) {
|
|||
NSColor* unemphasizedSelectedTextColor API_AVAILABLE(macosx(10.14));
|
||||
@end
|
||||
|
||||
extern "C" {
|
||||
#if !defined(MAC_OS_X_VERSION_10_14) || \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
|
||||
BASE_EXPORT extern NSString* const NSAppearanceNameDarkAqua;
|
||||
#endif // MAC_OS_X_VERSION_10_14
|
||||
} // extern "C"
|
||||
|
||||
@interface AtomApplication : NSApplication <CrAppProtocol,
|
||||
CrAppControlProtocol,
|
||||
NSUserActivityDelegate> {
|
||||
|
|
|
@ -11,11 +11,6 @@
|
|||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "content/public/browser/browser_accessibility_state.h"
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_14) || \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
|
||||
NSString* const NSAppearanceNameDarkAqua = @"NSAppearanceNameDarkAqua";
|
||||
#endif // MAC_OS_X_VERSION_10_14
|
||||
|
||||
namespace {
|
||||
|
||||
inline void dispatch_sync_main(dispatch_block_t block) {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "base/bind.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
#import <CommonCrypto/CommonCrypto.h>
|
||||
|
@ -117,8 +119,8 @@
|
|||
*/
|
||||
- (void)runCallback:(bool)isProductValid {
|
||||
if (callback_) {
|
||||
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(callback_, isProductValid));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(callback_, isProductValid));
|
||||
}
|
||||
// Release this delegate.
|
||||
[self release];
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "base/bind.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
#import <CommonCrypto/CommonCrypto.h>
|
||||
|
@ -71,8 +73,8 @@ using InAppTransactionCallback = base::RepeatingCallback<void(
|
|||
}
|
||||
|
||||
// Send the callback to the browser thread.
|
||||
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(callback_, converted));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(callback_, converted));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "base/bind.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
#import <StoreKit/StoreKit.h>
|
||||
|
@ -78,8 +80,8 @@
|
|||
}
|
||||
|
||||
// Send the callback to the browser thread.
|
||||
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(callback_, converted));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(callback_, converted));
|
||||
|
||||
[self release];
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include "ui/gfx/skia_util.h"
|
||||
#include "ui/gl/gpu_switching_manager.h"
|
||||
#include "ui/views/background.h"
|
||||
#include "ui/views/cocoa/bridged_native_widget.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
#include "ui/views_bridge_mac/bridged_native_widget_impl.h"
|
||||
|
||||
// This view always takes the size of its superview. It is intended to be used
|
||||
// as a NSWindow's contentView. It is needed because NSWindow's implementation
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "base/containers/linked_list.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/cert/cert_verify_result.h"
|
||||
|
@ -96,8 +98,8 @@ class CertVerifierRequest : public AtomCertVerifier::Request {
|
|||
request->certificate = params_.certificate();
|
||||
auto response_callback = base::Bind(&CertVerifierRequest::OnResponseInUI,
|
||||
weak_ptr_factory_.GetWeakPtr());
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(&CertVerifierRequest::OnVerifyRequestInUI,
|
||||
cert_verifier_->verify_proc(), std::move(request),
|
||||
response_callback));
|
||||
|
@ -112,8 +114,8 @@ class CertVerifierRequest : public AtomCertVerifier::Request {
|
|||
|
||||
static void OnResponseInUI(base::WeakPtr<CertVerifierRequest> self,
|
||||
int result) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&CertVerifierRequest::NotifyResponseInIO, self, result));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "base/command_line.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/resource_request_info.h"
|
||||
|
@ -397,14 +399,16 @@ net::NetworkDelegate::AuthRequiredResponse AtomNetworkDelegate::OnAuthRequired(
|
|||
}
|
||||
|
||||
bool AtomNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
|
||||
const net::CookieList& cookie_list) {
|
||||
const net::CookieList& cookie_list,
|
||||
bool allowed_from_caller) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AtomNetworkDelegate::OnCanSetCookie(
|
||||
const net::URLRequest& request,
|
||||
const net::CanonicalCookie& cookie_line,
|
||||
net::CookieOptions* options) {
|
||||
net::CookieOptions* options,
|
||||
bool allowed_from_caller) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -487,8 +491,8 @@ int AtomNetworkDelegate::HandleResponseEvent(
|
|||
ResponseCallback response =
|
||||
base::Bind(&AtomNetworkDelegate::OnListenerResultInUI<Out>,
|
||||
base::Unretained(this), request->identifier(), out);
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(RunResponseListener, info.listener, std::move(details),
|
||||
render_process_id, render_frame_id, response));
|
||||
return net::ERR_IO_PENDING;
|
||||
|
@ -509,8 +513,8 @@ void AtomNetworkDelegate::HandleSimpleEvent(SimpleEvent type,
|
|||
content::ResourceRequestInfo::GetRenderFrameForRequest(
|
||||
request, &render_process_id, &render_frame_id);
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(RunSimpleListener, info.listener, std::move(details),
|
||||
render_process_id, render_frame_id));
|
||||
}
|
||||
|
@ -538,8 +542,8 @@ void AtomNetworkDelegate::OnListenerResultInUI(
|
|||
const base::DictionaryValue& response) {
|
||||
auto copy = base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(response.Clone()));
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&AtomNetworkDelegate::OnListenerResultInIO<T>,
|
||||
base::Unretained(this), id, out, std::move(copy)));
|
||||
}
|
||||
|
|
|
@ -118,10 +118,12 @@ class AtomNetworkDelegate : public net::NetworkDelegate {
|
|||
AuthCallback callback,
|
||||
net::AuthCredentials* credentials) override;
|
||||
bool OnCanGetCookies(const net::URLRequest& request,
|
||||
const net::CookieList& cookie_list) override;
|
||||
const net::CookieList& cookie_list,
|
||||
bool allowed_from_caller) override;
|
||||
bool OnCanSetCookie(const net::URLRequest& request,
|
||||
const net::CanonicalCookie& cookie_line,
|
||||
net::CookieOptions* options) override;
|
||||
net::CookieOptions* options,
|
||||
bool allowed_from_caller) override;
|
||||
bool OnCanAccessFile(const net::URLRequest& request,
|
||||
const base::FilePath& original_path,
|
||||
const base::FilePath& absolute_path) const override;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/net/atom_url_request_job_factory.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/elements_upload_data_stream.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
|
@ -77,8 +79,8 @@ scoped_refptr<AtomURLRequest> AtomURLRequest::Create(
|
|||
browser_context->GetRequestContext());
|
||||
DCHECK(request_context_getter);
|
||||
scoped_refptr<AtomURLRequest> atom_url_request(new AtomURLRequest(delegate));
|
||||
if (content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
if (base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoInitialize, atom_url_request,
|
||||
request_context_getter, method, url,
|
||||
redirect_policy))) {
|
||||
|
@ -90,9 +92,8 @@ scoped_refptr<AtomURLRequest> AtomURLRequest::Create(
|
|||
void AtomURLRequest::Terminate() {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
delegate_ = nullptr;
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::BindOnce(&AtomURLRequest::DoTerminate, this));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoTerminate, this));
|
||||
}
|
||||
|
||||
void AtomURLRequest::DoInitialize(
|
||||
|
@ -140,8 +141,8 @@ void AtomURLRequest::DoTerminate() {
|
|||
bool AtomURLRequest::Write(scoped_refptr<const net::IOBufferWithSize> buffer,
|
||||
bool is_last) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
return content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
return base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoWriteBuffer, this, buffer, is_last));
|
||||
}
|
||||
|
||||
|
@ -156,30 +157,29 @@ void AtomURLRequest::SetChunkedUpload(bool is_chunked_upload) {
|
|||
|
||||
void AtomURLRequest::Cancel() {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::BindOnce(&AtomURLRequest::DoCancel, this));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoCancel, this));
|
||||
}
|
||||
|
||||
void AtomURLRequest::FollowRedirect() {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoFollowRedirect, this));
|
||||
}
|
||||
|
||||
void AtomURLRequest::SetExtraHeader(const std::string& name,
|
||||
const std::string& value) const {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoSetExtraHeader, this, name, value));
|
||||
}
|
||||
|
||||
void AtomURLRequest::RemoveExtraHeader(const std::string& name) const {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoRemoveExtraHeader, this, name));
|
||||
}
|
||||
|
||||
|
@ -188,20 +188,20 @@ void AtomURLRequest::PassLoginInformation(
|
|||
const base::string16& password) const {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
if (username.empty() || password.empty()) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoCancelAuth, this));
|
||||
} else {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoSetAuth, this, username, password));
|
||||
}
|
||||
}
|
||||
|
||||
void AtomURLRequest::SetLoadFlags(int flags) const {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&AtomURLRequest::DoSetLoadFlags, this, flags));
|
||||
}
|
||||
|
||||
|
@ -309,8 +309,8 @@ void AtomURLRequest::DoCancelAuth() const {
|
|||
void AtomURLRequest::DoCancelWithError(const std::string& error,
|
||||
bool isRequestError) {
|
||||
DoCancel();
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&AtomURLRequest::InformDelegateErrorOccured, this, error,
|
||||
isRequestError));
|
||||
}
|
||||
|
@ -338,8 +338,8 @@ void AtomURLRequest::OnReceivedRedirect(net::URLRequest* request,
|
|||
*defer_redirect = true;
|
||||
scoped_refptr<net::HttpResponseHeaders> response_headers =
|
||||
request->response_headers();
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&AtomURLRequest::InformDelegateReceivedRedirect, this,
|
||||
info.status_code, info.new_method, info.new_url,
|
||||
response_headers));
|
||||
|
@ -350,8 +350,8 @@ void AtomURLRequest::OnAuthRequired(net::URLRequest* request,
|
|||
net::AuthChallengeInfo* auth_info) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&AtomURLRequest::InformDelegateAuthenticationRequired,
|
||||
this, scoped_refptr<net::AuthChallengeInfo>(auth_info)));
|
||||
}
|
||||
|
@ -369,8 +369,8 @@ void AtomURLRequest::OnResponseStarted(net::URLRequest* request,
|
|||
const auto& status = request_->status();
|
||||
if (status.is_success()) {
|
||||
// Success or pending trigger a Read.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&AtomURLRequest::InformDelegateResponseStarted, this,
|
||||
response_headers));
|
||||
ReadResponse();
|
||||
|
@ -428,8 +428,8 @@ void AtomURLRequest::OnReadCompleted(net::URLRequest* request, int bytes_read) {
|
|||
if (response_error) {
|
||||
DoCancelWithError(net::ErrorToString(status.ToNetError()), false);
|
||||
} else if (data_ended) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&AtomURLRequest::InformDelegateResponseCompleted, this));
|
||||
DoTerminate();
|
||||
} else if (data_transfer_error) {
|
||||
|
@ -451,8 +451,8 @@ bool AtomURLRequest::CopyAndPostBuffer(int bytes_read) {
|
|||
auto buffer_copy = WrapRefCounted(new net::IOBufferWithSize(bytes_read));
|
||||
memcpy(buffer_copy->data(), response_read_buffer_->data(), bytes_read);
|
||||
|
||||
return content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
return base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&AtomURLRequest::InformDelegateResponseData, this,
|
||||
buffer_copy));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "base/lazy_instance.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h"
|
||||
#include "components/net_log/net_export_file_writer.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/network_service_instance.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
|
@ -147,6 +148,14 @@ SystemNetworkContextManager::GetSharedURLLoaderFactory() {
|
|||
return shared_url_loader_factory_;
|
||||
}
|
||||
|
||||
net_log::NetExportFileWriter*
|
||||
SystemNetworkContextManager::GetNetExportFileWriter() {
|
||||
if (!net_export_file_writer_) {
|
||||
net_export_file_writer_ = std::make_unique<net_log::NetExportFileWriter>();
|
||||
}
|
||||
return net_export_file_writer_.get();
|
||||
}
|
||||
|
||||
// static
|
||||
network::mojom::NetworkContextParamsPtr
|
||||
SystemNetworkContextManager::CreateDefaultNetworkContextParams() {
|
||||
|
|
|
@ -23,6 +23,10 @@ class URLLoaderFactory;
|
|||
class SharedURLLoaderFactory;
|
||||
} // namespace network
|
||||
|
||||
namespace net_log {
|
||||
class NetExportFileWriter;
|
||||
}
|
||||
|
||||
// Responsible for creating and managing access to the system NetworkContext.
|
||||
// Lives on the UI thread. The NetworkContext this owns is intended for requests
|
||||
// not associated with a session. It stores no data on disk, and has no HTTP
|
||||
|
@ -71,6 +75,9 @@ class SystemNetworkContextManager {
|
|||
// that is backed by the SystemNetworkContext.
|
||||
scoped_refptr<network::SharedURLLoaderFactory> GetSharedURLLoaderFactory();
|
||||
|
||||
// Returns a shared global NetExportFileWriter instance.
|
||||
net_log::NetExportFileWriter* GetNetExportFileWriter();
|
||||
|
||||
// Called when content creates a NetworkService. Creates the
|
||||
// SystemNetworkContext, if the network service is enabled.
|
||||
void OnNetworkServiceCreated(network::mojom::NetworkService* network_service);
|
||||
|
@ -98,6 +105,9 @@ class SystemNetworkContextManager {
|
|||
scoped_refptr<URLLoaderFactoryForSystem> shared_url_loader_factory_;
|
||||
network::mojom::URLLoaderFactoryPtr url_loader_factory_;
|
||||
|
||||
// Initialized on first access.
|
||||
std::unique_ptr<net_log::NetExportFileWriter> net_export_file_writer_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SystemNetworkContextManager);
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "atom/common/native_mate_converters/v8_value_converter.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -37,8 +38,8 @@ void BeforeStartInUI(base::WeakPtr<URLRequestAsyncAsarJob> job,
|
|||
error = net::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestAsyncAsarJob::StartAsync, job,
|
||||
std::move(request_options), error));
|
||||
}
|
||||
|
@ -55,8 +56,8 @@ URLRequestAsyncAsarJob::~URLRequestAsyncAsarJob() = default;
|
|||
void URLRequestAsyncAsarJob::Start() {
|
||||
auto request_details = std::make_unique<base::DictionaryValue>();
|
||||
FillRequestDetails(request_details.get(), request());
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&JsAsker::AskForOptions, base::Unretained(isolate()),
|
||||
handler(), std::move(request_details),
|
||||
base::Bind(&BeforeStartInUI, weak_factory_.GetWeakPtr())));
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "atom/common/native_mate_converters/v8_value_converter.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/mime_util.h"
|
||||
#include "net/base/net_errors.h"
|
||||
|
@ -47,10 +49,9 @@ void BeforeStartInUI(base::WeakPtr<URLRequestBufferJob> job,
|
|||
error = net::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::BindOnce(&URLRequestBufferJob::StartAsync, job,
|
||||
std::move(request_options), error));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestBufferJob::StartAsync, job,
|
||||
std::move(request_options), error));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -66,8 +67,8 @@ URLRequestBufferJob::~URLRequestBufferJob() = default;
|
|||
void URLRequestBufferJob::Start() {
|
||||
auto request_details = std::make_unique<base::DictionaryValue>();
|
||||
FillRequestDetails(request_details.get(), request());
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&JsAsker::AskForOptions, base::Unretained(isolate()),
|
||||
handler(), std::move(request_details),
|
||||
base::Bind(&BeforeStartInUI, weak_factory_.GetWeakPtr())));
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "chrome/common/pref_names.h"
|
||||
#include "components/network_session_configurator/common/network_switches.h"
|
||||
#include "components/prefs/value_map_pref_store.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/devtools_network_transaction_factory.h"
|
||||
#include "content/public/browser/network_service_instance.h"
|
||||
|
@ -225,8 +226,8 @@ void URLRequestContextGetter::Handle::ShutdownOnUIThread() {
|
|||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
if (main_request_context_getter_.get()) {
|
||||
if (BrowserThread::IsThreadInitialized(BrowserThread::IO)) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestContextGetter::NotifyContextShuttingDown,
|
||||
base::RetainedRef(main_request_context_getter_),
|
||||
std::move(resource_context_)));
|
||||
|
@ -340,7 +341,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
|||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
URLRequestContextGetter::GetNetworkTaskRunner() const {
|
||||
return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
|
||||
return base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO});
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "base/guid.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
|
@ -87,10 +89,9 @@ void BeforeStartInUI(base::WeakPtr<URLRequestFetchJob> job,
|
|||
mate::Dictionary options;
|
||||
if (!args->GetNext(&value) ||
|
||||
!mate::ConvertFromV8(args->isolate(), value, &options)) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::BindOnce(&URLRequestFetchJob::OnError, job,
|
||||
net::ERR_NOT_IMPLEMENTED));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestFetchJob::OnError, job,
|
||||
net::ERR_NOT_IMPLEMENTED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -125,8 +126,8 @@ void BeforeStartInUI(base::WeakPtr<URLRequestFetchJob> job,
|
|||
|
||||
JsAsker::IsErrorOptions(request_options.get(), &error);
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestFetchJob::StartAsync, job,
|
||||
base::RetainedRef(url_request_context_getter),
|
||||
base::RetainedRef(custom_browser_context),
|
||||
|
@ -144,8 +145,8 @@ URLRequestFetchJob::~URLRequestFetchJob() = default;
|
|||
void URLRequestFetchJob::Start() {
|
||||
auto request_details = std::make_unique<base::DictionaryValue>();
|
||||
FillRequestDetails(request_details.get(), request());
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&JsAsker::AskForOptions, base::Unretained(isolate()),
|
||||
handler(), std::move(request_details),
|
||||
base::Bind(&BeforeStartInUI, weak_factory_.GetWeakPtr())));
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
#include "atom/common/node_includes.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/time/time.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/filter/gzip_source_stream.h"
|
||||
|
@ -32,8 +34,8 @@ void BeforeStartInUI(base::WeakPtr<URLRequestStreamJob> job,
|
|||
bool ended = false;
|
||||
if (!args->GetNext(&value) || !value->IsObject()) {
|
||||
// Invalid opts.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestStreamJob::OnError, job, net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
|
@ -65,8 +67,8 @@ void BeforeStartInUI(base::WeakPtr<URLRequestStreamJob> job,
|
|||
// "data" was explicitly passed as null or undefined, assume the user wants
|
||||
// to send an empty body.
|
||||
ended = true;
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestStreamJob::StartAsync, job, nullptr,
|
||||
base::RetainedRef(response_headers), ended, error));
|
||||
return;
|
||||
|
@ -76,8 +78,8 @@ void BeforeStartInUI(base::WeakPtr<URLRequestStreamJob> job,
|
|||
if (!data.Get("on", &value) || !value->IsFunction() ||
|
||||
!data.Get("removeListener", &value) || !value->IsFunction()) {
|
||||
// If data is passed but it is not a stream, signal an error.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestStreamJob::OnError, job, net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
|
@ -85,8 +87,8 @@ void BeforeStartInUI(base::WeakPtr<URLRequestStreamJob> job,
|
|||
auto subscriber = std::make_unique<mate::StreamSubscriber>(
|
||||
args->isolate(), data.GetHandle(), job);
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestStreamJob::StartAsync, job,
|
||||
std::move(subscriber), base::RetainedRef(response_headers),
|
||||
ended, error));
|
||||
|
@ -113,8 +115,8 @@ URLRequestStreamJob::~URLRequestStreamJob() {
|
|||
void URLRequestStreamJob::Start() {
|
||||
auto request_details = std::make_unique<base::DictionaryValue>();
|
||||
FillRequestDetails(request_details.get(), request());
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&JsAsker::AskForOptions, base::Unretained(isolate()),
|
||||
handler(), std::move(request_details),
|
||||
base::Bind(&BeforeStartInUI, weak_factory_.GetWeakPtr())));
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "atom/common/atom_constants.h"
|
||||
#include "atom/common/native_mate_converters/net_converter.h"
|
||||
#include "atom/common/native_mate_converters/v8_value_converter.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/net_errors.h"
|
||||
|
||||
|
@ -36,10 +38,9 @@ void BeforeStartInUI(base::WeakPtr<URLRequestStringJob> job,
|
|||
error = net::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO, FROM_HERE,
|
||||
base::BindOnce(&URLRequestStringJob::StartAsync, job,
|
||||
std::move(request_options), error));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&URLRequestStringJob::StartAsync, job,
|
||||
std::move(request_options), error));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -54,8 +55,8 @@ URLRequestStringJob::~URLRequestStringJob() = default;
|
|||
void URLRequestStringJob::Start() {
|
||||
auto request_details = std::make_unique<base::DictionaryValue>();
|
||||
FillRequestDetails(request_details.get(), request());
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&JsAsker::AskForOptions, base::Unretained(isolate()),
|
||||
handler(), std::move(request_details),
|
||||
base::Bind(&BeforeStartInUI, weak_factory_.GetWeakPtr())));
|
||||
|
|
|
@ -37,13 +37,13 @@ void NodeDebugger::Start() {
|
|||
#endif
|
||||
}
|
||||
|
||||
auto options = std::make_shared<node::DebugOptions>();
|
||||
node::DebugOptions options;
|
||||
std::vector<std::string> exec_args;
|
||||
std::vector<std::string> v8_args;
|
||||
std::vector<std::string> errors;
|
||||
|
||||
node::options_parser::DebugOptionsParser::instance.Parse(
|
||||
&args, &exec_args, &v8_args, options.get(),
|
||||
&args, &exec_args, &v8_args, &options,
|
||||
node::options_parser::kDisallowedInEnvironment, &errors);
|
||||
|
||||
if (!errors.empty()) {
|
||||
|
@ -54,13 +54,14 @@ void NodeDebugger::Start() {
|
|||
|
||||
// Set process._debugWaitConnect if --inspect-brk was specified to stop
|
||||
// the debugger on the first line
|
||||
if (options->wait_for_connect()) {
|
||||
if (options.wait_for_connect()) {
|
||||
mate::Dictionary process(env_->isolate(), env_->process_object());
|
||||
process.Set("_breakFirstLine", true);
|
||||
}
|
||||
|
||||
const char* path = "";
|
||||
if (inspector->Start(path, options, true /* is_main */))
|
||||
if (inspector->Start(path, options, env_->inspector_host_port(),
|
||||
true /* is_main */))
|
||||
DCHECK(env_->inspector_agent()->IsListening());
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/notification_event_dispatcher.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/notification_resources.h"
|
||||
#include "content/public/common/platform_notification_data.h"
|
||||
#include "third_party/blink/public/common/notifications/notification_resources.h"
|
||||
#include "third_party/blink/public/common/notifications/platform_notification_data.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -21,7 +21,7 @@ namespace {
|
|||
|
||||
void OnWebNotificationAllowed(base::WeakPtr<Notification> notification,
|
||||
const SkBitmap& icon,
|
||||
const content::PlatformNotificationData& data,
|
||||
const blink::PlatformNotificationData& data,
|
||||
bool audio_muted,
|
||||
bool allowed) {
|
||||
if (!notification)
|
||||
|
@ -82,8 +82,8 @@ void PlatformNotificationService::DisplayNotification(
|
|||
content::BrowserContext* browser_context,
|
||||
const std::string& notification_id,
|
||||
const GURL& origin,
|
||||
const content::PlatformNotificationData& notification_data,
|
||||
const content::NotificationResources& notification_resources) {
|
||||
const blink::PlatformNotificationData& notification_data,
|
||||
const blink::NotificationResources& notification_resources) {
|
||||
auto* presenter = browser_client_->GetNotificationPresenter();
|
||||
if (!presenter)
|
||||
return;
|
||||
|
@ -104,8 +104,8 @@ void PlatformNotificationService::DisplayPersistentNotification(
|
|||
const std::string& notification_id,
|
||||
const GURL& service_worker_scope,
|
||||
const GURL& origin,
|
||||
const content::PlatformNotificationData& notification_data,
|
||||
const content::NotificationResources& notification_resources) {}
|
||||
const blink::PlatformNotificationData& notification_data,
|
||||
const blink::NotificationResources& notification_resources) {}
|
||||
|
||||
void PlatformNotificationService::ClosePersistentNotification(
|
||||
content::BrowserContext* browser_context,
|
||||
|
|
|
@ -28,15 +28,15 @@ class PlatformNotificationService
|
|||
content::BrowserContext* browser_context,
|
||||
const std::string& notification_id,
|
||||
const GURL& origin,
|
||||
const content::PlatformNotificationData& notification_data,
|
||||
const content::NotificationResources& notification_resources) override;
|
||||
const blink::PlatformNotificationData& notification_data,
|
||||
const blink::NotificationResources& notification_resources) override;
|
||||
void DisplayPersistentNotification(
|
||||
content::BrowserContext* browser_context,
|
||||
const std::string& notification_id,
|
||||
const GURL& service_worker_scope,
|
||||
const GURL& origin,
|
||||
const content::PlatformNotificationData& notification_data,
|
||||
const content::NotificationResources& notification_resources) override;
|
||||
const blink::PlatformNotificationData& notification_data,
|
||||
const blink::NotificationResources& notification_resources) override;
|
||||
void ClosePersistentNotification(content::BrowserContext* browser_context,
|
||||
const std::string& notification_id) override;
|
||||
void CloseNotification(content::BrowserContext* browser_context,
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/win/windows_version.h"
|
||||
#include "content/public/common/platform_notification_data.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "ui/gfx/codec/png_codec.h"
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "atom/common/application_info.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
using ABI::Windows::Data::Xml::Dom::IXmlAttribute;
|
||||
|
@ -411,8 +413,8 @@ ToastEventHandler::~ToastEventHandler() {}
|
|||
IFACEMETHODIMP ToastEventHandler::Invoke(
|
||||
ABI::Windows::UI::Notifications::IToastNotification* sender,
|
||||
IInspectable* args) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(&Notification::NotificationClicked, notification_));
|
||||
if (IsDebuggingNotifications())
|
||||
LOG(INFO) << "Notification clicked";
|
||||
|
@ -423,8 +425,8 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
|
|||
IFACEMETHODIMP ToastEventHandler::Invoke(
|
||||
ABI::Windows::UI::Notifications::IToastNotification* sender,
|
||||
ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(&Notification::NotificationDismissed, notification_));
|
||||
if (IsDebuggingNotifications())
|
||||
LOG(INFO) << "Notification dismissed";
|
||||
|
@ -435,8 +437,8 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
|
|||
IFACEMETHODIMP ToastEventHandler::Invoke(
|
||||
ABI::Windows::UI::Notifications::IToastNotification* sender,
|
||||
ABI::Windows::UI::Notifications::IToastFailedEventArgs* e) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(&Notification::NotificationFailed, notification_));
|
||||
if (IsDebuggingNotifications())
|
||||
LOG(INFO) << "Notification failed";
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "base/location.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/time/time.h"
|
||||
#include "components/viz/common/features.h"
|
||||
#include "components/viz/common/frame_sinks/copy_output_request.h"
|
||||
|
@ -23,6 +24,7 @@
|
|||
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/context_factory.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
|
@ -168,8 +170,8 @@ class AtomCopyFrameGenerator {
|
|||
base::TimeDelta next_frame_in = next_frame_time_ - now;
|
||||
if (next_frame_in > frame_duration_ / 4) {
|
||||
next_frame_time_ += frame_duration_;
|
||||
content::BrowserThread::PostDelayedTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostDelayedTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&AtomCopyFrameGenerator::OnCopyFrameCaptureSuccess,
|
||||
weak_ptr_factory_.GetWeakPtr(), damage_rect, bitmap),
|
||||
next_frame_in);
|
||||
|
@ -188,8 +190,8 @@ class AtomCopyFrameGenerator {
|
|||
const bool force_frame = (++frame_retry_count_ <= kFrameRetryLimit);
|
||||
if (force_frame) {
|
||||
// Retry with the same |damage_rect|.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&AtomCopyFrameGenerator::GenerateCopyFrame,
|
||||
weak_ptr_factory_.GetWeakPtr(), damage_rect));
|
||||
}
|
||||
|
@ -222,8 +224,8 @@ class AtomBeginFrameTimer : public viz::DelayBasedTimeSourceClient {
|
|||
const base::Closure& callback)
|
||||
: callback_(callback) {
|
||||
time_source_.reset(new viz::DelayBasedTimeSource(
|
||||
content::BrowserThread::GetTaskRunnerForThread(
|
||||
content::BrowserThread::UI)
|
||||
base::CreateSingleThreadTaskRunnerWithTraits(
|
||||
{content::BrowserThread::UI})
|
||||
.get()));
|
||||
time_source_->SetTimebaseAndInterval(
|
||||
base::TimeTicks(),
|
||||
|
@ -1005,8 +1007,8 @@ void OffScreenRenderWidgetHostView::ReleaseResize() {
|
|||
hold_resize_ = false;
|
||||
if (pending_resize_) {
|
||||
pending_resize_ = false;
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(
|
||||
&OffScreenRenderWidgetHostView::SynchronizeVisualProperties,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
|
@ -1110,8 +1112,8 @@ void OffScreenRenderWidgetHostView::SendMouseWheelEvent(
|
|||
// Scrolling outside of the popup widget so destroy it.
|
||||
// Execute asynchronously to avoid deleting the widget from inside some
|
||||
// other callback.
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&OffScreenRenderWidgetHostView::CancelWidget,
|
||||
popup_host_view_->weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
|
|
@ -166,12 +166,6 @@ void OffScreenWebContentsView::RenderViewHostChanged(
|
|||
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void OffScreenWebContentsView::SetAllowOtherViews(bool allow) {}
|
||||
|
||||
bool OffScreenWebContentsView::GetAllowOtherViews() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OffScreenWebContentsView::IsEventTracking() const {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ class OffScreenWebContentsView : public content::WebContentsView,
|
|||
void SetOverscrollControllerEnabled(bool enabled) override;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void SetAllowOtherViews(bool allow) override;
|
||||
bool GetAllowOtherViews() const override;
|
||||
bool IsEventTracking() const override;
|
||||
void CloseTabAfterEventTracking() override;
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "base/memory/read_only_shared_memory_region.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "chrome/browser/printing/printer_query.h"
|
||||
|
@ -18,6 +19,7 @@
|
|||
#include "components/printing/browser/print_manager_utils.h"
|
||||
#include "components/printing/common/print_messages.h"
|
||||
#include "components/services/pdf_compositor/public/cpp/pdf_service_mojo_types.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
@ -38,24 +40,12 @@ void StopWorker(int document_cookie) {
|
|||
scoped_refptr<printing::PrinterQuery> printer_query =
|
||||
queue->PopPrinterQuery(document_cookie);
|
||||
if (printer_query.get()) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&printing::PrinterQuery::StopWorker, printer_query));
|
||||
}
|
||||
}
|
||||
|
||||
scoped_refptr<base::RefCountedMemory> GetDataFromHandle(
|
||||
base::SharedMemoryHandle handle,
|
||||
uint32_t data_size) {
|
||||
auto shared_buf = std::make_unique<base::SharedMemory>(handle, true);
|
||||
if (!shared_buf->Map(data_size)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return base::MakeRefCounted<base::RefCountedSharedMemory>(
|
||||
std::move(shared_buf), data_size);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
PrintPreviewMessageHandler::PrintPreviewMessageHandler(
|
||||
|
@ -97,7 +87,7 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
|
|||
StopWorker(params.document_cookie);
|
||||
|
||||
const PrintHostMsg_DidPrintContent_Params& content = params.content;
|
||||
if (!content.metafile_data_handle.IsValid() ||
|
||||
if (!content.metafile_data_region.IsValid() ||
|
||||
params.expected_pages_count <= 0) {
|
||||
RunPrintToPDFCallback(ids.request_id, nullptr);
|
||||
return;
|
||||
|
@ -114,7 +104,8 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
|
|||
} else {
|
||||
RunPrintToPDFCallback(
|
||||
ids.request_id,
|
||||
GetDataFromHandle(content.metafile_data_handle, content.data_size));
|
||||
base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(
|
||||
content.metafile_data_region));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,18 +77,10 @@
|
|||
|
||||
auto* inspectable_web_contents =
|
||||
inspectableWebContentsView_->inspectable_web_contents();
|
||||
auto* webContents = inspectable_web_contents->GetWebContents();
|
||||
auto* devToolsWebContents =
|
||||
inspectable_web_contents->GetDevToolsWebContents();
|
||||
auto devToolsView = devToolsWebContents->GetNativeView();
|
||||
|
||||
if (visible && devtools_docked_) {
|
||||
webContents->SetAllowOtherViews(true);
|
||||
devToolsWebContents->SetAllowOtherViews(true);
|
||||
} else if (!inspectable_web_contents->IsGuest()) {
|
||||
webContents->SetAllowOtherViews(false);
|
||||
}
|
||||
|
||||
devtools_visible_ = visible;
|
||||
if (devtools_docked_) {
|
||||
if (visible) {
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "base/logging.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
#include "ui/base/accelerators/platform_accelerator_cocoa.h"
|
||||
|
@ -124,7 +126,7 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
|
|||
isMenuOpen_ = NO;
|
||||
model_->MenuWillClose();
|
||||
if (!closeCallback.is_null()) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, closeCallback);
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, closeCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -335,7 +337,7 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
|
|||
// Post async task so that itemSelected runs before the close callback
|
||||
// deletes the controller from the map which deallocates it
|
||||
if (!closeCallback.is_null()) {
|
||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, closeCallback);
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, closeCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#define ATOM_BROWSER_UI_COCOA_ATOM_NS_WINDOW_H_
|
||||
|
||||
#include "atom/browser/ui/cocoa/event_dispatching_window.h"
|
||||
#include "ui/views/cocoa/native_widget_mac_nswindow.h"
|
||||
#include "ui/views/widget/native_widget_mac.h"
|
||||
#include "ui/views_bridge_mac/native_widget_mac_nswindow.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <Quartz/Quartz.h>
|
||||
|
||||
#include "ui/views/cocoa/views_nswindow_delegate.h"
|
||||
#include "ui/views_bridge_mac/views_nswindow_delegate.h"
|
||||
|
||||
namespace atom {
|
||||
class NativeWindowMac;
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include "atom/browser/ui/cocoa/atom_preview_item.h"
|
||||
#include "atom/browser/ui/cocoa/atom_touch_bar.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "ui/views/cocoa/bridged_native_widget.h"
|
||||
#include "ui/views/widget/native_widget_mac.h"
|
||||
#include "ui/views_bridge_mac/bridged_native_widget_impl.h"
|
||||
|
||||
@implementation AtomNSWindowDelegate
|
||||
|
||||
|
@ -21,9 +21,8 @@
|
|||
// on the fly.
|
||||
// TODO(zcbenz): Add interface in NativeWidgetMac to allow overriding creating
|
||||
// window delegate.
|
||||
views::BridgedNativeWidget* bridged_view =
|
||||
views::NativeWidgetMac::GetBridgeForNativeWindow(
|
||||
shell->GetNativeWindow());
|
||||
auto* bridged_view = views::BridgedNativeWidgetImpl::GetFromNativeWindow(
|
||||
shell->GetNativeWindow());
|
||||
if ((self = [super initWithBridgedNativeWidget:bridged_view])) {
|
||||
shell_ = shell;
|
||||
is_zooming_ = false;
|
||||
|
@ -248,9 +247,8 @@
|
|||
// Clears the delegate when window is going to be closed, since EL Capitan it
|
||||
// is possible that the methods of delegate would get called after the window
|
||||
// has been closed.
|
||||
views::BridgedNativeWidget* bridged_view =
|
||||
views::NativeWidgetMac::GetBridgeForNativeWindow(
|
||||
shell_->GetNativeWindow());
|
||||
auto* bridged_view = views::BridgedNativeWidgetImpl::GetFromNativeWindow(
|
||||
shell_->GetNativeWindow());
|
||||
bridged_view->OnWindowWillClose();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
#include "content/shell/grit/shell_resources.h"
|
||||
#include "electron/grit/electron_resources.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/socket/stream_socket.h"
|
||||
#include "net/socket/tcp_server_socket.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "atom/browser/ui/devtools_ui.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
|
@ -56,6 +57,7 @@ std::string GetMimeTypeForPath(const std::string& path) {
|
|||
class BundledDataSource : public content::URLDataSource {
|
||||
public:
|
||||
BundledDataSource() {}
|
||||
~BundledDataSource() override {}
|
||||
|
||||
// content::URLDataSource implementation.
|
||||
std::string GetSource() const override { return kChromeUIDevToolsHost; }
|
||||
|
@ -104,7 +106,6 @@ class BundledDataSource : public content::URLDataSource {
|
|||
}
|
||||
|
||||
private:
|
||||
~BundledDataSource() override {}
|
||||
DISALLOW_COPY_AND_ASSIGN(BundledDataSource);
|
||||
};
|
||||
|
||||
|
@ -114,7 +115,8 @@ DevToolsUI::DevToolsUI(content::BrowserContext* browser_context,
|
|||
content::WebUI* web_ui)
|
||||
: WebUIController(web_ui) {
|
||||
web_ui->SetBindings(0);
|
||||
content::URLDataSource::Add(browser_context, new BundledDataSource());
|
||||
content::URLDataSource::Add(browser_context,
|
||||
std::make_unique<BundledDataSource>());
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include "base/callback.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "chrome/browser/ui/libgtkui/gtk_signal.h"
|
||||
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
|
||||
|
||||
namespace file_dialog {
|
||||
|
@ -147,7 +147,11 @@ class FileChooserDialog {
|
|||
return paths;
|
||||
}
|
||||
|
||||
CHROMEGTK_CALLBACK_1(FileChooserDialog, void, OnFileDialogResponse, int);
|
||||
CHROMEG_CALLBACK_1(FileChooserDialog,
|
||||
void,
|
||||
OnFileDialogResponse,
|
||||
GtkWidget*,
|
||||
int);
|
||||
|
||||
GtkWidget* dialog() const { return dialog_; }
|
||||
|
||||
|
|
|
@ -20,12 +20,15 @@
|
|||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/prefs/scoped_user_pref_update.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/file_select_listener.h"
|
||||
#include "content/public/browser/host_zoom_map.h"
|
||||
#include "content/public/browser/navigation_handle.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
|
@ -175,8 +178,8 @@ int ResponseWriter::Write(net::IOBuffer* buffer,
|
|||
base::Value* id = new base::Value(stream_id_);
|
||||
base::Value* chunk_value = new base::Value(chunk);
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&InspectableWebContentsImpl::CallClientFunction, bindings_,
|
||||
"DevToolsAPI.streamWrite", base::Owned(id),
|
||||
base::Owned(chunk_value), nullptr));
|
||||
|
@ -426,7 +429,7 @@ void InspectableWebContentsImpl::ActivateWindow() {
|
|||
}
|
||||
|
||||
void InspectableWebContentsImpl::CloseWindow() {
|
||||
GetDevToolsWebContents()->DispatchBeforeUnload();
|
||||
GetDevToolsWebContents()->DispatchBeforeUnload(false /* auto_cancel */);
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::LoadCompleted() {
|
||||
|
@ -801,19 +804,20 @@ content::ColorChooser* InspectableWebContentsImpl::OpenColorChooser(
|
|||
|
||||
void InspectableWebContentsImpl::RunFileChooser(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) {
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const blink::mojom::FileChooserParams& params) {
|
||||
auto* delegate = web_contents_->GetDelegate();
|
||||
if (delegate)
|
||||
delegate->RunFileChooser(render_frame_host, params);
|
||||
delegate->RunFileChooser(render_frame_host, std::move(listener), params);
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::EnumerateDirectory(
|
||||
content::WebContents* source,
|
||||
int request_id,
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const base::FilePath& path) {
|
||||
auto* delegate = web_contents_->GetDelegate();
|
||||
if (delegate)
|
||||
delegate->EnumerateDirectory(source, request_id, path);
|
||||
delegate->EnumerateDirectory(source, std::move(listener), path);
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::OnWebContentsFocused(
|
||||
|
|
|
@ -191,9 +191,10 @@ class InspectableWebContentsImpl
|
|||
const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions)
|
||||
override;
|
||||
void RunFileChooser(content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) override;
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const blink::mojom::FileChooserParams& params) override;
|
||||
void EnumerateDirectory(content::WebContents* source,
|
||||
int request_id,
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const base::FilePath& path) override;
|
||||
|
||||
// net::URLFetcherDelegate:
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include "base/callback.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/browser/ui/libgtkui/gtk_signal.h"
|
||||
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
||||
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
#include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
|
||||
|
||||
|
@ -168,8 +168,8 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
parent_ = nullptr;
|
||||
}
|
||||
|
||||
CHROMEGTK_CALLBACK_1(GtkMessageBox, void, OnResponseDialog, int);
|
||||
CHROMEGTK_CALLBACK_0(GtkMessageBox, void, OnCheckboxToggled);
|
||||
CHROMEG_CALLBACK_1(GtkMessageBox, void, OnResponseDialog, GtkWidget*, int);
|
||||
CHROMEG_CALLBACK_0(GtkMessageBox, void, OnCheckboxToggled, GtkWidget*);
|
||||
|
||||
private:
|
||||
atom::UnresponsiveSuppressor unresponsive_suppressor_;
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
#include "base/callback.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "base/win/scoped_gdi_object.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "ui/gfx/icon_util.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
@ -222,9 +224,8 @@ void RunMessageBoxInNewThread(base::Thread* thread,
|
|||
int result = ShowTaskDialogUTF8(parent, type, buttons, default_id, cancel_id,
|
||||
options, title, message, detail,
|
||||
checkbox_label, &checkbox_checked, icon);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(callback, result, checkbox_checked));
|
||||
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(callback, result, checkbox_checked));
|
||||
content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE,
|
||||
thread);
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
|
|||
canvas->DrawStringRectWithFlags(
|
||||
popup_->GetLabelAt(index), popup_->GetLabelFontListForRow(index),
|
||||
GetNativeTheme()->GetSystemColor(
|
||||
ui::NativeTheme::kColorId_ResultsTableNormalDimmedText),
|
||||
ui::NativeTheme::kColorId_ResultsTableDimmedText),
|
||||
gfx::Rect(label_x_align_left, entry_rect.y(), label_width,
|
||||
entry_rect.height()),
|
||||
text_align);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "atom/browser/ui/views/menu_bar.h"
|
||||
#include "atom/browser/ui/views/menu_model_adapter.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "ui/views/controls/button/menu_button.h"
|
||||
#include "ui/views/controls/menu/menu_item_view.h"
|
||||
|
@ -130,8 +132,8 @@ views::MenuItemView* MenuDelegate::GetSiblingMenu(
|
|||
button_to_open_ = button;
|
||||
// Switching menu asyncnously to avoid crash.
|
||||
if (!switch_in_progress) {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(&views::MenuRunner::Cancel,
|
||||
base::Unretained(menu_runner_.get())));
|
||||
}
|
||||
|
|
|
@ -14,12 +14,14 @@
|
|||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/sequenced_task_runner_helpers.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/browser/loader/resource_dispatcher_host_impl.h"
|
||||
#include "content/browser/loader/resource_request_info_impl.h"
|
||||
#include "content/browser/loader/stream_resource_handler.h"
|
||||
#include "content/browser/resource_context_impl.h"
|
||||
#include "content/browser/streams/stream.h"
|
||||
#include "content/browser/streams/stream_context.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
|
@ -183,8 +185,8 @@ class PdfViewerUI::ResourceRequester
|
|||
new net::HttpResponseHeaders(headers->raw_headers());
|
||||
stream_info_->mime_type = mime_type;
|
||||
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::Bind(&CallMigrationCallback<StreamResponseCallback>,
|
||||
base::Passed(&stream_response_cb_),
|
||||
base::Passed(&stream_info_)));
|
||||
|
@ -243,8 +245,8 @@ void PdfViewerUI::RenderFrameCreated(content::RenderFrameHost* rfh) {
|
|||
auto callback =
|
||||
base::BindOnce(&PdfViewerUI::OnPdfStreamCreated, base::Unretained(this));
|
||||
resource_requester_ = new ResourceRequester(std::move(callback));
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::Bind(&ResourceRequester::StartRequest, resource_requester_,
|
||||
GURL(src_), GURL(kPdfViewerUIOrigin), render_process_id,
|
||||
render_view_id, render_frame_id, resource_context));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "atom/browser/web_dialog_helper.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
|
@ -16,23 +17,29 @@
|
|||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/public/browser/file_select_listener.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/file_chooser_file_info.h"
|
||||
#include "content/public/common/file_chooser_params.h"
|
||||
#include "net/base/mime_util.h"
|
||||
#include "ui/shell_dialogs/selected_file_info.h"
|
||||
|
||||
using blink::mojom::FileChooserFileInfo;
|
||||
using blink::mojom::FileChooserFileInfoPtr;
|
||||
using blink::mojom::FileChooserParams;
|
||||
|
||||
namespace {
|
||||
|
||||
class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
FileSelectHelper(content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams::Mode& mode)
|
||||
: render_frame_host_(render_frame_host), mode_(mode) {
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
blink::mojom::FileChooserParams::Mode mode)
|
||||
: render_frame_host_(render_frame_host),
|
||||
listener_(std::move(listener)),
|
||||
mode_(mode) {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
content::WebContentsObserver::Observe(web_contents);
|
||||
|
@ -61,13 +68,12 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
|
|||
void OnOpenDialogDone(bool result, const std::vector<base::FilePath>& paths)
|
||||
#endif
|
||||
{
|
||||
std::vector<content::FileChooserFileInfo> file_info;
|
||||
std::vector<FileChooserFileInfoPtr> file_info;
|
||||
if (result) {
|
||||
for (auto& path : paths) {
|
||||
content::FileChooserFileInfo info;
|
||||
info.file_path = path;
|
||||
info.display_name = path.BaseName().value();
|
||||
file_info.push_back(info);
|
||||
file_info.push_back(FileChooserFileInfo::NewNativeFile(
|
||||
blink::mojom::NativeFileInfo::New(
|
||||
path, path.BaseName().AsUTF16Unsafe())));
|
||||
}
|
||||
|
||||
if (render_frame_host_ && !paths.empty()) {
|
||||
|
@ -77,7 +83,7 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
|
|||
paths[0].DirName());
|
||||
}
|
||||
}
|
||||
OnFilesSelected(file_info);
|
||||
OnFilesSelected(std::move(file_info));
|
||||
}
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
|
@ -88,20 +94,22 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
|
|||
void OnSaveDialogDone(bool result, const base::FilePath& path)
|
||||
#endif
|
||||
{
|
||||
std::vector<content::FileChooserFileInfo> file_info;
|
||||
std::vector<FileChooserFileInfoPtr> file_info;
|
||||
if (result) {
|
||||
content::FileChooserFileInfo info;
|
||||
info.file_path = path;
|
||||
info.display_name = path.BaseName().value();
|
||||
file_info.push_back(info);
|
||||
file_info.push_back(
|
||||
FileChooserFileInfo::NewNativeFile(blink::mojom::NativeFileInfo::New(
|
||||
path, path.BaseName().AsUTF16Unsafe())));
|
||||
}
|
||||
OnFilesSelected(file_info);
|
||||
OnFilesSelected(std::move(file_info));
|
||||
}
|
||||
|
||||
void OnFilesSelected(
|
||||
const std::vector<content::FileChooserFileInfo>& file_info) {
|
||||
if (render_frame_host_)
|
||||
render_frame_host_->FilesSelectedInChooser(file_info, mode_);
|
||||
void OnFilesSelected(std::vector<FileChooserFileInfoPtr> file_info) {
|
||||
if (listener_) {
|
||||
listener_->FileSelected(std::move(file_info), mode_);
|
||||
listener_.reset();
|
||||
}
|
||||
render_frame_host_ = nullptr;
|
||||
Release();
|
||||
}
|
||||
|
||||
// content::WebContentsObserver:
|
||||
|
@ -121,7 +129,8 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
|
|||
void WebContentsDestroyed() override { render_frame_host_ = nullptr; }
|
||||
|
||||
content::RenderFrameHost* render_frame_host_;
|
||||
content::FileChooserParams::Mode mode_;
|
||||
std::unique_ptr<content::FileSelectListener> listener_;
|
||||
blink::mojom::FileChooserParams::Mode mode_;
|
||||
};
|
||||
|
||||
file_dialog::Filters GetFileTypesFromAcceptType(
|
||||
|
@ -201,31 +210,30 @@ WebDialogHelper::~WebDialogHelper() {}
|
|||
|
||||
void WebDialogHelper::RunFileChooser(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) {
|
||||
std::vector<content::FileChooserFileInfo> result;
|
||||
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const blink::mojom::FileChooserParams& params) {
|
||||
file_dialog::DialogSettings settings;
|
||||
settings.force_detached = offscreen_;
|
||||
settings.filters = GetFileTypesFromAcceptType(params.accept_types);
|
||||
settings.parent_window = window_;
|
||||
settings.title = base::UTF16ToUTF8(params.title);
|
||||
|
||||
scoped_refptr<FileSelectHelper> file_select_helper(
|
||||
new FileSelectHelper(render_frame_host, params.mode));
|
||||
if (params.mode == content::FileChooserParams::Save) {
|
||||
scoped_refptr<FileSelectHelper> file_select_helper(new FileSelectHelper(
|
||||
render_frame_host, std::move(listener), params.mode));
|
||||
if (params.mode == FileChooserParams::Mode::kSave) {
|
||||
settings.default_path = params.default_file_name;
|
||||
file_select_helper->ShowSaveDialog(settings);
|
||||
} else {
|
||||
int flags = file_dialog::FILE_DIALOG_CREATE_DIRECTORY;
|
||||
switch (params.mode) {
|
||||
case content::FileChooserParams::OpenMultiple:
|
||||
case FileChooserParams::Mode::kOpenMultiple:
|
||||
flags |= file_dialog::FILE_DIALOG_MULTI_SELECTIONS;
|
||||
FALLTHROUGH;
|
||||
case content::FileChooserParams::Open:
|
||||
case FileChooserParams::Mode::kOpen:
|
||||
flags |= file_dialog::FILE_DIALOG_OPEN_FILE;
|
||||
flags |= file_dialog::FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY;
|
||||
break;
|
||||
case content::FileChooserParams::UploadFolder:
|
||||
case FileChooserParams::Mode::kUploadFolder:
|
||||
flags |= file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
|
||||
break;
|
||||
default:
|
||||
|
@ -242,20 +250,23 @@ void WebDialogHelper::RunFileChooser(
|
|||
}
|
||||
}
|
||||
|
||||
void WebDialogHelper::EnumerateDirectory(content::WebContents* web_contents,
|
||||
int request_id,
|
||||
const base::FilePath& dir) {
|
||||
void WebDialogHelper::EnumerateDirectory(
|
||||
content::WebContents* web_contents,
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const base::FilePath& dir) {
|
||||
int types = base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES |
|
||||
base::FileEnumerator::INCLUDE_DOT_DOT;
|
||||
base::FileEnumerator file_enum(dir, false, types);
|
||||
|
||||
base::FilePath path;
|
||||
std::vector<base::FilePath> paths;
|
||||
while (!(path = file_enum.Next()).empty())
|
||||
paths.push_back(path);
|
||||
std::vector<FileChooserFileInfoPtr> file_info;
|
||||
while (!(path = file_enum.Next()).empty()) {
|
||||
file_info.push_back(FileChooserFileInfo::NewNativeFile(
|
||||
blink::mojom::NativeFileInfo::New(path, base::string16())));
|
||||
}
|
||||
|
||||
web_contents->GetRenderViewHost()->DirectoryEnumerationFinished(request_id,
|
||||
paths);
|
||||
listener->FileSelected(std::move(file_info),
|
||||
FileChooserParams::Mode::kUploadFolder);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -5,14 +5,17 @@
|
|||
#ifndef ATOM_BROWSER_WEB_DIALOG_HELPER_H_
|
||||
#define ATOM_BROWSER_WEB_DIALOG_HELPER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
|
||||
|
||||
namespace base {
|
||||
class FilePath;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
struct FileChooserParams;
|
||||
class FileSelectListener;
|
||||
class RenderFrameHost;
|
||||
class WebContents;
|
||||
} // namespace content
|
||||
|
@ -27,9 +30,10 @@ class WebDialogHelper {
|
|||
~WebDialogHelper();
|
||||
|
||||
void RunFileChooser(content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params);
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const blink::mojom::FileChooserParams& params);
|
||||
void EnumerateDirectory(content::WebContents* web_contents,
|
||||
int request_id,
|
||||
std::unique_ptr<content::FileSelectListener> listener,
|
||||
const base::FilePath& path);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue