Update files for Chrome 54 API changes

This commit is contained in:
Cheng Zhao 2016-11-30 16:30:03 +09:00 коммит произвёл Birunthan Mohanathas
Родитель bdc334d797
Коммит 497f5a1199
52 изменённых файлов: 275 добавлений и 298 удалений

Просмотреть файл

@ -55,7 +55,7 @@ int NodeMain(int argc, char *argv[]) {
// Start our custom debugger implementation.
NodeDebugger node_debugger(gin_env.isolate());
if (node_debugger.IsRunning())
env->AssignToContext(v8::Debug::GetDebugContext());
env->AssignToContext(v8::Debug::GetDebugContext(gin_env.isolate()));
#if defined(OS_WIN)
mate::Dictionary process(gin_env.isolate(), env->process_object());

Просмотреть файл

@ -312,8 +312,21 @@ struct Converter<Browser::LoginItemSettings> {
return dict.GetHandle();
}
};
} // namespace mate
template<>
struct Converter<content::CertificateRequestResultType> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
content::CertificateRequestResultType* out) {
bool b;
if (!ConvertFromV8(isolate, val, &b))
return false;
*out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
return true;
}
};
} // namespace mate
namespace atom {
@ -573,8 +586,8 @@ void App::AllowCertificateError(
bool overridable,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(bool)>& callback,
content::CertificateRequestResultType* request) {
const base::Callback<void(content::CertificateRequestResultType)>&
callback) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
bool prevent_default = Emit("certificate-error",
@ -586,7 +599,7 @@ void App::AllowCertificateError(
// Deny the certificate by default.
if (!prevent_default)
*request = content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY;
callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
}
void App::SelectClientCertificate(

Просмотреть файл

@ -98,8 +98,8 @@ class App : public AtomBrowserClient::Delegate,
bool overridable,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(bool)>& callback,
content::CertificateRequestResultType* request) override;
const base::Callback<void(content::CertificateRequestResultType)>&
callback) override;
void SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,

Просмотреть файл

@ -10,8 +10,8 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "native_mate/dictionary.h"
#include "net/base/filename_util.h"
@ -80,7 +80,8 @@ void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
Emit("done", item->GetState());
// Destroy the item once item is downloaded.
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, GetDestroyClosure());
} else {
Emit("updated", item->GetState());
}

Просмотреть файл

@ -11,6 +11,8 @@
#include "atom/common/node_includes.h"
using content::BrowserThread;
namespace mate {
template<>
@ -76,10 +78,8 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
new_blocker_type,
device::PowerSaveBlocker::kReasonOther,
ATOM_PRODUCT_NAME,
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE)));
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
power_save_blocker_.swap(new_blocker);
current_blocker_type_ = new_blocker_type;
}

Просмотреть файл

@ -254,8 +254,8 @@ class ResolveProxyHelper {
// Start the request.
int result = proxy_service->ResolveProxy(
url, "GET", net::LOAD_NORMAL, &proxy_info_, completion_callback,
&pac_req_, nullptr, net::BoundNetLog());
url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr,
net::BoundNetLog());
// Completed synchronously.
if (result != net::ERR_IO_PENDING)

Просмотреть файл

@ -13,6 +13,7 @@
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/node_includes.h"
#include "base/threading/thread_task_runner_handle.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
#include "ui/gfx/image/image.h"
@ -71,7 +72,8 @@ Tray::Tray(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
Tray::~Tray() {
// Destroy the native tray in next tick.
base::MessageLoop::current()->DeleteSoon(FROM_HERE, tray_icon_.release());
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
FROM_HERE, tray_icon_.release());
}
// static

Просмотреть файл

@ -40,6 +40,7 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "chrome/browser/printing/print_preview_message_handler.h"
@ -830,7 +831,8 @@ void WebContents::WebContentsDestroyed() {
Emit("destroyed");
// Destroy the native class in next tick.
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, GetDestroyClosure());
}
void WebContents::NavigationEntryCommitted(
@ -976,7 +978,7 @@ std::string WebContents::GetUserAgent() {
}
void WebContents::InsertCSS(const std::string& css) {
web_contents()->InsertCSS(css);
// FIXME(zcbenz): Redirect this method to webFrame.
}
bool WebContents::SavePage(const base::FilePath& full_file_path,
@ -1066,7 +1068,8 @@ void WebContents::InspectElement(int x, int y) {
OpenDevTools(nullptr);
scoped_refptr<content::DevToolsAgentHost> agent(
content::DevToolsAgentHost::GetOrCreateFor(web_contents()));
agent->InspectElement(x, y);
// FIXME(zcbenz): Figure out how to implement this for Chrome 54.
agent->InspectElement(nullptr, x, y);
}
void WebContents::InspectServiceWorker() {

Просмотреть файл

@ -17,6 +17,7 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
#include "native_mate/constructor.h"
@ -152,7 +153,7 @@ Window::~Window() {
// Destroy the native window in next tick because the native code might be
// iterating all windows.
base::MessageLoop::current()->DeleteSoon(FROM_HERE, window_.release());
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window_.release());
}
void Window::WillCloseWindow(bool* prevent_default) {
@ -185,7 +186,8 @@ void Window::OnWindowClosed() {
RemoveFromParentChildWindows();
// Destroy the native class when window is closed.
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, GetDestroyClosure());
}
void Window::OnWindowBlur() {

Просмотреть файл

@ -73,7 +73,7 @@ void AtomBlobReader::StartReading(
auto blob_reader = blob_data_handle->CreateReader(
file_system_context_.get(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get());
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
BlobReadHelper* blob_read_helper =
new BlobReadHelper(std::move(blob_reader), callback);
blob_read_helper->Read();

Просмотреть файл

@ -10,7 +10,6 @@
#include "atom/browser/api/atom_api_app.h"
#include "atom/browser/api/atom_api_protocol.h"
#include "atom/browser/atom_access_token_store.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_quota_permission_context.h"
@ -33,7 +32,6 @@
#include "content/common/resource_request_body_impl.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
@ -56,19 +54,6 @@ bool g_suppress_renderer_process_restart = false;
// Custom schemes to be registered to handle service worker.
std::string g_custom_service_worker_schemes = "";
// A provider of Geolocation services to override AccessTokenStore.
class AtomGeolocationDelegate : public content::GeolocationDelegate {
public:
AtomGeolocationDelegate() = default;
content::AccessTokenStore* CreateAccessTokenStore() final {
return new AtomAccessTokenStore();
}
private:
DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate);
};
void Noop(scoped_refptr<content::SiteInstance>) {
}
@ -93,7 +78,7 @@ AtomBrowserClient::~AtomBrowserClient() {
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
int process_id) {
// If the process is a pending process, we should use the old one.
if (ContainsKey(pending_processes_, process_id))
if (base::ContainsKey(pending_processes_, process_id))
process_id = pending_processes_[process_id];
// Certain render process will be created with no associated render view,
@ -160,11 +145,6 @@ content::SpeechRecognitionManagerDelegate*
return new AtomSpeechRecognitionManagerDelegate;
}
content::GeolocationDelegate*
AtomBrowserClient::CreateGeolocationDelegate() {
return new AtomGeolocationDelegate();
}
void AtomBrowserClient::OverrideWebkitPrefs(
content::RenderViewHost* host, content::WebPreferences* prefs) {
prefs->javascript_enabled = true;
@ -283,13 +263,13 @@ void AtomBrowserClient::AllowCertificateError(
bool overridable,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(bool)>& callback,
content::CertificateRequestResultType* request) {
const base::Callback<void(content::CertificateRequestResultType)>&
callback) {
if (delegate_) {
delegate_->AllowCertificateError(
web_contents, cert_error, ssl_info, request_url,
resource_type, overridable, strict_enforcement,
expired_previous_decision, callback, request);
expired_previous_decision, callback);
}
}
@ -315,9 +295,9 @@ bool AtomBrowserClient::CanCreateWindow(
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
WindowContainerType container_type,
const std::string& frame_name,
const GURL& target_url,
const content::Referrer& referrer,
const std::string& frame_name,
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features,

Просмотреть файл

@ -50,7 +50,6 @@ class AtomBrowserClient : public brightray::BrowserClient,
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override;
device::GeolocationDelegate* CreateGeolocationDelegate() override;
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
content::WebPreferences* prefs) override;
std::string GetApplicationLocale() override;
@ -72,8 +71,8 @@ class AtomBrowserClient : public brightray::BrowserClient,
bool overridable,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(bool)>& callback,
content::CertificateRequestResultType* request) override;
const base::Callback<void(content::CertificateRequestResultType)>&
callback) override;
void SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
@ -84,9 +83,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
WindowContainerType container_type,
const std::string& frame_name,
const GURL& target_url,
const content::Referrer& referrer,
const std::string& frame_name,
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features,

Просмотреть файл

@ -5,6 +5,7 @@
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/atom_access_token_store.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/bridge_task_runner.h"
@ -18,6 +19,8 @@
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/browser_process.h"
#include "content/public/browser/child_process_security_policy.h"
#include "device/geolocation/geolocation_delegate.h"
#include "device/geolocation/geolocation_provider.h"
#include "v8/include/v8-debug.h"
#if defined(USE_X11)
@ -27,11 +30,28 @@
namespace atom {
namespace {
// A provider of Geolocation services to override AccessTokenStore.
class AtomGeolocationDelegate : public device::GeolocationDelegate {
public:
AtomGeolocationDelegate() = default;
scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final {
return new AtomAccessTokenStore();
}
private:
DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate);
};
template<typename T>
void Erase(T* container, typename T::iterator iter) {
container->erase(iter);
}
} // namespace
// static
AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr;
@ -115,7 +135,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
// Make sure node can get correct environment when debugging.
if (node_debugger_->IsRunning())
env->AssignToContext(v8::Debug::GetDebugContext());
env->AssignToContext(v8::Debug::GetDebugContext(js_env_->isolate()));
// Add Electron extended APIs.
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
@ -171,6 +191,8 @@ void AtomBrowserMainParts::PostMainMessageLoopStart() {
#if defined(OS_POSIX)
HandleShutdownSignals();
#endif
device::GeolocationProvider::SetGeolocationDelegate(
new AtomGeolocationDelegate());
}
void AtomBrowserMainParts::PostMainMessageLoopRun() {

Просмотреть файл

@ -51,6 +51,7 @@ int AtomPermissionManager::RequestPermission(
content::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const ResponseCallback& response_callback) {
int process_id = render_frame_host->GetProcess()->GetID();
@ -81,8 +82,9 @@ int AtomPermissionManager::RequestPermissions(
const std::vector<content::PermissionType>& permissions,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(
const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
// FIXME(zcbenz): Just ignore multiple permissions request for now.
std::vector<blink::mojom::PermissionStatus> permissionStatuses;
for (auto permission : permissions) {

Просмотреть файл

@ -37,13 +37,17 @@ class AtomPermissionManager : public content::PermissionManager {
content::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
const ResponseCallback& callback) override;
bool user_gesture,
const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
override;
int RequestPermissions(
const std::vector<content::PermissionType>& permissions,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(
const std::vector<blink::mojom::PermissionStatus>&)>& callback) override;
const std::vector<blink::mojom::PermissionStatus>&)>& callback)
override;
protected:
void OnPermissionResponse(int request_id,

Просмотреть файл

@ -91,14 +91,9 @@ void AtomSecurityStateModelClient::GetVisibleSecurityState(
state->connection_status = ssl.connection_status;
state->security_bits = ssl.security_bits;
state->sct_verify_statuses.clear();
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
ssl.num_unknown_scts,
net::ct::SCT_STATUS_LOG_UNKNOWN);
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
ssl.num_invalid_scts,
net::ct::SCT_STATUS_INVALID);
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
ssl.num_valid_scts, net::ct::SCT_STATUS_OK);
state->sct_verify_statuses.insert(state->sct_verify_statuses.begin(),
ssl.sct_statuses.begin(),
ssl.sct_statuses.end());
state->displayed_mixed_content =
(ssl.content_status & content::SSLStatus::DISPLAYED_INSECURE_CONTENT)
? true

Просмотреть файл

@ -10,8 +10,8 @@
#include "atom/browser/native_window.h"
#include "atom/browser/window_list.h"
#include "base/files/file_util.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brightray/browser/brightray_paths.h"
namespace atom {
@ -85,7 +85,7 @@ void Browser::Shutdown() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit());
if (base::MessageLoop::current()) {
base::MessageLoop::current()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
} else {
// There is no message loop available so we are in early stage.

Просмотреть файл

@ -331,14 +331,14 @@ content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
explanations->ran_insecure_content =
security_info.mixed_content_status ==
SecurityStateModel::RAN_MIXED_CONTENT ||
security_state::SecurityStateModel::CONTENT_STATUS_RAN ||
security_info.mixed_content_status ==
SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN;
explanations->displayed_insecure_content =
security_info.mixed_content_status ==
SecurityStateModel::DISPLAYED_MIXED_CONTENT ||
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED ||
security_info.mixed_content_status ==
SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN;
if (net::IsCertStatusError(security_info.cert_status)) {
std::string error_string = net::ErrorToString(
@ -364,13 +364,6 @@ content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
}
}
if (security_info.is_secure_protocol_and_ciphersuite) {
explanations->secure_explanations.push_back(
content::SecurityStyleExplanation(
kSecureProtocol,
kSecureProtocolDescription));
}
return security_style;
}

Просмотреть файл

@ -89,8 +89,12 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
}
}
void BluetoothChooser::AddDevice(const std::string& device_id,
const base::string16& device_name) {
void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool should_update_name,
const base::string16& device_name,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
DeviceInfo info = {device_id, device_name};
device_list_.push_back(info);
}

Просмотреть файл

@ -27,8 +27,12 @@ class BluetoothChooser : public content::BluetoothChooser {
// content::BluetoothChooser:
void SetAdapterPresence(AdapterPresence presence) override;
void ShowDiscoveryState(DiscoveryState state) override;
void AddDevice(const std::string& device_id,
const base::string16& device_name) override;
void AddOrUpdateDevice(const std::string& device_id,
bool should_update_name,
const base::string16& device_name,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
void RemoveDevice(const std::string& device_id) override;
private:

Просмотреть файл

@ -20,6 +20,7 @@
#include "base/json/json_writer.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "components/prefs/pref_service.h"
@ -604,7 +605,7 @@ void NativeWindow::DidFirstVisuallyNonEmptyPaint() {
view->SetSize(GetContentSize());
// Emit the ReadyToShow event in next tick in case of pending drawing work.
base::MessageLoop::current()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&NativeWindow::NotifyReadyToShow, GetWeakPtr()));
}
@ -635,7 +636,7 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
window_unresposive_closure_.Reset(
base::Bind(&NativeWindow::NotifyWindowUnresponsive,
weak_factory_.GetWeakPtr()));
base::MessageLoop::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
window_unresposive_closure_.callback(),
base::TimeDelta::FromMilliseconds(ms));

Просмотреть файл

@ -232,7 +232,7 @@ int AtomNetworkDelegate::OnBeforeURLRequest(
net::URLRequest* request,
const net::CompletionCallback& callback,
GURL* new_url) {
if (!ContainsKey(response_listeners_, kOnBeforeRequest))
if (!base::ContainsKey(response_listeners_, kOnBeforeRequest))
return brightray::NetworkDelegate::OnBeforeURLRequest(
request, callback, new_url);
@ -253,7 +253,7 @@ int AtomNetworkDelegate::OnBeforeStartTransaction(
headers->SetHeader(
DevToolsNetworkTransaction::kDevToolsEmulateNetworkConditionsClientId,
client_id);
if (!ContainsKey(response_listeners_, kOnBeforeSendHeaders))
if (!base::ContainsKey(response_listeners_, kOnBeforeSendHeaders))
return brightray::NetworkDelegate::OnBeforeStartTransaction(
request, callback, headers);
@ -264,7 +264,7 @@ int AtomNetworkDelegate::OnBeforeStartTransaction(
void AtomNetworkDelegate::OnStartTransaction(
net::URLRequest* request,
const net::HttpRequestHeaders& headers) {
if (!ContainsKey(simple_listeners_, kOnSendHeaders)) {
if (!base::ContainsKey(simple_listeners_, kOnSendHeaders)) {
brightray::NetworkDelegate::OnStartTransaction(request, headers);
return;
}
@ -278,7 +278,7 @@ int AtomNetworkDelegate::OnHeadersReceived(
const net::HttpResponseHeaders* original,
scoped_refptr<net::HttpResponseHeaders>* override,
GURL* allowed) {
if (!ContainsKey(response_listeners_, kOnHeadersReceived))
if (!base::ContainsKey(response_listeners_, kOnHeadersReceived))
return brightray::NetworkDelegate::OnHeadersReceived(
request, callback, original, override, allowed);
@ -289,7 +289,7 @@ int AtomNetworkDelegate::OnHeadersReceived(
void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
const GURL& new_location) {
if (!ContainsKey(simple_listeners_, kOnBeforeRedirect)) {
if (!base::ContainsKey(simple_listeners_, kOnBeforeRedirect)) {
brightray::NetworkDelegate::OnBeforeRedirect(request, new_location);
return;
}
@ -300,7 +300,7 @@ void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
}
void AtomNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
if (!ContainsKey(simple_listeners_, kOnResponseStarted)) {
if (!base::ContainsKey(simple_listeners_, kOnResponseStarted)) {
brightray::NetworkDelegate::OnResponseStarted(request);
return;
}
@ -329,7 +329,7 @@ void AtomNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
return;
}
if (!ContainsKey(simple_listeners_, kOnCompleted)) {
if (!base::ContainsKey(simple_listeners_, kOnCompleted)) {
brightray::NetworkDelegate::OnCompleted(request, started);
return;
}
@ -344,7 +344,7 @@ void AtomNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
void AtomNetworkDelegate::OnErrorOccurred(
net::URLRequest* request, bool started) {
if (!ContainsKey(simple_listeners_, kOnErrorOccurred)) {
if (!base::ContainsKey(simple_listeners_, kOnErrorOccurred)) {
brightray::NetworkDelegate::OnCompleted(request, started);
return;
}
@ -399,7 +399,7 @@ template<typename T>
void AtomNetworkDelegate::OnListenerResultInIO(
uint64_t id, T out, std::unique_ptr<base::DictionaryValue> response) {
// The request has been destroyed.
if (!ContainsKey(callbacks_, id))
if (!base::ContainsKey(callbacks_, id))
return;
ReadFromResponseObject(*response.get(), out);

Просмотреть файл

@ -36,7 +36,7 @@ bool AtomURLRequestJobFactory::SetProtocolHandler(
return true;
}
if (ContainsKey(protocol_handler_map_, scheme))
if (base::ContainsKey(protocol_handler_map_, scheme))
return false;
protocol_handler_map_[scheme] = protocol_handler.release();
return true;
@ -45,8 +45,8 @@ bool AtomURLRequestJobFactory::SetProtocolHandler(
bool AtomURLRequestJobFactory::InterceptProtocol(
const std::string& scheme,
std::unique_ptr<ProtocolHandler> protocol_handler) {
if (!ContainsKey(protocol_handler_map_, scheme) ||
ContainsKey(original_protocols_, scheme))
if (!base::ContainsKey(protocol_handler_map_, scheme) ||
base::ContainsKey(original_protocols_, scheme))
return false;
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
protocol_handler_map_[scheme] = protocol_handler.release();
@ -74,11 +74,11 @@ ProtocolHandler* AtomURLRequestJobFactory::GetProtocolHandler(
bool AtomURLRequestJobFactory::HasProtocolHandler(
const std::string& scheme) const {
return ContainsKey(protocol_handler_map_, scheme);
return base::ContainsKey(protocol_handler_map_, scheme);
}
void AtomURLRequestJobFactory::Clear() {
STLDeleteValues(&protocol_handler_map_);
base::STLDeleteValues(&protocol_handler_map_);
}
net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(

Просмотреть файл

@ -51,8 +51,9 @@ NodeDebugger::NodeDebugger(v8::Isolate* isolate)
base::StringToInt(port_str, &port);
isolate_->SetData(kIsolateSlot, this);
v8::Debug::SetMessageHandler(DebugMessageHandler);
v8::Debug::SetMessageHandler(isolate_, DebugMessageHandler);
weak_up_ui_handle_.data = this;
uv_async_init(uv_default_loop(), &weak_up_ui_handle_, ProcessMessageInUI);
// Start a new IO thread.
@ -64,7 +65,7 @@ NodeDebugger::NodeDebugger(v8::Isolate* isolate)
}
// Start the server in new IO thread.
thread_.message_loop()->PostTask(
thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&NodeDebugger::StartServer, weak_factory_.GetWeakPtr(),
port));
@ -126,7 +127,8 @@ void NodeDebugger::SendConnectMessage() {
// static
void NodeDebugger::ProcessMessageInUI(uv_async_t* handle) {
v8::Debug::ProcessDebugMessages();
NodeDebugger* self = static_cast<NodeDebugger*>(handle->data);
v8::Debug::ProcessDebugMessages(self->isolate_);
}
// static
@ -136,7 +138,7 @@ void NodeDebugger::DebugMessageHandler(const v8::Debug::Message& message) {
if (self) {
std::string message8(*v8::String::Utf8Value(message.GetJSON()));
self->thread_.message_loop()->PostTask(
self->thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&NodeDebugger::SendMessage, self->weak_factory_.GetWeakPtr(),
message8));

Просмотреть файл

@ -302,8 +302,8 @@ class AtomBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
const base::Closure& callback)
: callback_(callback) {
time_source_.reset(new cc::DelayBasedTimeSource(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI).get()));
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI).get()));
time_source_->SetClient(this);
}
@ -548,6 +548,10 @@ bool OffScreenRenderWidgetHostView::LockMouse() {
void OffScreenRenderWidgetHostView::UnlockMouse() {
}
void OffScreenRenderWidgetHostView::SetNeedsBeginFrames(
bool needs_begin_frames) {
}
void OffScreenRenderWidgetHostView::OnSwapCompositorFrame(
uint32_t output_surface_id,
cc::CompositorFrame frame) {
@ -678,22 +682,6 @@ bool OffScreenRenderWidgetHostView::HasAcceleratedSurface(const gfx::Size &) {
return false;
}
void OffScreenRenderWidgetHostView::GetScreenInfo(
blink::WebScreenInfo* results) {
results->rect = gfx::Rect(size_);
results->availableRect = gfx::Rect(size_);
results->depth = 24;
results->depthPerComponent = 8;
results->deviceScaleFactor = scale_factor_;
results->orientationAngle = 0;
results->orientationType = blink::WebScreenOrientationLandscapePrimary;
}
bool OffScreenRenderWidgetHostView::GetScreenColorProfile(
blink::WebVector<char>*) {
return false;
}
gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() {
return gfx::Rect(size_);
}
@ -716,12 +704,7 @@ gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const {
return size_;
}
int OffScreenRenderWidgetHostView::
DelegatedFrameHostGetGpuMemoryBufferClientId()
const {
return render_widget_host_->GetProcess()->GetID();
}
#if !defined(OS_MACOSX)
ui::Layer* OffScreenRenderWidgetHostView::DelegatedFrameHostGetLayer() const {
return const_cast<ui::Layer*>(root_layer_.get());
}
@ -754,19 +737,14 @@ void OffScreenRenderWidgetHostView::DelegatedFrameHostResizeLockWasReleased() {
return render_widget_host_->WasResized();
}
void OffScreenRenderWidgetHostView::DelegatedFrameHostSendCompositorSwapAck(
int output_surface_id, const cc::CompositorFrameAck& ack) {
render_widget_host_->Send(new ViewMsg_SwapCompositorFrameAck(
render_widget_host_->GetRoutingID(),
output_surface_id, ack));
}
void OffScreenRenderWidgetHostView::
DelegatedFrameHostSendReclaimCompositorResources(
int output_surface_id, const cc::CompositorFrameAck& ack) {
void
OffScreenRenderWidgetHostView::DelegatedFrameHostSendReclaimCompositorResources(
int output_surface_id,
bool is_swap_ack,
const cc::ReturnedResourceArray& resources) {
render_widget_host_->Send(new ViewMsg_ReclaimCompositorResources(
render_widget_host_->GetRoutingID(),
output_surface_id, ack));
render_widget_host_->GetRoutingID(), output_surface_id, is_swap_ack,
resources));
}
void OffScreenRenderWidgetHostView::
@ -783,6 +761,12 @@ void OffScreenRenderWidgetHostView::SetBeginFrameSource(
cc::BeginFrameSource* source) {
}
bool OffScreenRenderWidgetHostView::IsAutoResizeEnabled() const {
return render_widget_host_->auto_resize_enabled();
}
#endif // !defined(OS_MACOSX)
std::unique_ptr<cc::SoftwareOutputDevice>
OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice(
ui::Compositor* compositor) {

Просмотреть файл

@ -61,7 +61,9 @@ class MacHelper;
class OffScreenRenderWidgetHostView
: public content::RenderWidgetHostViewBase,
public ui::CompositorDelegate,
#if !defined(OS_MACOSX)
public content::DelegatedFrameHostClient,
#endif
public NativeWindowObserver {
public:
OffScreenRenderWidgetHostView(bool transparent,
@ -92,6 +94,7 @@ class OffScreenRenderWidgetHostView
void SetBackgroundColor(SkColor color) override;
bool LockMouse(void) override;
void UnlockMouse(void) override;
void SetNeedsBeginFrames(bool needs_begin_frames) override;
#if defined(OS_MACOSX)
ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override;
void SetActive(bool active) override;
@ -137,8 +140,6 @@ class OffScreenRenderWidgetHostView
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber>) override;
void EndFrameSubscription() override;
bool HasAcceleratedSurface(const gfx::Size &) override;
void GetScreenInfo(blink::WebScreenInfo *) override;
bool GetScreenColorProfile(blink::WebVector<char>*);
gfx::Rect GetBoundsInRootWindow(void) override;
void LockCompositingSurface(void) override;
void UnlockCompositingSurface(void) override;
@ -147,6 +148,7 @@ class OffScreenRenderWidgetHostView
gfx::Size GetPhysicalBackingSize() const override;
gfx::Size GetRequestedRendererSize() const override;
#if !defined(OS_MACOSX)
// content::DelegatedFrameHostClient:
int DelegatedFrameHostGetGpuMemoryBufferClientId(void) const;
ui::Layer *DelegatedFrameHostGetLayer(void) const override;
@ -157,14 +159,15 @@ class OffScreenRenderWidgetHostView
std::unique_ptr<content::ResizeLock> DelegatedFrameHostCreateResizeLock(
bool defer_compositor_lock) override;
void DelegatedFrameHostResizeLockWasReleased(void) override;
void DelegatedFrameHostSendCompositorSwapAck(
int, const cc::CompositorFrameAck &) override;
void DelegatedFrameHostSendReclaimCompositorResources(
int, const cc::CompositorFrameAck &) override;
int output_surface_id,
bool is_swap_ack,
const cc::ReturnedResourceArray& resources) override;
void DelegatedFrameHostOnLostCompositorResources(void) override;
void DelegatedFrameHostUpdateVSyncParameters(
const base::TimeTicks &, const base::TimeDelta &) override;
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
#endif // !defined(OS_MACOSX)
// ui::CompositorDelegate:
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(

Просмотреть файл

@ -38,18 +38,13 @@ class MacHelper :
return color;
}
void BrowserCompositorMacSendCompositorSwapAck(
int output_surface_id,
const cc::CompositorFrameAck& ack) override {
view_->render_widget_host()->Send(new ViewMsg_SwapCompositorFrameAck(
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
}
void BrowserCompositorMacSendReclaimCompositorResources(
int output_surface_id,
const cc::CompositorFrameAck& ack) override {
bool is_swap_ack,
const cc::ReturnedResourceArray& resources) override {
view_->render_widget_host()->Send(new ViewMsg_ReclaimCompositorResources(
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
view_->render_widget_host()->GetRoutingID(), output_surface_id,
is_swap_ack, resources));
}
void BrowserCompositorMacOnLostCompositorResources() override {

Просмотреть файл

@ -106,6 +106,10 @@ void OffScreenWebContentsView::RenderViewSwappedIn(
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {
}
void OffScreenWebContentsView::GetScreenInfo(
blink::WebScreenInfo* web_screen_info) const {
}
#if defined(OS_MACOSX)
void OffScreenWebContentsView::SetAllowOtherViews(bool allow) {
}

Просмотреть файл

@ -51,6 +51,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
void RenderViewCreated(content::RenderViewHost* host) override;
void RenderViewSwappedIn(content::RenderViewHost* host) override;
void SetOverscrollControllerEnabled(bool enabled) override;
void GetScreenInfo(blink::WebScreenInfo* web_screen_info) const override;
#if defined(OS_MACOSX)
void SetAllowOtherViews(bool allow) override;

Просмотреть файл

@ -88,7 +88,7 @@ void GenerateAcceleratorTable(AcceleratorTable* table,
bool TriggerAcceleratorTableCommand(AcceleratorTable* table,
const ui::Accelerator& accelerator) {
if (ContainsKey(*table, accelerator)) {
if (base::ContainsKey(*table, accelerator)) {
const accelerator_util::MenuItem& item = (*table)[accelerator];
if (item.model->IsEnabledAt(item.position)) {
item.model->ActivatedAt(item.position);

Просмотреть файл

@ -26,7 +26,7 @@ class AtomMenuModel : public ui::SimpleMenuModel {
private:
// ui::SimpleMenuModel::Delegate:
bool GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) {
ui::Accelerator* accelerator) const {
return GetAcceleratorForCommandIdWithParams(
command_id, false, accelerator);
}

Просмотреть файл

@ -60,7 +60,7 @@ void WebContentsPermissionHelper::RequestPermission(
web_contents_->GetBrowserContext()->GetPermissionManager());
auto origin = web_contents_->GetLastCommittedURL();
permission_manager->RequestPermission(
permission, rfh, origin,
permission, rfh, origin, false,
base::Bind(&OnPermissionResponse, callback));
}

Просмотреть файл

@ -198,12 +198,6 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
if (!visible) // Default state is visible.
command_line->AppendSwitch(switches::kHiddenPage);
}
// Use frame scheduling for offscreen renderers.
// TODO(zcbenz): Remove this after Chrome 54, on which it becomes default.
bool offscreen;
if (web_preferences.GetBoolean("offscreen", &offscreen) && offscreen)
command_line->AppendSwitch(cc::switches::kEnableBeginFrameScheduling);
}
bool WebContentsPreferences::IsSandboxed(content::WebContents* web_contents) {

Просмотреть файл

@ -29,7 +29,7 @@ void WebViewManager::AddGuest(int guest_instance_id,
}
void WebViewManager::RemoveGuest(int guest_instance_id) {
if (!ContainsKey(web_contents_embedder_map_, guest_instance_id))
if (!base::ContainsKey(web_contents_embedder_map_, guest_instance_id))
return;
web_contents_embedder_map_.erase(guest_instance_id);
@ -43,7 +43,7 @@ void WebViewManager::RemoveGuest(int guest_instance_id) {
}
content::WebContents* WebViewManager::GetEmbedder(int guest_instance_id) {
if (ContainsKey(web_contents_embedder_map_, guest_instance_id))
if (base::ContainsKey(web_contents_embedder_map_, guest_instance_id))
return web_contents_embedder_map_[guest_instance_id].embedder;
else
return nullptr;
@ -53,11 +53,11 @@ content::WebContents* WebViewManager::GetGuestByInstanceID(
int owner_process_id,
int element_instance_id) {
ElementInstanceKey key(owner_process_id, element_instance_id);
if (!ContainsKey(element_instance_id_to_guest_map_, key))
if (!base::ContainsKey(element_instance_id_to_guest_map_, key))
return nullptr;
int guest_instance_id = element_instance_id_to_guest_map_[key];
if (ContainsKey(web_contents_embedder_map_, guest_instance_id))
if (base::ContainsKey(web_contents_embedder_map_, guest_instance_id))
return web_contents_embedder_map_[guest_instance_id].web_contents;
else
return nullptr;

Просмотреть файл

@ -90,11 +90,11 @@ struct Converter<blink::WebMouseEvent::Button> {
blink::WebMouseEvent::Button* out) {
std::string button = base::ToLowerASCII(V8ToString(val));
if (button == "left")
*out = blink::WebMouseEvent::Button::ButtonLeft;
*out = blink::WebMouseEvent::Button::Left;
else if (button == "middle")
*out = blink::WebMouseEvent::Button::ButtonMiddle;
*out = blink::WebMouseEvent::Button::Middle;
else if (button == "right")
*out = blink::WebMouseEvent::Button::ButtonRight;
*out = blink::WebMouseEvent::Button::Right;
else
return false;
return true;
@ -176,7 +176,6 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(
out->windowsKeyCode = keyCode;
if (shifted)
out->modifiers |= blink::WebInputEvent::ShiftKey;
out->setKeyIdentifierFromWindowsKeyCode();
ui::DomCode domCode = ui::UsLayoutKeyboardCodeToDomCode(keyCode);
out->domCode = static_cast<int>(domCode);
@ -246,7 +245,7 @@ bool Converter<blink::WebMouseEvent>::FromV8(
if (!dict.Get("x", &out->x) || !dict.Get("y", &out->y))
return false;
if (!dict.Get("button", &out->button))
out->button = blink::WebMouseEvent::Button::ButtonLeft;
out->button = blink::WebMouseEvent::Button::Left;
dict.Get("globalX", &out->globalX);
dict.Get("globalY", &out->globalY);
dict.Get("movementX", &out->movementX);

Просмотреть файл

@ -15,8 +15,9 @@
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_paths.h"
@ -99,7 +100,6 @@ base::FilePath GetResourcesPath(bool is_browser) {
NodeBindings::NodeBindings(bool is_browser)
: is_browser_(is_browser),
message_loop_(nullptr),
uv_loop_(uv_default_loop()),
embed_closed_(false),
uv_env_(nullptr),
@ -210,7 +210,7 @@ void NodeBindings::RunMessageLoop() {
DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));
// The MessageLoop should have been created, remember the one in main thread.
message_loop_ = base::MessageLoop::current();
task_runner_ = base::ThreadTaskRunnerHandle::Get();
// Run uv loop for once to give the uv__io_poll a chance to add all events.
UvRunOnce();
@ -242,16 +242,16 @@ void NodeBindings::UvRunOnce() {
TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
if (r == 0)
message_loop_->QuitWhenIdle(); // Quit from uv.
base::RunLoop().QuitWhenIdle(); // Quit from uv.
// Tell the worker thread to continue polling.
uv_sem_post(&embed_sem_);
}
void NodeBindings::WakeupMainThread() {
DCHECK(message_loop_);
message_loop_->PostTask(FROM_HERE, base::Bind(&NodeBindings::UvRunOnce,
weak_factory_.GetWeakPtr()));
DCHECK(task_runner_);
task_runner_->PostTask(FROM_HERE, base::Bind(&NodeBindings::UvRunOnce,
weak_factory_.GetWeakPtr()));
}
void NodeBindings::WakeupEmbedThread() {

Просмотреть файл

@ -64,7 +64,7 @@ class NodeBindings {
bool is_browser_;
// Main thread's MessageLoop.
base::MessageLoop* message_loop_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
// Main thread's libuv loop.
uv_loop_t* uv_loop_;

Просмотреть файл

@ -64,19 +64,6 @@ void SpellCheckClient::spellCheck(
}
}
void SpellCheckClient::checkTextOfParagraph(
const blink::WebString& text,
blink::WebTextCheckingTypeMask mask,
blink::WebVector<blink::WebTextCheckingResult>* results) {
if (!results)
return;
if (!(mask & blink::WebTextCheckingTypeSpelling))
return;
NOTREACHED() << "checkTextOfParagraph should never be called";
}
void SpellCheckClient::requestCheckingOfText(
const blink::WebString& textToCheck,
const blink::WebVector<uint32_t>& markersInText,

Просмотреть файл

@ -32,10 +32,6 @@ class SpellCheckClient : public blink::WebSpellCheckClient {
int& misspelledOffset,
int& misspelledLength,
blink::WebVector<blink::WebString>* optionalSuggestions) override;
void checkTextOfParagraph(
const blink::WebString&,
blink::WebTextCheckingTypeMask mask,
blink::WebVector<blink::WebTextCheckingResult>* results) override;
void requestCheckingOfText(
const blink::WebString& textToCheck,
const blink::WebVector<uint32_t>& markersInText,

Просмотреть файл

@ -8,7 +8,7 @@
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/gfx/geometry/size.h"
namespace atom {
@ -53,7 +53,7 @@ void GuestViewContainer::DidResizeElement(const gfx::Size& new_size) {
if (element_resize_callback_.is_null())
return;
base::MessageLoop::current()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(element_resize_callback_, new_size));
}

Просмотреть файл

@ -49,7 +49,8 @@ void AtomContentUtilityClient::UtilityThreadStarted() {
bool AtomContentUtilityClient::OnMessageReceived(
const IPC::Message& message) {
if (filter_messages_ && !ContainsKey(message_id_whitelist_, message.type()))
if (filter_messages_ &&
!base::ContainsKey(message_id_whitelist_, message.type()))
return false;
bool handled = true;

Просмотреть файл

@ -7,7 +7,9 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/threading/worker_pool.h"
#include "base/timer/timer.h"
#include "chrome/browser/chrome_notification_types.h"
@ -196,12 +198,13 @@ bool PrintJob::FlushJob(base::TimeDelta timeout) {
// Make sure the object outlive this message loop.
scoped_refptr<PrintJob> handle(this);
base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
base::Bind(&PrintJob::Quit, quit_factory_.GetWeakPtr()), timeout);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&PrintJob::Quit, quit_factory_.GetWeakPtr()),
timeout);
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
base::MessageLoop::current()->Run();
base::RunLoop().Run();
return true;
}
@ -362,7 +365,7 @@ void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) {
}
case JobEventDetails::DOC_DONE: {
// This will call Stop() and broadcast a JOB_DONE message.
base::MessageLoop::current()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&PrintJob::OnDocumentDone, this));
break;
}

Просмотреть файл

@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
@ -278,7 +279,7 @@ void PrintJobWorker::OnNewPage() {
scoped_refptr<PrintedPage> page = document_->GetPage(page_number_.ToInt());
if (!page.get()) {
// We need to wait for the page to be available.
base::MessageLoop::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&PrintJobWorker::OnNewPage, weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(500));

Просмотреть файл

@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/timer/timer.h"
#include "components/prefs/pref_service.h"
@ -424,7 +425,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
{
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
base::MessageLoop::current()->Run();
base::RunLoop().Run();
}
bool success = true;

Просмотреть файл

@ -32,7 +32,7 @@ PepperBrokerMessageFilter::~PepperBrokerMessageFilter() {}
scoped_refptr<base::TaskRunner>
PepperBrokerMessageFilter::OverrideTaskRunnerForMessage(
const IPC::Message& message) {
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
return BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
}
int32_t PepperBrokerMessageFilter::OnResourceMessageReceived(

Просмотреть файл

@ -110,16 +110,16 @@ PepperFlashClipboardMessageFilter::OverrideTaskRunnerForMessage(
// restrictions of various platform APIs. In general, the clipboard is not
// thread-safe, so all clipboard calls should be serviced from the UI thread.
if (msg.type() == PpapiHostMsg_FlashClipboard_WriteData::ID)
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
return BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
// Windows needs clipboard reads to be serviced from the IO thread because
// these are sync IPCs which can result in deadlocks with plugins if serviced
// from the UI thread. Note that Windows clipboard calls ARE thread-safe so it
// is ok for reads and writes to be serviced from different threads.
#if !defined(OS_WIN)
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
return BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
#else
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
#endif
}

Просмотреть файл

@ -54,7 +54,7 @@ PepperIsolatedFileSystemMessageFilter::OverrideTaskRunnerForMessage(
const IPC::Message& msg) {
// In order to reach ExtensionSystem, we need to get ProfileManager first.
// ProfileManager lives in UI thread, so we need to do this in UI thread.
return content::BrowserThread::GetMessageLoopProxyForThread(
return content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI);
}

Просмотреть файл

@ -24,6 +24,7 @@
#include "net/base/escape.h"
#include "printing/pdf_metafile_skia.h"
#include "printing/units.h"
#include "third_party/WebKit/public/platform/WebDoubleSize.h"
#include "third_party/WebKit/public/platform/WebSize.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
@ -69,15 +70,15 @@ bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) {
}
PrintMsg_Print_Params GetCssPrintParams(
blink::WebFrame* frame,
blink::WebLocalFrame* frame,
int page_index,
const PrintMsg_Print_Params& page_params) {
PrintMsg_Print_Params page_css_params = page_params;
int dpi = GetDPI(&page_params);
blink::WebSize page_size_in_pixels(
ConvertUnit(page_params.page_size.width(), dpi, kPixelsPerInch),
ConvertUnit(page_params.page_size.height(), dpi, kPixelsPerInch));
blink::WebDoubleSize page_size_in_pixels(
ConvertUnitDouble(page_params.page_size.width(), dpi, kPixelsPerInch),
ConvertUnitDouble(page_params.page_size.height(), dpi, kPixelsPerInch));
int margin_top_in_pixels =
ConvertUnit(page_params.margin_top, dpi, kPixelsPerInch);
int margin_right_in_pixels = ConvertUnit(
@ -92,8 +93,6 @@ PrintMsg_Print_Params GetCssPrintParams(
page_params.margin_left,
dpi, kPixelsPerInch);
blink::WebSize original_page_size_in_pixels = page_size_in_pixels;
if (frame) {
frame->pageSizeAndMarginsInPixels(page_index,
page_size_in_pixels,
@ -103,9 +102,9 @@ PrintMsg_Print_Params GetCssPrintParams(
margin_left_in_pixels);
}
int new_content_width = page_size_in_pixels.width -
double new_content_width = page_size_in_pixels.width() -
margin_left_in_pixels - margin_right_in_pixels;
int new_content_height = page_size_in_pixels.height -
double new_content_height = page_size_in_pixels.height() -
margin_top_in_pixels - margin_bottom_in_pixels;
// Invalid page size and/or margins. We just use the default setting.
@ -115,20 +114,12 @@ PrintMsg_Print_Params GetCssPrintParams(
return page_css_params;
}
page_css_params.content_size = gfx::Size(
ConvertUnit(new_content_width, kPixelsPerInch, dpi),
ConvertUnit(new_content_height, kPixelsPerInch, dpi));
if (original_page_size_in_pixels != page_size_in_pixels) {
page_css_params.page_size = gfx::Size(
ConvertUnit(page_size_in_pixels.width, kPixelsPerInch, dpi),
ConvertUnit(page_size_in_pixels.height, kPixelsPerInch, dpi));
} else {
// Printing frame doesn't have any page size css. Pixels to dpi conversion
// causes rounding off errors. Therefore use the default page size values
// directly.
page_css_params.page_size = page_params.page_size;
}
page_css_params.page_size =
gfx::Size(ConvertUnit(page_size_in_pixels.width(), kPixelsPerInch, dpi),
ConvertUnit(page_size_in_pixels.height(), kPixelsPerInch, dpi));
page_css_params.content_size =
gfx::Size(ConvertUnit(new_content_width, kPixelsPerInch, dpi),
ConvertUnit(new_content_height, kPixelsPerInch, dpi));
page_css_params.margin_top =
ConvertUnit(margin_top_in_pixels, kPixelsPerInch, dpi);
@ -274,7 +265,7 @@ MarginType GetMarginsForPdf(blink::WebFrame* frame,
}
PrintMsg_Print_Params CalculatePrintParamsForCss(
blink::WebFrame* frame,
blink::WebLocalFrame* frame,
int page_index,
const PrintMsg_Print_Params& page_params,
bool ignore_css_margins,
@ -429,7 +420,6 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient,
const blink::WebString& unique_name,
blink::WebSandboxFlags sandbox_flags,
const blink::WebFrameOwnerProperties& frame_owner_properties) override;
void frameDetached(blink::WebFrame* frame, DetachType type) override;
private:
void CallOnReady();
@ -567,10 +557,9 @@ void PrepareFrameAndViewForPrint::didStopLoading() {
DCHECK(!on_ready_.is_null());
// Don't call callback here, because it can delete |this| and WebView that is
// called didStopLoading.
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&PrepareFrameAndViewForPrint::CallOnReady,
weak_ptr_factory_.GetWeakPtr()));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&PrepareFrameAndViewForPrint::CallOnReady,
weak_ptr_factory_.GetWeakPtr()));
}
blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame(
@ -585,14 +574,6 @@ blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame(
return frame;
}
void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame,
DetachType type) {
DCHECK(type == DetachType::Remove);
if (frame->parent())
frame->parent()->removeChild(frame);
frame->close();
}
void PrepareFrameAndViewForPrint::CallOnReady() {
return on_ready_.Run(); // Can delete |this|.
}
@ -640,6 +621,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view)
print_node_in_progress_(false),
is_loading_(false),
is_scripted_preview_delayed_(false),
ipc_nesting_level_(0),
weak_ptr_factory_(this) {
}
@ -653,6 +635,15 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame,
}
bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
// The class is not designed to handle recursive messages. This is not
// expected during regular flow. However, during rendering of content for
// printing, lower level code may run nested message loop. E.g. PDF may has
// script to show message box http://crbug.com/502562. In that moment browser
// may receive updated printer capabilities and decide to restart print
// preview generation. When this happened message handling function may
// choose to ignore message or safely crash process.
++ipc_nesting_level_;
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message)
IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages)
@ -660,6 +651,8 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
--ipc_nesting_level_;
return handled;
}
@ -667,28 +660,14 @@ void PrintWebViewHelper::OnDestruct() {
delete this;
}
bool PrintWebViewHelper::GetPrintFrame(blink::WebLocalFrame** frame) {
DCHECK(frame);
blink::WebView* webView = render_view()->GetWebView();
DCHECK(webView);
if (!webView)
return false;
// If the user has selected text in the currently focused frame we print
// only that frame (this makes print selection work for multiple frames).
blink::WebLocalFrame* focusedFrame =
webView->focusedFrame()->toWebLocalFrame();
*frame = focusedFrame->hasSelection()
? focusedFrame
: webView->mainFrame()->toWebLocalFrame();
return true;
}
#if !defined(DISABLE_BASIC_PRINTING)
void PrintWebViewHelper::OnPrintPages(bool silent, bool print_background) {
blink::WebLocalFrame* frame;
if (GetPrintFrame(&frame))
Print(frame, blink::WebNode(), silent, print_background);
if (ipc_nesting_level_> 1)
return;
blink::WebLocalFrame* frame =
render_view()->GetMainRenderFrame()->GetWebFrame();
Print(frame, blink::WebNode(), silent, print_background);
}
#endif // !DISABLE_BASIC_PRINTING
@ -725,22 +704,25 @@ void PrintWebViewHelper::OnPrintingDone(bool success) {
}
void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) {
blink::WebLocalFrame* frame;
if (GetPrintFrame(&frame)) {
print_preview_context_.InitWithFrame(frame);
if (!print_preview_context_.source_frame()) {
DidFinishPrinting(FAIL_PREVIEW);
return;
}
if (ipc_nesting_level_ > 1)
return;
if (!UpdatePrintSettings(print_preview_context_.source_frame(),
print_preview_context_.source_node(), settings)) {
DidFinishPrinting(FAIL_PREVIEW);
return;
}
is_print_ready_metafile_sent_ = false;
PrepareFrameForPreviewDocument();
blink::WebLocalFrame* frame =
render_view()->GetMainRenderFrame()->GetWebFrame();
print_preview_context_.InitWithFrame(frame);
if (!print_preview_context_.source_frame()) {
DidFinishPrinting(FAIL_PREVIEW);
return;
}
if (!UpdatePrintSettings(print_preview_context_.source_frame(),
print_preview_context_.source_node(), settings)) {
DidFinishPrinting(FAIL_PREVIEW);
return;
}
is_print_ready_metafile_sent_ = false;
PrepareFrameForPreviewDocument();
}
void PrintWebViewHelper::PrepareFrameForPreviewDocument() {
@ -972,7 +954,7 @@ void PrintWebViewHelper::FinishFramePrinting() {
}
#if defined(OS_MACOSX)
bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
int page_count) {
const PrintMsg_PrintPages_Params& params = *print_pages_params_;
const PrintMsg_Print_Params& print_params = params.params;
@ -999,7 +981,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
// static - Not anonymous so that platform implementations can use it.
void PrintWebViewHelper::ComputePageLayoutInPointsForCss(
blink::WebFrame* frame,
blink::WebLocalFrame* frame,
int page_index,
const PrintMsg_Print_Params& page_params,
bool ignore_css_margins,
@ -1120,7 +1102,7 @@ bool PrintWebViewHelper::UpdatePrintSettings(
}
bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebFrame* frame,
bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebLocalFrame* frame,
const blink::WebNode& node,
int expected_pages_count) {
PrintHostMsg_ScriptedPrint_Params params;

Просмотреть файл

@ -163,7 +163,7 @@ class PrintWebViewHelper
// Get final print settings from the user.
// Return false if the user cancels or on error.
bool GetPrintSettingsFromUser(blink::WebFrame* frame,
bool GetPrintSettingsFromUser(blink::WebLocalFrame* frame,
const blink::WebNode& node,
int expected_pages_count);
@ -171,23 +171,23 @@ class PrintWebViewHelper
void OnFramePreparedForPrintPages();
void PrintPages();
bool PrintPagesNative(blink::WebFrame* frame, int page_count);
bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count);
void FinishFramePrinting();
// Prints the page listed in |params|.
#if defined(OS_LINUX) || defined(OS_ANDROID)
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
blink::WebFrame* frame,
blink::WebLocalFrame* frame,
PdfMetafileSkia* metafile);
#elif defined(OS_WIN)
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
blink::WebFrame* frame,
blink::WebLocalFrame* frame,
PdfMetafileSkia* metafile,
gfx::Size* page_size_in_dpi,
gfx::Rect* content_area_in_dpi);
#else
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
blink::WebFrame* frame);
blink::WebLocalFrame* frame);
#endif
// Render the frame for printing.
@ -198,7 +198,7 @@ class PrintWebViewHelper
#if defined(OS_MACOSX)
void RenderPage(const PrintMsg_Print_Params& params,
int page_number,
blink::WebFrame* frame,
blink::WebLocalFrame* frame,
bool is_preview,
PdfMetafileSkia* metafile,
gfx::Size* page_size,
@ -223,15 +223,13 @@ class PrintWebViewHelper
// Helper method to get page layout in points and fit to page if needed.
static void ComputePageLayoutInPointsForCss(
blink::WebFrame* frame,
blink::WebLocalFrame* frame,
int page_index,
const PrintMsg_Print_Params& default_params,
bool ignore_css_margins,
double* scale_factor,
PageSizeMargins* page_layout_in_points);
bool GetPrintFrame(blink::WebLocalFrame** frame);
// Script Initiated Printing ------------------------------------------------
// Notifies the browser a print preview page has been rendered.
@ -373,6 +371,7 @@ class PrintWebViewHelper
bool print_node_in_progress_;
bool is_loading_;
bool is_scripted_preview_delayed_;
int ipc_nesting_level_;
PrintPreviewContext print_preview_context_;

Просмотреть файл

@ -22,7 +22,7 @@
namespace printing {
using blink::WebFrame;
using blink::WebLocalFrame;
bool PrintWebViewHelper::RenderPreviewPage(
int page_number,
@ -56,7 +56,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
return PreviewPageRendered(page_number, draft_metafile.get());
}
bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
int page_count) {
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
if (!metafile.Init())
@ -113,7 +113,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
void PrintWebViewHelper::PrintPageInternal(
const PrintMsg_PrintPage_Params& params,
WebFrame* frame,
WebLocalFrame* frame,
PdfMetafileSkia* metafile) {
PageSizeMargins page_layout_in_points;
double scale_factor = 1.0f;

Просмотреть файл

@ -18,11 +18,11 @@
namespace printing {
using blink::WebFrame;
using blink::WebLocalFrame;
void PrintWebViewHelper::PrintPageInternal(
const PrintMsg_PrintPage_Params& params,
WebFrame* frame) {
WebLocalFrame* frame) {
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
CHECK(metafile.Init());
@ -89,7 +89,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
int page_number,
WebFrame* frame,
WebLocalFrame* frame,
bool is_preview,
PdfMetafileSkia* metafile,
gfx::Size* page_size,

Просмотреть файл

@ -20,7 +20,7 @@
namespace printing {
using blink::WebFrame;
using blink::WebLocalFrame;
bool PrintWebViewHelper::RenderPreviewPage(
int page_number,
@ -55,7 +55,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
return PreviewPageRendered(page_number, draft_metafile.get());
}
bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
int page_count) {
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
if (!metafile.Init())
@ -122,7 +122,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
void PrintWebViewHelper::PrintPageInternal(
const PrintMsg_PrintPage_Params& params,
WebFrame* frame,
WebLocalFrame* frame,
PdfMetafileSkia* metafile,
gfx::Size* page_size_in_dpi,
gfx::Rect* content_area_in_dpi) {