Fix API changes of Chrome 53

This commit is contained in:
Cheng Zhao 2016-09-06 17:24:37 +09:00
parent 2e0a1a8a64
commit f28e8d7168
52 changed files with 301 additions and 173 deletions

View file

@ -7,12 +7,13 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/node_includes.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "content/public/browser/tracing_controller.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
using content::TracingController;
namespace mate {

View file

@ -9,7 +9,6 @@
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "content/public/browser/devtools_agent_host.h"
@ -17,6 +16,8 @@
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "atom/common/node_includes.h"
using content::DevToolsAgentHost;
namespace atom {
@ -107,7 +108,7 @@ bool Debugger::IsAttached() {
void Debugger::Detach() {
if (!agent_host_.get())
return;
agent_host_->DetachClient();
agent_host_->DetachClient(this);
AgentHostClosed(agent_host_.get(), false);
agent_host_ = nullptr;
}
@ -136,7 +137,7 @@ void Debugger::SendCommand(mate::Arguments* args) {
std::string json_args;
base::JSONWriter::Write(request, &json_args);
agent_host_->DispatchProtocolMessage(json_args);
agent_host_->DispatchProtocolMessage(this, json_args);
}
// static

View file

@ -6,18 +6,19 @@
#include <string>
#include "atom/common/node_includes.h"
#include "content/public/browser/power_save_blocker.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h"
namespace mate {
template<>
struct Converter<content::PowerSaveBlocker::PowerSaveBlockerType> {
struct Converter<device::PowerSaveBlocker::PowerSaveBlockerType> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
content::PowerSaveBlocker::PowerSaveBlockerType* out) {
using content::PowerSaveBlocker;
device::PowerSaveBlocker::PowerSaveBlockerType* out) {
using device::PowerSaveBlocker;
std::string type;
if (!ConvertFromV8(isolate, val, &type))
return false;
@ -39,7 +40,7 @@ namespace api {
PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
: current_blocker_type_(
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) {
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) {
Init(isolate);
}
@ -58,30 +59,34 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
// higher precedence level than |kPowerSaveBlockPreventAppSuspension|.
//
// Only the highest-precedence blocker type takes effect.
content::PowerSaveBlocker::PowerSaveBlockerType new_blocker_type =
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension;
device::PowerSaveBlocker::PowerSaveBlockerType new_blocker_type =
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension;
for (const auto& element : power_save_blocker_types_) {
if (element.second ==
content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep) {
device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep) {
new_blocker_type =
content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
break;
}
}
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
std::unique_ptr<content::PowerSaveBlocker> new_blocker =
content::PowerSaveBlocker::Create(
std::unique_ptr<device::PowerSaveBlocker> new_blocker(
new device::PowerSaveBlocker(
new_blocker_type,
content::PowerSaveBlocker::kReasonOther,
ATOM_PRODUCT_NAME);
device::PowerSaveBlocker::kReasonOther,
ATOM_PRODUCT_NAME,
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE)));
power_save_blocker_.swap(new_blocker);
current_blocker_type_ = new_blocker_type;
}
}
int PowerSaveBlocker::Start(
content::PowerSaveBlocker::PowerSaveBlockerType type) {
device::PowerSaveBlocker::PowerSaveBlockerType type) {
static int count = 0;
power_save_blocker_types_[count] = type;
UpdatePowerSaveBlocker();

View file

@ -9,7 +9,7 @@
#include <memory>
#include "atom/browser/api/trackable_object.h"
#include "content/public/browser/power_save_blocker.h"
#include "device/power_save_blocker/power_save_blocker.h"
#include "native_mate/handle.h"
namespace mate {
@ -33,18 +33,18 @@ class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {
private:
void UpdatePowerSaveBlocker();
int Start(content::PowerSaveBlocker::PowerSaveBlockerType type);
int Start(device::PowerSaveBlocker::PowerSaveBlockerType type);
bool Stop(int id);
bool IsStarted(int id);
std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_;
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
// Currnet blocker type used by |power_save_blocker_|
content::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;
device::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;
// Map from id to the corresponding blocker type for each request.
using PowerSaveBlockerTypeMap =
std::map<int, content::PowerSaveBlocker::PowerSaveBlockerType>;
std::map<int, device::PowerSaveBlocker::PowerSaveBlockerType>;
PowerSaveBlockerTypeMap power_save_blocker_types_;
DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);

View file

@ -7,11 +7,12 @@
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "content/public/browser/render_process_host.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {

View file

@ -37,7 +37,6 @@
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@ -77,6 +76,8 @@
#include "ui/aura/window.h"
#endif
#include "atom/common/node_includes.h"
namespace {
struct PrintSettings {
@ -871,7 +872,8 @@ void WebContents::DownloadURL(const GURL& url) {
content::BrowserContext::GetDownloadManager(browser_context);
download_manager->DownloadUrl(
content::DownloadUrlParameters::FromWebContents(web_contents(), url));
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents(), url));
}
GURL WebContents::GetURL() const {
@ -1177,7 +1179,7 @@ void WebContents::ShowDefinitionForSelection() {
}
void WebContents::CopyImageAt(int x, int y) {
const auto host = web_contents()->GetRenderViewHost();
const auto host = web_contents()->GetMainFrame();
if (host)
host->CopyImageAt(x, y);
}

View file

@ -14,7 +14,6 @@
#include "atom/common/native_mate_converters/gurl_converter.h"
#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 "atom/common/options_switches.h"
#include "base/command_line.h"
#include "content/public/browser/render_process_host.h"
@ -31,6 +30,8 @@
#include "atom/browser/ui/win/taskbar_host.h"
#endif
#include "atom/common/node_includes.h"
#if defined(OS_WIN)
namespace mate {

View file

@ -5,10 +5,11 @@
#include "atom/browser/api/frame_subscriber.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/node_includes.h"
#include "base/bind.h"
#include "content/public/browser/render_widget_host.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {

View file

@ -32,6 +32,7 @@
#include "chrome/browser/speech/tts_message_filter.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"
@ -53,6 +54,19 @@ 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>) {
}
@ -99,8 +113,9 @@ content::SpeechRecognitionManagerDelegate*
return new AtomSpeechRecognitionManagerDelegate;
}
content::AccessTokenStore* AtomBrowserClient::CreateAccessTokenStore() {
return new AtomAccessTokenStore;
content::GeolocationDelegate*
AtomBrowserClient::CreateGeolocationDelegate() {
return new AtomGeolocationDelegate();
}
void AtomBrowserClient::OverrideWebkitPrefs(

View file

@ -49,7 +49,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override;
content::AccessTokenStore* CreateAccessTokenStore() override;
content::GeolocationDelegate* CreateGeolocationDelegate() override;
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
content::WebPreferences* prefs) override;
std::string GetApplicationLocale() override;

View file

@ -10,8 +10,17 @@
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
#include "net/ssl/client_cert_store.h"
#include "url/gurl.h"
#if defined(USE_NSS_CERTS)
#include "net/ssl/client_cert_store_nss.h"
#elif defined(OS_WIN)
#include "net/ssl/client_cert_store_win.h"
#elif defined(OS_MACOSX)
#include "net/ssl/client_cert_store_mac.h"
#endif
using content::BrowserThread;
namespace atom {
@ -59,7 +68,8 @@ bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol(
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
bool is_main_frame,
ui::PageTransition transition,
bool has_user_gesture) {
bool has_user_gesture,
content::ResourceContext* resource_context) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&HandleExternalProtocolInUI,
url,
@ -75,4 +85,19 @@ AtomResourceDispatcherHostDelegate::CreateLoginDelegate(
return new LoginHandler(auth_info, request);
}
std::unique_ptr<net::ClientCertStore>
AtomResourceDispatcherHostDelegate::CreateClientCertStore(
content::ResourceContext* resource_context) {
#if defined(USE_NSS_CERTS)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS(
net::ClientCertStoreNSS::PasswordDelegateFactory()));
#elif defined(OS_WIN)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
#elif defined(OS_MACOSX)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac());
#elif defined(USE_OPENSSL)
return std::unique_ptr<net::ClientCertStore>();
#endif
}
} // namespace atom

View file

@ -21,10 +21,13 @@ class AtomResourceDispatcherHostDelegate
const content::ResourceRequestInfo::WebContentsGetter&,
bool is_main_frame,
ui::PageTransition transition,
bool has_user_gesture) override;
bool has_user_gesture,
content::ResourceContext* resource_context) override;
content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
net::AuthChallengeInfo* auth_info,
net::URLRequest* request) override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
content::ResourceContext* resource_context) override;
};
} // namespace atom

View file

@ -27,7 +27,7 @@ bool BridgeTaskRunner::PostDelayedTask(
base::TimeDelta delay) {
auto message_loop = base::MessageLoop::current();
if (!message_loop) {
tasks_.push_back(base::MakeTuple(from_here, task, delay));
tasks_.push_back(std::make_tuple(from_here, task, delay));
return true;
}
@ -48,7 +48,7 @@ bool BridgeTaskRunner::PostNonNestableDelayedTask(
base::TimeDelta delay) {
auto message_loop = base::MessageLoop::current();
if (!message_loop) {
non_nestable_tasks_.push_back(base::MakeTuple(from_here, task, delay));
non_nestable_tasks_.push_back(std::make_tuple(from_here, task, delay));
return true;
}

View file

@ -5,6 +5,7 @@
#ifndef ATOM_BROWSER_BRIDGE_TASK_RUNNER_H_
#define ATOM_BROWSER_BRIDGE_TASK_RUNNER_H_
#include <tuple>
#include <vector>
#include "base/single_thread_task_runner.h"
@ -33,7 +34,7 @@ class BridgeTaskRunner : public base::SingleThreadTaskRunner {
base::TimeDelta delay) override;
private:
using TaskPair = base::Tuple<
using TaskPair = std::tuple<
tracked_objects::Location, base::Closure, base::TimeDelta>;
std::vector<TaskPair> tasks_;
std::vector<TaskPair> non_nestable_tasks_;

View file

@ -252,11 +252,11 @@ content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
}
void CommonWebContentsDelegate::RunFileChooser(
content::WebContents* guest,
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
if (!web_dialog_helper_)
web_dialog_helper_.reset(new WebDialogHelper(owner_window()));
web_dialog_helper_->RunFileChooser(guest, params);
web_dialog_helper_->RunFileChooser(render_frame_host, params);
}
void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,

View file

@ -71,7 +71,7 @@ class CommonWebContentsDelegate
content::WebContents* web_contents,
SkColor color,
const std::vector<content::ColorSuggestion>& suggestions) override;
void RunFileChooser(content::WebContents* web_contents,
void RunFileChooser(content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) override;
void EnumerateDirectory(content::WebContents* web_contents,
int request_id,

View file

@ -33,6 +33,7 @@
#include "content/public/common/content_switches.h"
#include "ipc/ipc_message_macros.h"
#include "native_mate/dictionary.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"

View file

@ -22,6 +22,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "native_mate/dictionary.h"
#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/skia_util.h"
namespace {
@ -1009,8 +1010,8 @@ bool NativeWindowMac::IsKiosk() {
void NativeWindowMac::SetBackgroundColor(const std::string& color_name) {
SkColor color = ParseHexColor(color_name);
base::ScopedCFTypeRef<CGColorRef> cgcolor =
skia::CGColorCreateFromSkColor(color);
base::ScopedCFTypeRef<CGColorRef> cgcolor(
skia::CGColorCreateFromSkColor(color));
[[[window_ contentView] layer] setBackgroundColor:cgcolor];
const auto view = web_contents()->GetRenderWidgetHostView();

View file

@ -40,10 +40,7 @@ void AtomCertVerifier::SetVerifyProc(const VerifyProc& proc) {
}
int AtomCertVerifier::Verify(
net::X509Certificate* cert,
const std::string& hostname,
const std::string& ocsp_response,
int flags,
const RequestParams& params,
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,
@ -53,12 +50,11 @@ int AtomCertVerifier::Verify(
if (verify_proc_.is_null())
return default_cert_verifier_->Verify(
cert, hostname, ocsp_response, flags, crl_set, verify_result, callback,
out_req, net_log);
params, crl_set, verify_result, callback, out_req, net_log);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(verify_proc_, hostname, make_scoped_refptr(cert),
base::Bind(verify_proc_, params.hostname(), params.certificate(),
base::Bind(OnResult, verify_result, callback)));
return net::ERR_IO_PENDING;
}

View file

@ -26,10 +26,7 @@ class AtomCertVerifier : public net::CertVerifier {
protected:
// net::CertVerifier:
int Verify(net::X509Certificate* cert,
const std::string& hostname,
const std::string& ocsp_response,
int flags,
int Verify(const RequestParams& params,
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,

View file

@ -239,7 +239,7 @@ int AtomNetworkDelegate::OnBeforeURLRequest(
return HandleResponseEvent(kOnBeforeRequest, request, callback, new_url);
}
int AtomNetworkDelegate::OnBeforeSendHeaders(
int AtomNetworkDelegate::OnBeforeStartTransaction(
net::URLRequest* request,
const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) {
@ -254,18 +254,18 @@ int AtomNetworkDelegate::OnBeforeSendHeaders(
DevToolsNetworkTransaction::kDevToolsEmulateNetworkConditionsClientId,
client_id);
if (!ContainsKey(response_listeners_, kOnBeforeSendHeaders))
return brightray::NetworkDelegate::OnBeforeSendHeaders(
return brightray::NetworkDelegate::OnBeforeStartTransaction(
request, callback, headers);
return HandleResponseEvent(
kOnBeforeSendHeaders, request, callback, headers, *headers);
}
void AtomNetworkDelegate::OnSendHeaders(
void AtomNetworkDelegate::OnStartTransaction(
net::URLRequest* request,
const net::HttpRequestHeaders& headers) {
if (!ContainsKey(simple_listeners_, kOnSendHeaders)) {
brightray::NetworkDelegate::OnSendHeaders(request, headers);
brightray::NetworkDelegate::OnStartTransaction(request, headers);
return;
}

View file

@ -77,11 +77,11 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
int OnBeforeURLRequest(net::URLRequest* request,
const net::CompletionCallback& callback,
GURL* new_url) override;
int OnBeforeSendHeaders(net::URLRequest* request,
const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) override;
void OnSendHeaders(net::URLRequest* request,
const net::HttpRequestHeaders& headers) override;
int OnBeforeStartTransaction(net::URLRequest* request,
const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) override;
void OnStartTransaction(net::URLRequest* request,
const net::HttpRequestHeaders& headers) override;
int OnHeadersReceived(
net::URLRequest* request,
const net::CompletionCallback& callback,

View file

@ -302,10 +302,9 @@ class AtomBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
AtomBeginFrameTimer(int frame_rate_threshold_ms,
const base::Closure& callback)
: callback_(callback) {
time_source_ = cc::DelayBasedTimeSource::Create(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms),
time_source_.reset(new cc::DelayBasedTimeSource(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI).get());
content::BrowserThread::UI).get()));
time_source_->SetClient(this);
}
@ -522,21 +521,17 @@ bool OffScreenRenderWidgetHostView::LockMouse() {
void OffScreenRenderWidgetHostView::UnlockMouse() {
}
bool OffScreenRenderWidgetHostView::GetScreenColorProfile(std::vector<char>*) {
return false;
}
void OffScreenRenderWidgetHostView::OnSwapCompositorFrame(
uint32_t output_surface_id,
std::unique_ptr<cc::CompositorFrame> frame) {
cc::CompositorFrame frame) {
TRACE_EVENT0("electron",
"OffScreenRenderWidgetHostView::OnSwapCompositorFrame");
if (frame->metadata.root_scroll_offset != last_scroll_offset_) {
last_scroll_offset_ = frame->metadata.root_scroll_offset;
if (frame.metadata.root_scroll_offset != last_scroll_offset_) {
last_scroll_offset_ = frame.metadata.root_scroll_offset;
}
if (frame->delegated_frame_data) {
if (frame.delegated_frame_data) {
if (software_output_device_) {
if (!begin_frame_timer_.get()) {
software_output_device_->SetActive(painting_);
@ -551,7 +546,7 @@ void OffScreenRenderWidgetHostView::OnSwapCompositorFrame(
}
cc::RenderPass* root_pass =
frame->delegated_frame_data->render_pass_list.back().get();
frame.delegated_frame_data->render_pass_list.back().get();
gfx::Size frame_size = root_pass->output_rect.size();
gfx::Rect damage_rect =
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));

View file

@ -36,7 +36,6 @@
#if defined(OS_MACOSX)
#include "content/browser/renderer_host/browser_compositor_view_mac.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#endif
#if defined(OS_MACOSX)
@ -54,11 +53,12 @@ namespace atom {
class AtomCopyFrameGenerator;
class AtomBeginFrameTimer;
#if defined(OS_MACOSX)
class MacHelper;
#endif
class OffScreenRenderWidgetHostView
: public content::RenderWidgetHostViewBase,
#if defined(OS_MACOSX)
public ui::AcceleratedWidgetMacNSView,
#endif
public ui::CompositorDelegate,
public content::DelegatedFrameHostClient {
public:
@ -90,7 +90,6 @@ class OffScreenRenderWidgetHostView
void SetBackgroundColor(SkColor color) override;
bool LockMouse(void) override;
void UnlockMouse(void) override;
bool GetScreenColorProfile(std::vector<char>*) override;
#if defined(OS_MACOSX)
ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override;
void SetActive(bool active) override;
@ -102,7 +101,7 @@ class OffScreenRenderWidgetHostView
#endif // defined(OS_MACOSX)
// content::RenderWidgetHostViewBase:
void OnSwapCompositorFrame(uint32_t, std::unique_ptr<cc::CompositorFrame>)
void OnSwapCompositorFrame(uint32_t, cc::CompositorFrame)
override;
void ClearCompositorFrame(void) override;
void InitAsPopup(content::RenderWidgetHostView *rwhv, const gfx::Rect& rect)
@ -173,14 +172,6 @@ class OffScreenRenderWidgetHostView
bool IsAutoResizeEnabled() const;
void OnSetNeedsBeginFrames(bool enabled);
#if defined(OS_MACOSX)
// ui::AcceleratedWidgetMacNSView:
NSView* AcceleratedWidgetGetNSView() const override;
void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override;
void AcceleratedWidgetSwapCompleted() override;
#endif // defined(OS_MACOSX)
void OnBeginFrameTimerTick();
void SendBeginFrame(base::TimeTicks frame_time,
base::TimeDelta vsync_period);
@ -201,6 +192,7 @@ class OffScreenRenderWidgetHostView
ui::Compositor* compositor() const { return compositor_.get(); }
content::RenderWidgetHostImpl* render_widget_host() const
{ return render_widget_host_; }
NativeWindow* window() const { return native_window_; }
private:
void SetupFrameRate(bool force);
@ -233,10 +225,13 @@ class OffScreenRenderWidgetHostView
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
#if defined(OS_MACOSX)
NSWindow* window_;
CALayer* background_layer_;
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
// Can not be managed by smart pointer because its header can not be included
// in the file that has the destructor.
MacHelper* nsview_;
// Selected text on the renderer.
std::string selected_text_;
#endif

View file

@ -7,48 +7,115 @@
#import <Cocoa/Cocoa.h>
#include "base/strings/utf_string_conversions.h"
#include "content/common/view_messages.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
namespace atom {
class MacHelper :
public content::BrowserCompositorMacClient,
public ui::AcceleratedWidgetMacNSView {
public:
explicit MacHelper(OffScreenRenderWidgetHostView* view) : view_(view) {}
virtual ~MacHelper() {}
// content::BrowserCompositorMacClient:
NSView* BrowserCompositorMacGetNSView() const override {
// Intentionally return nil so that
// BrowserCompositorMac::DelegatedFrameHostDesiredSizeInDIP uses the layer
// size instead of the NSView size.
return nil;
}
SkColor BrowserCompositorMacGetGutterColor(SkColor color) const override {
// When making an element on the page fullscreen the element's background
// may not match the page's, so use black as the gutter color to avoid
// flashes of brighter colors during the transition.
if (view_->render_widget_host()->delegate() &&
view_->render_widget_host()->delegate()->IsFullscreenForCurrentTab()) {
return SK_ColorBLACK;
}
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 {
view_->render_widget_host()->Send(new ViewMsg_ReclaimCompositorResources(
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
}
void BrowserCompositorMacOnLostCompositorResources() override {
view_->render_widget_host()->ScheduleComposite();
}
void BrowserCompositorMacUpdateVSyncParameters(
const base::TimeTicks& timebase,
const base::TimeDelta& interval) override {
view_->render_widget_host()->UpdateVSyncParameters(timebase, interval);
}
void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send(
new ViewMsg_BeginFrame(view_->render_widget_host()->GetRoutingID(),
args));
}
// ui::AcceleratedWidgetMacNSView:
NSView* AcceleratedWidgetGetNSView() const override {
return [view_->window()->GetNativeWindow() contentView];
}
void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override {
*timebase = base::TimeTicks();
*interval = base::TimeDelta();
}
void AcceleratedWidgetSwapCompleted() override {
}
private:
OffScreenRenderWidgetHostView* view_;
DISALLOW_COPY_AND_ASSIGN(MacHelper);
};
ui::AcceleratedWidgetMac*
atom::OffScreenRenderWidgetHostView::GetAcceleratedWidgetMac() const {
OffScreenRenderWidgetHostView::GetAcceleratedWidgetMac() const {
if (browser_compositor_)
return browser_compositor_->accelerated_widget_mac();
return browser_compositor_->GetAcceleratedWidgetMac();
return nullptr;
}
NSView* atom::OffScreenRenderWidgetHostView::AcceleratedWidgetGetNSView() const {
return [native_window_->GetNativeWindow() contentView];
void OffScreenRenderWidgetHostView::SetActive(bool active) {
}
void atom::OffScreenRenderWidgetHostView::AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const {
*timebase = base::TimeTicks();
*interval = base::TimeDelta();
void OffScreenRenderWidgetHostView::ShowDefinitionForSelection() {
}
void atom::OffScreenRenderWidgetHostView::AcceleratedWidgetSwapCompleted() {
}
void atom::OffScreenRenderWidgetHostView::SetActive(bool active) {
}
void atom::OffScreenRenderWidgetHostView::ShowDefinitionForSelection() {
}
bool atom::OffScreenRenderWidgetHostView::SupportsSpeech() const {
bool OffScreenRenderWidgetHostView::SupportsSpeech() const {
return false;
}
void atom::OffScreenRenderWidgetHostView::SpeakSelection() {
void OffScreenRenderWidgetHostView::SpeakSelection() {
}
bool atom::OffScreenRenderWidgetHostView::IsSpeaking() const {
bool OffScreenRenderWidgetHostView::IsSpeaking() const {
return false;
}
void atom::OffScreenRenderWidgetHostView::StopSpeaking() {
void OffScreenRenderWidgetHostView::StopSpeaking() {
}
void atom::OffScreenRenderWidgetHostView::SelectionChanged(
void OffScreenRenderWidgetHostView::SelectionChanged(
const base::string16& text,
size_t offset,
const gfx::Range& range) {
@ -69,24 +136,15 @@ void atom::OffScreenRenderWidgetHostView::SelectionChanged(
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
}
void atom::OffScreenRenderWidgetHostView::CreatePlatformWidget() {
browser_compositor_ = content::BrowserCompositorMac::Create();
compositor_.reset(browser_compositor_->compositor());
compositor_->SetRootLayer(root_layer_.get());
browser_compositor_->accelerated_widget_mac()->SetNSView(this);
browser_compositor_->compositor()->SetVisible(true);
compositor_->SetLocksWillTimeOut(true);
browser_compositor_->Unsuspend();
void OffScreenRenderWidgetHostView::CreatePlatformWidget() {
nsview_ = new MacHelper(this);
browser_compositor_.reset(new content::BrowserCompositorMac(
nsview_, nsview_, render_widget_host_->is_hidden(), true));
}
void atom::OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
ui::Compositor* compositor = compositor_.release();
ALLOW_UNUSED_LOCAL(compositor);
browser_compositor_->accelerated_widget_mac()->ResetNSView();
browser_compositor_->compositor()->SetVisible(false);
browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0));
browser_compositor_->compositor()->SetRootLayer(NULL);
void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
browser_compositor_.reset();
delete nsview_;
}
} // namespace

View file

@ -4,6 +4,8 @@
#include "atom/browser/osr/osr_web_contents_view.h"
#import <Cocoa/Cocoa.h>
@interface OffScreenView : NSView
@end

View file

@ -16,9 +16,11 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/render_frame_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"
@ -75,8 +77,9 @@ WebDialogHelper::~WebDialogHelper() {
}
void WebDialogHelper::RunFileChooser(content::WebContents* web_contents,
const content::FileChooserParams& params) {
void WebDialogHelper::RunFileChooser(
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
std::vector<content::FileChooserFileInfo> result;
file_dialog::Filters filters = GetFileTypesFromAcceptType(
params.accept_types);
@ -133,8 +136,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents,
}
}
web_contents->GetRenderViewHost()->FilesSelectedInChooser(
result, params.mode);
render_frame_host->FilesSelectedInChooser(result, params.mode);
}
void WebDialogHelper::EnumerateDirectory(content::WebContents* web_contents,

View file

@ -13,6 +13,7 @@ class FilePath;
namespace content {
struct FileChooserParams;
class RenderFrameHost;
class WebContents;
}
@ -25,7 +26,7 @@ class WebDialogHelper {
explicit WebDialogHelper(NativeWindow* window);
~WebDialogHelper();
void RunFileChooser(content::WebContents* web_contents,
void RunFileChooser(content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params);
void EnumerateDirectory(content::WebContents* web_contents,
int request_id,

View file

@ -11,7 +11,6 @@
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/node_includes.h"
#include "base/base64.h"
#include "base/files/file_util.h"
#include "base/strings/pattern.h"
@ -33,6 +32,8 @@
#include "ui/gfx/icon_util.h"
#endif
#include "atom/common/node_includes.h"
namespace atom {
namespace api {

View file

@ -12,8 +12,7 @@ namespace atom {
ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate,
v8::Local<v8::Object> target)
: isolate_(isolate),
context_(isolate, isolate->GetCurrentContext()),
: context_(isolate, isolate->GetCurrentContext()),
target_(isolate, target),
weak_ptr_factory_(this) {
target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter);

View file

@ -22,7 +22,6 @@ class ObjectLifeMonitor {
static void OnObjectGC(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
static void Free(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
v8::Isolate* isolate_;
v8::Global<v8::Context> context_;
v8::Global<v8::Object> target_;

View file

@ -238,7 +238,6 @@ bool Converter<blink::WebMouseWheelEvent>::FromV8(
dict.Get("accelerationRatioX", &out->accelerationRatioX);
dict.Get("accelerationRatioY", &out->accelerationRatioY);
dict.Get("hasPreciseScrollingDeltas", &out->hasPreciseScrollingDeltas);
dict.Get("canScroll", &out->canScroll);
return true;
}

View file

@ -9,7 +9,6 @@
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "native_mate/dictionary.h"
@ -21,6 +20,8 @@
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#include "atom/common/node_includes.h"
namespace mate {
// static

View file

@ -375,7 +375,7 @@ base::Value* V8ValueConverter::FromNodeBuffer(
FromV8ValueState* state,
v8::Isolate* isolate) const {
return base::BinaryValue::CreateWithCopiedBuffer(
node::Buffer::Data(value), node::Buffer::Length(value));
node::Buffer::Data(value), node::Buffer::Length(value)).release();
}
base::Value* V8ValueConverter::FromV8Object(

View file

@ -103,7 +103,6 @@ AtomRenderViewObserver::AtomRenderViewObserver(
content::RenderView* render_view,
AtomRendererClient* renderer_client)
: content::RenderViewObserver(render_view),
renderer_client_(renderer_client),
document_created_(false) {
// Initialise resource for directory listing.
net::NetModule::SetResourceProvider(NetResourceProvider);
@ -151,6 +150,10 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
return handled;
}
void AtomRenderViewObserver::OnDestruct() {
delete this;
}
void AtomRenderViewObserver::OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args) {

View file

@ -29,14 +29,12 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
void DidCreateDocumentElement(blink::WebLocalFrame* frame) override;
void DraggableRegionsChanged(blink::WebFrame* frame) override;
bool OnMessageReceived(const IPC::Message& message) override;
void OnDestruct() override;
void OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args);
// Weak reference to renderer client.
AtomRendererClient* renderer_client_;
// Whether the document object has been created.
bool document_created_;

View file

@ -13,7 +13,6 @@
#include "atom/common/color_util.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_bindings.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "atom/renderer/atom_render_view_observer.h"
#include "atom/renderer/guest_view_container.h"
@ -51,6 +50,8 @@
#include <shlobj.h>
#endif
#include "atom/common/node_includes.h"
namespace atom {
namespace {
@ -85,6 +86,10 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
renderer_client_->WillReleaseScriptContext(context, render_frame_);
}
void OnDestruct() override {
delete this;
}
private:
content::RenderFrame* render_frame_;
int world_id_;

View file

@ -22,8 +22,7 @@ static base::LazyInstance<GuestViewContainerMap> g_guest_view_container_map =
} // namespace
GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame)
: render_frame_(render_frame),
weak_ptr_factory_(this) {
: weak_ptr_factory_(this) {
}
GuestViewContainer::~GuestViewContainer() {

View file

@ -32,7 +32,6 @@ class GuestViewContainer : public content::BrowserPluginDelegate {
private:
int element_instance_id_;
content::RenderFrame* render_frame_;
ResizeCallback element_resize_callback_;

View file

@ -97,7 +97,8 @@ class NativeDesktopMediaList::Worker
typedef std::map<DesktopMediaID, uint32> ImageHashesMap;
// webrtc::DesktopCapturer::Callback interface.
void OnCaptureCompleted(webrtc::DesktopFrame* frame) override;
void OnCaptureResult(webrtc::DesktopCapturer::Result result,
std::unique_ptr<webrtc::DesktopFrame> frame) override;
base::WeakPtr<NativeDesktopMediaList> media_list_;
@ -217,9 +218,10 @@ void NativeDesktopMediaList::Worker::Refresh(
base::Bind(&NativeDesktopMediaList::OnRefreshFinished, media_list_));
}
void NativeDesktopMediaList::Worker::OnCaptureCompleted(
webrtc::DesktopFrame* frame) {
current_frame_.reset(frame);
void NativeDesktopMediaList::Worker::OnCaptureResult(
webrtc::DesktopCapturer::Result result,
std::unique_ptr<webrtc::DesktopFrame> frame) {
current_frame_ = std::move(frame);
}
NativeDesktopMediaList::NativeDesktopMediaList(

View file

@ -133,7 +133,8 @@ void PrintViewManagerBase::OnDidPrintPage(
}
}
std::unique_ptr<PdfMetafileSkia> metafile(new PdfMetafileSkia);
std::unique_ptr<PdfMetafileSkia> metafile(
new PdfMetafileSkia(PDF_SKIA_DOCUMENT_TYPE));
if (metafile_must_be_valid) {
if (!metafile->InitFromData(shared_buf.memory(), params.data_size)) {
NOTREACHED() << "Invalid metafile header";

View file

@ -17,6 +17,7 @@
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/widevine_cdm_constants.h"
#include "third_party/widevine/cdm/stub/widevine_cdm_version.h"
#include "third_party/widevine/cdm/widevine_cdm_common.h"
#if defined(OS_ANDROID)
#include "base/android/path_utils.h"

View file

@ -7,9 +7,6 @@
#include "build/build_config.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
const base::FilePath::CharType kWidevineCdmBaseDirectory[] =
FILE_PATH_LITERAL("WidevineCDM");
const char kWidevineCdmPluginExtension[] = "";
const int32_t kWidevineCdmPluginPermissions = ppapi::PERMISSION_DEV |

View file

@ -8,9 +8,6 @@
#include "base/macros.h"
#include "base/files/file_path.h"
// The Widevine CDM adapter and Widevine CDM are in this directory.
extern const base::FilePath::CharType kWidevineCdmBaseDirectory[];
extern const char kWidevineCdmPluginExtension[];
// Permission bits for Widevine CDM plugin.

View file

@ -241,6 +241,7 @@ static void AddPepperBasedWidevine(
#endif // defined(USE_PROPRIETARY_CODECS)
}
using Robustness = cdm::WidevineKeySystemProperties::Robustness;
concrete_key_systems->emplace_back(new cdm::WidevineKeySystemProperties(
supported_codecs,
#if defined(OS_CHROMEOS)
@ -253,8 +254,8 @@ static void AddPepperBasedWidevine(
media::EmeFeatureSupport::REQUESTABLE, // Persistent state.
media::EmeFeatureSupport::REQUESTABLE)); // Distinctive identifier.
#else // (Desktop)
media::EmeRobustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
media::EmeRobustness::SW_SECURE_DECODE, // Maximum video robustness.
Robustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
Robustness::SW_SECURE_DECODE, // Maximum video robustness.
media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
media::EmeSessionTypeSupport::
NOT_SUPPORTED, // persistent-release-message.

View file

@ -205,8 +205,8 @@ int32_t PepperFlashRendererHost::OnDrawGlyphs(
style |= SkTypeface::kBold;
if (params.font_desc.italic)
style |= SkTypeface::kItalic;
sk_sp<SkTypeface> typeface(SkTypeface::CreateFromName(
params.font_desc.face.c_str(), static_cast<SkTypeface::Style>(style)));
sk_sp<SkTypeface> typeface(SkTypeface::MakeFromName(
params.font_desc.face.c_str(), SkFontStyle::FromOldStyle(style)));
if (!typeface)
return PP_ERROR_FAILED;

View file

@ -24,3 +24,7 @@ void PepperHelper::DidCreatePepperPlugin(content::RendererPpapiHost* host) {
std::unique_ptr<ppapi::host::InstanceMessageFilter>(
new PepperSharedMemoryMessageFilter(host)));
}
void PepperHelper::OnDestruct() {
delete this;
}

View file

@ -17,6 +17,7 @@ class PepperHelper : public content::RenderFrameObserver {
// RenderFrameObserver.
void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
void OnDestruct() override;
private:
DISALLOW_COPY_AND_ASSIGN(PepperHelper);

View file

@ -545,7 +545,8 @@ void PrepareFrameAndViewForPrint::CopySelection(
WebPreferences prefs = preferences;
prefs.javascript_enabled = false;
blink::WebView* web_view = blink::WebView::create(this);
blink::WebView* web_view =
blink::WebView::create(this, blink::WebPageVisibilityStateVisible);
owns_web_view_ = true;
content::RenderView::ApplyWebPreferences(prefs, web_view);
web_view->setMainFrame(
@ -662,6 +663,10 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
return handled;
}
void PrintWebViewHelper::OnDestruct() {
delete this;
}
bool PrintWebViewHelper::GetPrintFrame(blink::WebLocalFrame** frame) {
DCHECK(frame);
blink::WebView* webView = render_view()->GetWebView();
@ -1266,7 +1271,7 @@ bool PrintWebViewHelper::PrintPreviewContext::CreatePreviewDocument(
return false;
}
metafile_.reset(new PdfMetafileSkia);
metafile_.reset(new PdfMetafileSkia(PDF_SKIA_DOCUMENT_TYPE));
CHECK(metafile_->Init());
current_page_index_ = 0;

View file

@ -92,9 +92,9 @@ class PrintWebViewHelper
};
// RenderViewObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) override;
virtual void PrintPage(blink::WebLocalFrame* frame,
bool user_initiated) override;
bool OnMessageReceived(const IPC::Message& message) override;
void PrintPage(blink::WebLocalFrame* frame, bool user_initiated) override;
void OnDestruct() override;
// Message handlers ---------------------------------------------------------
#if !defined(DISABLE_BASIC_PRINTING)

View file

@ -23,7 +23,7 @@ using blink::WebFrame;
void PrintWebViewHelper::PrintPageInternal(
const PrintMsg_PrintPage_Params& params,
WebFrame* frame) {
PdfMetafileSkia metafile;
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
CHECK(metafile.Init());
int page_number = params.page_number;
@ -61,7 +61,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
is_print_ready_metafile_sent_;
if (render_to_draft) {
draft_metafile.reset(new PdfMetafileSkia());
draft_metafile.reset(new PdfMetafileSkia(PDF_SKIA_DOCUMENT_TYPE));
CHECK(draft_metafile->Init());
initial_render_metafile = draft_metafile.get();
}
@ -80,7 +80,8 @@ bool PrintWebViewHelper::RenderPreviewPage(
print_preview_context_.generate_draft_pages()) {
DCHECK(!draft_metafile.get());
draft_metafile =
print_preview_context_.metafile()->GetMetafileForCurrentPage();
print_preview_context_.metafile()->GetMetafileForCurrentPage(
PDF_SKIA_DOCUMENT_TYPE);
}
}
return PreviewPageRendered(page_number, draft_metafile.get());

View file

@ -228,6 +228,17 @@
}], # OS=="win"
],
}],
['_target_name.startswith("crashpad")', {
'conditions': [
['OS=="mac"', {
'xcode_settings': {
'WARNING_CFLAGS': [
'-Wno-unused-private-field',
],
},
}], # OS=="mac"
],
}],
['_target_name.startswith("breakpad") or _target_name in ["crash_report_sender", "dump_syms"]', {
'conditions': [
['OS=="mac"', {