Merge pull request #4714 from atom/chrome49

Upgrade to Chrome 49
This commit is contained in:
Cheng Zhao 2016-03-11 21:39:52 +09:00
commit 6aec1e6949
145 changed files with 642 additions and 585 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@
/external_binaries/ /external_binaries/
/out/ /out/
/vendor/brightray/vendor/download/ /vendor/brightray/vendor/download/
/vendor/debian_wheezy_amd64-sysroot/
/vendor/debian_wheezy_arm-sysroot/ /vendor/debian_wheezy_arm-sysroot/
/vendor/debian_wheezy_i386-sysroot/ /vendor/debian_wheezy_i386-sysroot/
/vendor/python_26/ /vendor/python_26/

View file

@ -143,7 +143,6 @@
], ],
}, { }, {
'copied_libraries': [ 'copied_libraries': [
'<(libchromiumcontent_dir)/pdf.dll',
'<(libchromiumcontent_dir)/ffmpeg.dll', '<(libchromiumcontent_dir)/ffmpeg.dll',
], ],
}], }],

View file

@ -5,7 +5,7 @@
#ifndef ATOM_APP_ATOM_LIBRARY_MAIN_H_ #ifndef ATOM_APP_ATOM_LIBRARY_MAIN_H_
#define ATOM_APP_ATOM_LIBRARY_MAIN_H_ #define ATOM_APP_ATOM_LIBRARY_MAIN_H_
#include "base/basictypes.h" #include "build/build_config.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
extern "C" { extern "C" {

View file

@ -16,7 +16,7 @@
#include "atom/common/crash_reporter/win/crash_service_main.h" #include "atom/common/crash_reporter/win/crash_service_main.h"
#include "base/environment.h" #include "base/environment.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "content/public/app/startup_helper_win.h" #include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h" #include "sandbox/win/src/sandbox_types.h"
#include "ui/gfx/win/dpi.h" #include "ui/gfx/win/dpi.h"
#elif defined(OS_LINUX) // defined(OS_WIN) #elif defined(OS_LINUX) // defined(OS_WIN)

View file

@ -135,7 +135,7 @@ content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() {
} }
scoped_ptr<brightray::ContentClient> AtomMainDelegate::CreateContentClient() { scoped_ptr<brightray::ContentClient> AtomMainDelegate::CreateContentClient() {
return scoped_ptr<brightray::ContentClient>(new AtomContentClient).Pass(); return scoped_ptr<brightray::ContentClient>(new AtomContentClient);
} }
} // namespace atom } // namespace atom

View file

@ -230,8 +230,7 @@ void App::OnLogin(LoginHandler* login_handler) {
} }
void App::AllowCertificateError( void App::AllowCertificateError(
int pid, content::WebContents* web_contents,
int fid,
int cert_error, int cert_error,
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
@ -241,9 +240,6 @@ void App::AllowCertificateError(
bool expired_previous_decision, bool expired_previous_decision,
const base::Callback<void(bool)>& callback, const base::Callback<void(bool)>& callback,
content::CertificateRequestResultType* request) { content::CertificateRequestResultType* request) {
auto rfh = content::RenderFrameHost::FromID(pid, fid);
auto web_contents = content::WebContents::FromRenderFrameHost(rfh);
v8::Locker locker(isolate()); v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
bool prevent_default = Emit("certificate-error", bool prevent_default = Emit("certificate-error",

View file

@ -52,8 +52,7 @@ class App : public AtomBrowserClient::Delegate,
// content::ContentBrowserClient: // content::ContentBrowserClient:
void AllowCertificateError( void AllowCertificateError(
int render_process_id, content::WebContents* web_contents,
int render_frame_id,
int cert_error, int cert_error,
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,

View file

@ -53,13 +53,7 @@ scoped_refptr<TracingController::TraceDataSink> GetTraceDataSink(
void StopRecording(const base::FilePath& path, void StopRecording(const base::FilePath& path,
const CompletionCallback& callback) { const CompletionCallback& callback) {
TracingController::GetInstance()->DisableRecording( TracingController::GetInstance()->StopTracing(
GetTraceDataSink(path, callback));
}
void CaptureMonitoringSnapshot(const base::FilePath& path,
const CompletionCallback& callback) {
TracingController::GetInstance()->CaptureMonitoringSnapshot(
GetTraceDataSink(path, callback)); GetTraceDataSink(path, callback));
} }
@ -70,13 +64,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
dict.SetMethod("getCategories", base::Bind( dict.SetMethod("getCategories", base::Bind(
&TracingController::GetCategories, controller)); &TracingController::GetCategories, controller));
dict.SetMethod("startRecording", base::Bind( dict.SetMethod("startRecording", base::Bind(
&TracingController::EnableRecording, controller)); &TracingController::StartTracing, controller));
dict.SetMethod("stopRecording", &StopRecording); dict.SetMethod("stopRecording", &StopRecording);
dict.SetMethod("startMonitoring", base::Bind(
&TracingController::EnableMonitoring, controller));
dict.SetMethod("stopMonitoring", base::Bind(
&TracingController::DisableMonitoring, controller));
dict.SetMethod("captureMonitoringSnapshot", &CaptureMonitoringSnapshot);
dict.SetMethod("getTraceBufferUsage", base::Bind( dict.SetMethod("getTraceBufferUsage", base::Bind(
&TracingController::GetTraceBufferUsage, controller)); &TracingController::GetTraceBufferUsage, controller));
dict.SetMethod("setWatchEvent", base::Bind( dict.SetMethod("setWatchEvent", base::Bind(

View file

@ -180,7 +180,8 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
GetCookieStore(getter)->GetCookieMonster()->SetCookieWithDetailsAsync( GetCookieStore(getter)->GetCookieMonster()->SetCookieWithDetailsAsync(
GURL(url), name, value, domain, path, expiration_time, secure, http_only, GURL(url), name, value, domain, path, expiration_time, secure, http_only,
false, net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback)); false, false, false, net::COOKIE_PRIORITY_DEFAULT,
base::Bind(OnSetCookie, callback));
} }
} // namespace } // namespace

View file

@ -5,7 +5,6 @@
#include "atom/browser/api/atom_api_desktop_capturer.h" #include "atom/browser/api/atom_api_desktop_capturer.h"
#include "atom/common/api/atom_api_native_image.h" #include "atom/common/api/atom_api_native_image.h"
#include "atom/common/node_includes.h"
#include "atom/common/native_mate_converters/gfx_converter.h" #include "atom/common/native_mate_converters/gfx_converter.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/media/desktop_media_list.h" #include "chrome/browser/media/desktop_media_list.h"
@ -14,6 +13,8 @@
#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
#include "third_party/webrtc/modules/desktop_capture/window_capturer.h" #include "third_party/webrtc/modules/desktop_capture/window_capturer.h"
#include "atom/common/node_includes.h"
namespace mate { namespace mate {
template<> template<>
@ -63,8 +64,8 @@ void DesktopCapturer::StartHandling(bool capture_window,
capture_screen ? webrtc::ScreenCapturer::Create(options) : nullptr); capture_screen ? webrtc::ScreenCapturer::Create(options) : nullptr);
scoped_ptr<webrtc::WindowCapturer> window_capturer( scoped_ptr<webrtc::WindowCapturer> window_capturer(
capture_window ? webrtc::WindowCapturer::Create(options) : nullptr); capture_window ? webrtc::WindowCapturer::Create(options) : nullptr);
media_list_.reset(new NativeDesktopMediaList(screen_capturer.Pass(), media_list_.reset(new NativeDesktopMediaList(
window_capturer.Pass())); std::move(screen_capturer), std::move(window_capturer)));
media_list_->SetThumbnailSize(thumbnail_size); media_list_->SetThumbnailSize(thumbnail_size);
media_list_->StartUpdating(this); media_list_->StartUpdating(this);

View file

@ -53,7 +53,7 @@ namespace {
using WrapDownloadItemCallback = base::Callback<void(v8::Local<v8::Value>)>; using WrapDownloadItemCallback = base::Callback<void(v8::Local<v8::Value>)>;
WrapDownloadItemCallback g_wrap_download_item; WrapDownloadItemCallback g_wrap_download_item;
std::map<uint32, linked_ptr<v8::Global<v8::Value>>> g_download_item_objects; std::map<uint32_t, linked_ptr<v8::Global<v8::Value>>> g_download_item_objects;
} // namespace } // namespace
@ -106,11 +106,11 @@ void DownloadItem::Cancel() {
download_item_->Remove(); download_item_->Remove();
} }
int64 DownloadItem::GetReceivedBytes() const { int64_t DownloadItem::GetReceivedBytes() const {
return download_item_->GetReceivedBytes(); return download_item_->GetReceivedBytes();
} }
int64 DownloadItem::GetTotalBytes() const { int64_t DownloadItem::GetTotalBytes() const {
return download_item_->GetTotalBytes(); return download_item_->GetTotalBytes();
} }

View file

@ -30,8 +30,8 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
void Pause(); void Pause();
void Resume(); void Resume();
void Cancel(); void Cancel();
int64 GetReceivedBytes() const; int64_t GetReceivedBytes() const;
int64 GetTotalBytes() const; int64_t GetTotalBytes() const;
std::string GetMimeType() const; std::string GetMimeType() const;
bool HasUserGesture() const; bool HasUserGesture() const;
std::string GetFilename() const; std::string GetFilename() const;

View file

@ -117,7 +117,7 @@ class Protocol : public mate::Wrappable {
scoped_ptr<CustomProtocolHandler<RequestJob>> protocol_handler( scoped_ptr<CustomProtocolHandler<RequestJob>> protocol_handler(
new CustomProtocolHandler<RequestJob>( new CustomProtocolHandler<RequestJob>(
isolate(), request_context_getter_, handler)); isolate(), request_context_getter_, handler));
if (job_factory_->SetProtocolHandler(scheme, protocol_handler.Pass())) if (job_factory_->SetProtocolHandler(scheme, std::move(protocol_handler)))
return PROTOCOL_OK; return PROTOCOL_OK;
else else
return PROTOCOL_FAIL; return PROTOCOL_FAIL;
@ -161,7 +161,7 @@ class Protocol : public mate::Wrappable {
isolate(), request_context_getter_, handler)); isolate(), request_context_getter_, handler));
original_protocols_.set( original_protocols_.set(
scheme, scheme,
job_factory_->ReplaceProtocol(scheme, protocol_handler.Pass())); job_factory_->ReplaceProtocol(scheme, std::move(protocol_handler)));
return PROTOCOL_OK; return PROTOCOL_OK;
} }

View file

@ -49,12 +49,12 @@ namespace {
struct ClearStorageDataOptions { struct ClearStorageDataOptions {
GURL origin; GURL origin;
uint32 storage_types = StoragePartition::REMOVE_DATA_MASK_ALL; uint32_t storage_types = StoragePartition::REMOVE_DATA_MASK_ALL;
uint32 quota_types = StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL; uint32_t quota_types = StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL;
}; };
uint32 GetStorageMask(const std::vector<std::string>& storage_types) { uint32_t GetStorageMask(const std::vector<std::string>& storage_types) {
uint32 storage_mask = 0; uint32_t storage_mask = 0;
for (const auto& it : storage_types) { for (const auto& it : storage_types) {
auto type = base::ToLowerASCII(it); auto type = base::ToLowerASCII(it);
if (type == "appcache") if (type == "appcache")
@ -77,8 +77,8 @@ uint32 GetStorageMask(const std::vector<std::string>& storage_types) {
return storage_mask; return storage_mask;
} }
uint32 GetQuotaMask(const std::vector<std::string>& quota_types) { uint32_t GetQuotaMask(const std::vector<std::string>& quota_types) {
uint32 quota_mask = 0; uint32_t quota_mask = 0;
for (const auto& it : quota_types) { for (const auto& it : quota_types) {
auto type = base::ToLowerASCII(it); auto type = base::ToLowerASCII(it);
if (type == "temporary") if (type == "temporary")

View file

@ -44,6 +44,7 @@
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/resource_request_details.h" #include "content/public/browser/resource_request_details.h"
#include "content/public/browser/service_worker_context.h" #include "content/public/browser/service_worker_context.h"
@ -150,7 +151,7 @@ struct Converter<net::HttpResponseHeaders*> {
} else { } else {
scoped_ptr<base::ListValue> values(new base::ListValue()); scoped_ptr<base::ListValue> values(new base::ListValue());
values->AppendString(value); values->AppendString(value);
response_headers.Set(key, values.Pass()); response_headers.Set(key, std::move(values));
} }
} }
} }
@ -303,9 +304,9 @@ WebContents::~WebContents() {
} }
bool WebContents::AddMessageToConsole(content::WebContents* source, bool WebContents::AddMessageToConsole(content::WebContents* source,
int32 level, int32_t level,
const base::string16& message, const base::string16& message,
int32 line_no, int32_t line_no,
const base::string16& source_id) { const base::string16& source_id) {
if (type_ == BROWSER_WINDOW) { if (type_ == BROWSER_WINDOW) {
return false; return false;
@ -317,8 +318,9 @@ bool WebContents::AddMessageToConsole(content::WebContents* source,
bool WebContents::ShouldCreateWebContents( bool WebContents::ShouldCreateWebContents(
content::WebContents* web_contents, content::WebContents* web_contents,
int route_id, int32_t route_id,
int main_frame_route_id, int32_t main_frame_route_id,
int32_t main_frame_widget_route_id,
WindowContainerType window_container_type, WindowContainerType window_container_type,
const std::string& frame_name, const std::string& frame_name,
const GURL& target_url, const GURL& target_url,
@ -509,11 +511,11 @@ void WebContents::PluginCrashed(const base::FilePath& plugin_path,
Emit("plugin-crashed", info.name, info.version); Emit("plugin-crashed", info.name, info.version);
} }
void WebContents::MediaStartedPlaying() { void WebContents::MediaStartedPlaying(const MediaPlayerId& id) {
Emit("media-started-playing"); Emit("media-started-playing");
} }
void WebContents::MediaPaused() { void WebContents::MediaStoppedPlaying(const MediaPlayerId& id) {
Emit("media-paused"); Emit("media-paused");
} }
@ -998,8 +1000,8 @@ void WebContents::ReplaceMisspelling(const base::string16& word) {
web_contents()->ReplaceMisspelling(word); web_contents()->ReplaceMisspelling(word);
} }
uint32 WebContents::FindInPage(mate::Arguments* args) { uint32_t WebContents::FindInPage(mate::Arguments* args) {
uint32 request_id = GetNextRequestId(); uint32_t request_id = GetNextRequestId();
base::string16 search_text; base::string16 search_text;
blink::WebFindOptions options; blink::WebFindOptions options;
if (!args->GetNext(&search_text) || search_text.empty()) { if (!args->GetNext(&search_text) || search_text.empty()) {
@ -1070,7 +1072,7 @@ void WebContents::BeginFrameSubscription(
if (view) { if (view) {
scoped_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber( scoped_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
isolate(), view, callback)); isolate(), view, callback));
view->BeginFrameSubscription(frame_subscriber.Pass()); view->BeginFrameSubscription(std::move(frame_subscriber));
} }
} }

View file

@ -110,7 +110,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
void Unselect(); void Unselect();
void Replace(const base::string16& word); void Replace(const base::string16& word);
void ReplaceMisspelling(const base::string16& word); void ReplaceMisspelling(const base::string16& word);
uint32 FindInPage(mate::Arguments* args); uint32_t FindInPage(mate::Arguments* args);
void StopFindInPage(content::StopFindAction action); void StopFindInPage(content::StopFindAction action);
// Focus. // Focus.
@ -162,14 +162,15 @@ class WebContents : public mate::TrackableObject<WebContents>,
// content::WebContentsDelegate: // content::WebContentsDelegate:
bool AddMessageToConsole(content::WebContents* source, bool AddMessageToConsole(content::WebContents* source,
int32 level, int32_t level,
const base::string16& message, const base::string16& message,
int32 line_no, int32_t line_no,
const base::string16& source_id) override; const base::string16& source_id) override;
bool ShouldCreateWebContents( bool ShouldCreateWebContents(
content::WebContents* web_contents, content::WebContents* web_contents,
int route_id, int32_t route_id,
int main_frame_route_id, int32_t main_frame_route_id,
int32_t main_frame_widget_route_id,
WindowContainerType window_container_type, WindowContainerType window_container_type,
const std::string& frame_name, const std::string& frame_name,
const GURL& target_url, const GURL& target_url,
@ -252,8 +253,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
const std::vector<content::FaviconURL>& urls) override; const std::vector<content::FaviconURL>& urls) override;
void PluginCrashed(const base::FilePath& plugin_path, void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override; base::ProcessId plugin_pid) override;
void MediaStartedPlaying() override; void MediaStartedPlaying(const MediaPlayerId& id) override;
void MediaPaused() override; void MediaStoppedPlaying(const MediaPlayerId& id) override;
void DidChangeThemeColor(SkColor theme_color) override; void DidChangeThemeColor(SkColor theme_color) override;
// brightray::InspectableWebContentsViewDelegate: // brightray::InspectableWebContentsViewDelegate:
@ -270,7 +271,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
AtomBrowserContext* GetBrowserContext() const; AtomBrowserContext* GetBrowserContext() const;
uint32 GetNextRequestId() { uint32_t GetNextRequestId() {
return ++request_id_; return ++request_id_;
} }
@ -299,7 +300,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
Type type_; Type type_;
// Request id used for findInPage request. // Request id used for findInPage request.
uint32 request_id_; uint32_t request_id_;
DISALLOW_COPY_AND_ASSIGN(WebContents); DISALLOW_COPY_AND_ASSIGN(WebContents);
}; };

View file

@ -54,7 +54,7 @@ void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
return; return;
bitmap.copyPixelsTo( bitmap.copyPixelsTo(
reinterpret_cast<uint8*>(node::Buffer::Data(buffer.ToLocalChecked())), reinterpret_cast<uint8_t*>(node::Buffer::Data(buffer.ToLocalChecked())),
rgb_arr_size); rgb_arr_size);
callback_.Run(buffer.ToLocalChecked()); callback_.Run(buffer.ToLocalChecked());

View file

@ -49,7 +49,7 @@ namespace {
// The default routing id of WebContents. // The default routing id of WebContents.
// In Electron each RenderProcessHost only has one WebContents, so this ID is // In Electron each RenderProcessHost only has one WebContents, so this ID is
// same for every WebContents. // same for every WebContents.
int kDefaultRoutingID = 2; int kDefaultRoutingID = 1;
// Next navigation should not restart renderer process. // Next navigation should not restart renderer process.
bool g_suppress_renderer_process_restart = false; bool g_suppress_renderer_process_restart = false;
@ -201,16 +201,10 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
if (ContainsKey(pending_processes_, process_id)) if (ContainsKey(pending_processes_, process_id))
process_id = pending_processes_[process_id]; process_id = pending_processes_[process_id];
// Certain render process will be created with no associated render view, // Certain render process will be created with no associated render view,
// for example: ServiceWorker. // for example: ServiceWorker.
auto rvh = content::RenderViewHost::FromID(process_id, kDefaultRoutingID);
if (!rvh)
return;
// Get the WebContents of the render process.
content::WebContents* web_contents = content::WebContents* web_contents =
content::WebContents::FromRenderViewHost(rvh); WebContentsPreferences::GetWebContentsFromProcessID(process_id);
if (!web_contents) if (!web_contents)
return; return;
@ -230,8 +224,7 @@ content::QuotaPermissionContext*
} }
void AtomBrowserClient::AllowCertificateError( void AtomBrowserClient::AllowCertificateError(
int render_process_id, content::WebContents* web_contents,
int render_frame_id,
int cert_error, int cert_error,
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
@ -243,7 +236,7 @@ void AtomBrowserClient::AllowCertificateError(
content::CertificateRequestResultType* request) { content::CertificateRequestResultType* request) {
if (delegate_) { if (delegate_) {
delegate_->AllowCertificateError( delegate_->AllowCertificateError(
render_process_id, render_frame_id, cert_error, ssl_info, request_url, web_contents, cert_error, ssl_info, request_url,
resource_type, overridable, strict_enforcement, resource_type, overridable, strict_enforcement,
expired_previous_decision, callback, request); expired_previous_decision, callback, request);
} }
@ -265,7 +258,7 @@ void AtomBrowserClient::SelectClientCertificate(
if (!cert_request_info->client_certs.empty() && delegate_) { if (!cert_request_info->client_certs.empty() && delegate_) {
delegate_->SelectClientCertificate( delegate_->SelectClientCertificate(
web_contents, cert_request_info, delegate.Pass()); web_contents, cert_request_info, std::move(delegate));
} }
} }

View file

@ -61,8 +61,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override; void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
content::QuotaPermissionContext* CreateQuotaPermissionContext() override; content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
void AllowCertificateError( void AllowCertificateError(
int render_process_id, content::WebContents* web_contents,
int render_frame_id,
int cert_error, int cert_error,
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,

View file

@ -134,14 +134,15 @@ AtomBrowserContext::CreateURLRequestJobFactory(
new net::FtpNetworkLayer(host_resolver)))); new net::FtpNetworkLayer(host_resolver))));
// Set up interceptors in the reverse order. // Set up interceptors in the reverse order.
scoped_ptr<net::URLRequestJobFactory> top_job_factory = job_factory.Pass(); scoped_ptr<net::URLRequestJobFactory> top_job_factory =
std::move(job_factory);
content::URLRequestInterceptorScopedVector::reverse_iterator it; content::URLRequestInterceptorScopedVector::reverse_iterator it;
for (it = interceptors->rbegin(); it != interceptors->rend(); ++it) for (it = interceptors->rbegin(); it != interceptors->rend(); ++it)
top_job_factory.reset(new net::URLRequestInterceptingJobFactory( top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
top_job_factory.Pass(), make_scoped_ptr(*it))); std::move(top_job_factory), make_scoped_ptr(*it)));
interceptors->weak_clear(); interceptors->weak_clear();
return top_job_factory.Pass(); return top_job_factory;
} }
net::HttpCache::BackendFactory* net::HttpCache::BackendFactory*

View file

@ -60,7 +60,7 @@ void AtomDownloadManagerDelegate::CreateDownloadPath(
} }
void AtomDownloadManagerDelegate::OnDownloadPathGenerated( void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
uint32 download_id, uint32_t download_id,
const content::DownloadTargetCallback& callback, const content::DownloadTargetCallback& callback,
const base::FilePath& default_path) { const base::FilePath& default_path) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@ -160,7 +160,7 @@ bool AtomDownloadManagerDelegate::ShouldOpenDownload(
void AtomDownloadManagerDelegate::GetNextId( void AtomDownloadManagerDelegate::GetNextId(
const content::DownloadIdCallback& callback) { const content::DownloadIdCallback& callback) {
static uint32 next_id = content::DownloadItem::kInvalidId + 1; static uint32_t next_id = content::DownloadItem::kInvalidId + 1;
callback.Run(next_id++); callback.Run(next_id++);
} }

View file

@ -31,7 +31,7 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate {
const std::string& mime_type, const std::string& mime_type,
const base::FilePath& path, const base::FilePath& path,
const CreateDownloadPathCallback& callback); const CreateDownloadPathCallback& callback);
void OnDownloadPathGenerated(uint32 download_id, void OnDownloadPathGenerated(uint32_t download_id,
const content::DownloadTargetCallback& callback, const content::DownloadTargetCallback& callback,
const base::FilePath& default_path); const base::FilePath& default_path);

View file

@ -4,6 +4,8 @@
#include "atom/browser/atom_permission_manager.h" #include "atom/browser/atom_permission_manager.h"
#include <vector>
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/permission_type.h" #include "content/public/browser/permission_type.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
@ -80,6 +82,26 @@ int AtomPermissionManager::RequestPermission(
return kNoPendingOperation; return kNoPendingOperation;
} }
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<content::PermissionStatus>&)>& callback) {
// FIXME(zcbenz): Just ignore multiple permissions request for now.
std::vector<content::PermissionStatus> permissionStatuses;
for (auto permission : permissions) {
if (permission == content::PermissionType::MIDI_SYSEX) {
content::ChildProcessSecurityPolicy::GetInstance()->
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
}
permissionStatuses.push_back(content::PERMISSION_STATUS_GRANTED);
}
callback.Run(permissionStatuses);
return kNoPendingOperation;
}
void AtomPermissionManager::OnPermissionResponse( void AtomPermissionManager::OnPermissionResponse(
int request_id, int request_id,
const GURL& origin, const GURL& origin,

View file

@ -6,6 +6,7 @@
#define ATOM_BROWSER_ATOM_PERMISSION_MANAGER_H_ #define ATOM_BROWSER_ATOM_PERMISSION_MANAGER_H_
#include <map> #include <map>
#include <vector>
#include "base/callback.h" #include "base/callback.h"
#include "content/public/browser/permission_manager.h" #include "content/public/browser/permission_manager.h"
@ -38,6 +39,13 @@ class AtomPermissionManager : public content::PermissionManager {
const GURL& requesting_origin, const GURL& requesting_origin,
bool user_gesture, bool user_gesture,
const ResponseCallback& callback) override; const ResponseCallback& 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<content::PermissionStatus>&)>& callback) override;
protected: protected:
void OnPermissionResponse(int request_id, void OnPermissionResponse(int request_id,

View file

@ -19,8 +19,8 @@ AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() {
bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol( bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol(
const GURL& url, const GURL& url,
int render_process_id, int child_id,
int render_view_id, const content::ResourceRequestInfo::WebContentsGetter&,
bool is_main_frame, bool is_main_frame,
ui::PageTransition transition, ui::PageTransition transition,
bool has_user_gesture) { bool has_user_gesture) {

View file

@ -15,12 +15,13 @@ class AtomResourceDispatcherHostDelegate
AtomResourceDispatcherHostDelegate(); AtomResourceDispatcherHostDelegate();
// content::ResourceDispatcherHostDelegate: // content::ResourceDispatcherHostDelegate:
bool HandleExternalProtocol(const GURL& url, bool HandleExternalProtocol(
int render_process_id, const GURL& url,
int render_view_id, int child_id,
bool is_main_frame, const content::ResourceRequestInfo::WebContentsGetter&,
ui::PageTransition transition, bool is_main_frame,
bool has_user_gesture) override; ui::PageTransition transition,
bool has_user_gesture) override;
content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
net::AuthChallengeInfo* auth_info, net::AuthChallengeInfo* auth_info,
net::URLRequest* request) override; net::URLRequest* request) override;

View file

@ -7,6 +7,7 @@
#include <string> #include <string>
#include "base/macros.h"
#include "content/public/browser/speech_recognition_event_listener.h" #include "content/public/browser/speech_recognition_event_listener.h"
#include "content/public/browser/speech_recognition_manager_delegate.h" #include "content/public/browser/speech_recognition_manager_delegate.h"

View file

@ -7,7 +7,8 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/macros.h"
#include "build/build_config.h"
namespace base { namespace base {
class Time; class Time;

View file

@ -8,7 +8,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/macros.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"

View file

@ -19,6 +19,7 @@
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "storage/browser/fileapi/isolated_context.h" #include "storage/browser/fileapi/isolated_context.h"
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
@ -173,8 +174,6 @@ content::WebContents* CommonWebContentsDelegate::OpenURLFromTab(
load_url_params.should_replace_current_entry = load_url_params.should_replace_current_entry =
params.should_replace_current_entry; params.should_replace_current_entry;
load_url_params.is_renderer_initiated = params.is_renderer_initiated; load_url_params.is_renderer_initiated = params.is_renderer_initiated;
load_url_params.transferred_global_request_id =
params.transferred_global_request_id;
load_url_params.should_clear_history_list = true; load_url_params.should_clear_history_list = true;
source->GetController().LoadURLWithParams(load_url_params); source->GetController().LoadURLWithParams(load_url_params);
@ -223,7 +222,7 @@ void CommonWebContentsDelegate::EnterFullscreenModeForTab(
return; return;
SetHtmlApiFullscreen(true); SetHtmlApiFullscreen(true);
owner_window_->NotifyWindowEnterHtmlFullScreen(); owner_window_->NotifyWindowEnterHtmlFullScreen();
source->GetRenderViewHost()->WasResized(); source->GetRenderViewHost()->GetWidget()->WasResized();
} }
void CommonWebContentsDelegate::ExitFullscreenModeForTab( void CommonWebContentsDelegate::ExitFullscreenModeForTab(
@ -232,7 +231,7 @@ void CommonWebContentsDelegate::ExitFullscreenModeForTab(
return; return;
SetHtmlApiFullscreen(false); SetHtmlApiFullscreen(false);
owner_window_->NotifyWindowLeaveHtmlFullScreen(); owner_window_->NotifyWindowLeaveHtmlFullScreen();
source->GetRenderViewHost()->WasResized(); source->GetRenderViewHost()->GetWidget()->WasResized();
} }
bool CommonWebContentsDelegate::IsFullscreenForTabOrPending( bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(

View file

@ -37,6 +37,7 @@ bool JavascriptEnvironment::Initialize() {
v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size()); v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size());
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
gin::IsolateHolder::kStableV8Extras,
gin::ArrayBufferAllocator::SharedInstance()); gin::ArrayBufferAllocator::SharedInstance());
return true; return true;
} }

View file

@ -5,7 +5,7 @@
#ifndef ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ #ifndef ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_
#define ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ #define ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_
#include "base/basictypes.h" #include "base/macros.h"
#include "gin/public/isolate_holder.h" #include "gin/public/isolate_holder.h"
namespace atom { namespace atom {

View file

@ -27,6 +27,7 @@
#include "content/public/browser/plugin_service.h" #include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
@ -275,15 +276,15 @@ bool NativeWindow::HasModalDialog() {
} }
void NativeWindow::FocusOnWebView() { void NativeWindow::FocusOnWebView() {
web_contents()->GetRenderViewHost()->Focus(); web_contents()->GetRenderViewHost()->GetWidget()->Focus();
} }
void NativeWindow::BlurWebView() { void NativeWindow::BlurWebView() {
web_contents()->GetRenderViewHost()->Blur(); web_contents()->GetRenderViewHost()->GetWidget()->Blur();
} }
bool NativeWindow::IsWebViewFocused() { bool NativeWindow::IsWebViewFocused() {
auto host_view = web_contents()->GetRenderViewHost()->GetView(); auto host_view = web_contents()->GetRenderViewHost()->GetWidget()->GetView();
return host_view && host_view->HasFocus(); return host_view && host_view->HasFocus();
} }
@ -519,7 +520,7 @@ scoped_ptr<SkRegion> NativeWindow::DraggableRegionsToSkRegion(
region.bounds.bottom(), region.bounds.bottom(),
region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
} }
return sk_region.Pass(); return sk_region;
} }
void NativeWindow::RenderViewCreated( void NativeWindow::RenderViewCreated(

View file

@ -44,6 +44,7 @@ URLRequestAsarJob::URLRequestAsarJob(
: net::URLRequestJob(request, network_delegate), : net::URLRequestJob(request, network_delegate),
type_(TYPE_ERROR), type_(TYPE_ERROR),
remaining_bytes_(0), remaining_bytes_(0),
range_parse_result_(net::OK),
weak_ptr_factory_(this) {} weak_ptr_factory_(this) {}
URLRequestAsarJob::~URLRequestAsarJob() {} URLRequestAsarJob::~URLRequestAsarJob() {}
@ -99,7 +100,7 @@ void URLRequestAsarJob::InitializeFileJob(
void URLRequestAsarJob::Start() { void URLRequestAsarJob::Start() {
if (type_ == TYPE_ASAR) { if (type_ == TYPE_ASAR) {
remaining_bytes_ = static_cast<int64>(file_info_.size); remaining_bytes_ = static_cast<int64_t>(file_info_.size);
int flags = base::File::FLAG_OPEN | int flags = base::File::FLAG_OPEN |
base::File::FLAG_READ | base::File::FLAG_READ |
@ -131,18 +132,14 @@ void URLRequestAsarJob::Kill() {
URLRequestJob::Kill(); URLRequestJob::Kill();
} }
bool URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
int dest_size,
int* bytes_read) {
if (remaining_bytes_ < dest_size) if (remaining_bytes_ < dest_size)
dest_size = static_cast<int>(remaining_bytes_); dest_size = static_cast<int>(remaining_bytes_);
// If we should copy zero bytes because |remaining_bytes_| is zero, short // If we should copy zero bytes because |remaining_bytes_| is zero, short
// circuit here. // circuit here.
if (!dest_size) { if (!dest_size)
*bytes_read = 0; return 0;
return true;
}
int rv = stream_->Read(dest, int rv = stream_->Read(dest,
dest_size, dest_size,
@ -150,20 +147,11 @@ bool URLRequestAsarJob::ReadRawData(net::IOBuffer* dest,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
make_scoped_refptr(dest))); make_scoped_refptr(dest)));
if (rv >= 0) { if (rv >= 0) {
// Data is immediately available.
*bytes_read = rv;
remaining_bytes_ -= rv; remaining_bytes_ -= rv;
DCHECK_GE(remaining_bytes_, 0); DCHECK_GE(remaining_bytes_, 0);
return true;
} }
// Otherwise, a read error occured. We may just need to wait... return rv;
if (rv == net::ERR_IO_PENDING) {
SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
} else {
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, rv));
}
return false;
} }
bool URLRequestAsarJob::IsRedirectResponse(GURL* location, bool URLRequestAsarJob::IsRedirectResponse(GURL* location,
@ -214,15 +202,16 @@ void URLRequestAsarJob::SetExtraRequestHeaders(
const net::HttpRequestHeaders& headers) { const net::HttpRequestHeaders& headers) {
std::string range_header; std::string range_header;
if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) {
// We only care about "Range" header here. // This job only cares about the Range header. This method stashes the value
// for later use in DidOpen(), which is responsible for some of the range
// validation as well. NotifyStartError is not legal to call here since
// the job has not started.
std::vector<net::HttpByteRange> ranges; std::vector<net::HttpByteRange> ranges;
if (net::HttpUtil::ParseRangeHeader(range_header, &ranges)) { if (net::HttpUtil::ParseRangeHeader(range_header, &ranges)) {
if (ranges.size() == 1) { if (ranges.size() == 1) {
byte_range_ = ranges[0]; byte_range_ = ranges[0];
} else { } else {
NotifyDone(net::URLRequestStatus( range_parse_result_ = net::ERR_REQUEST_RANGE_NOT_SATISFIABLE;
net::URLRequestStatus::FAILED,
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
} }
} }
} }
@ -274,7 +263,14 @@ void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
void URLRequestAsarJob::DidOpen(int result) { void URLRequestAsarJob::DidOpen(int result) {
if (result != net::OK) { if (result != net::OK) {
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result)); NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
result));
return;
}
if (range_parse_result_ != net::OK) {
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
range_parse_result_));
return; return;
} }
@ -289,8 +285,9 @@ void URLRequestAsarJob::DidOpen(int result) {
} }
} else { } else {
if (!byte_range_.ComputeBounds(meta_info_.file_size)) { if (!byte_range_.ComputeBounds(meta_info_.file_size)) {
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, NotifyStartError(
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return; return;
} }
@ -315,17 +312,19 @@ void URLRequestAsarJob::DidOpen(int result) {
} }
} }
void URLRequestAsarJob::DidSeek(int64 result) { void URLRequestAsarJob::DidSeek(int64_t result) {
if (type_ == TYPE_ASAR) { if (type_ == TYPE_ASAR) {
if (result != static_cast<int64>(file_info_.offset)) { if (result != static_cast<int64_t>(file_info_.offset)) {
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, NotifyStartError(
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return; return;
} }
} else { } else {
if (result != byte_range_.first_byte_position()) { if (result != byte_range_.first_byte_position()) {
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, NotifyStartError(
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return; return;
} }
} }
@ -334,21 +333,14 @@ void URLRequestAsarJob::DidSeek(int64 result) {
} }
void URLRequestAsarJob::DidRead(scoped_refptr<net::IOBuffer> buf, int result) { void URLRequestAsarJob::DidRead(scoped_refptr<net::IOBuffer> buf, int result) {
if (result > 0) { if (result >= 0) {
SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status
remaining_bytes_ -= result; remaining_bytes_ -= result;
DCHECK_GE(remaining_bytes_, 0); DCHECK_GE(remaining_bytes_, 0);
} }
buf = NULL; buf = NULL;
if (result == 0) { ReadRawDataComplete(result);
NotifyDone(net::URLRequestStatus());
} else if (result < 0) {
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
}
NotifyReadComplete(result);
} }
} // namespace asar } // namespace asar

View file

@ -54,9 +54,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
// net::URLRequestJob: // net::URLRequestJob:
void Start() override; void Start() override;
void Kill() override; void Kill() override;
bool ReadRawData(net::IOBuffer* buf, int ReadRawData(net::IOBuffer* buf, int buf_size) override;
int buf_size,
int* bytes_read) override;
bool IsRedirectResponse(GURL* location, int* http_status_code) override; bool IsRedirectResponse(GURL* location, int* http_status_code) override;
net::Filter* SetupFilter() const override; net::Filter* SetupFilter() const override;
bool GetMimeType(std::string* mime_type) const override; bool GetMimeType(std::string* mime_type) const override;
@ -72,7 +70,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
FileMetaInfo(); FileMetaInfo();
// Size of the file. // Size of the file.
int64 file_size; int64_t file_size;
// Mime type associated with the file. // Mime type associated with the file.
std::string mime_type; std::string mime_type;
// Result returned from GetMimeTypeFromFile(), i.e. flag showing whether // Result returned from GetMimeTypeFromFile(), i.e. flag showing whether
@ -97,7 +95,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
// Callback after seeking to the beginning of |byte_range_| in the file // Callback after seeking to the beginning of |byte_range_| in the file
// on a background thread. // on a background thread.
void DidSeek(int64 result); void DidSeek(int64_t result);
// Callback after data is asynchronously read from the file into |buf|. // Callback after data is asynchronously read from the file into |buf|.
void DidRead(scoped_refptr<net::IOBuffer> buf, int result); void DidRead(scoped_refptr<net::IOBuffer> buf, int result);
@ -119,7 +117,9 @@ class URLRequestAsarJob : public net::URLRequestJob {
scoped_refptr<base::TaskRunner> file_task_runner_; scoped_refptr<base::TaskRunner> file_task_runner_;
net::HttpByteRange byte_range_; net::HttpByteRange byte_range_;
int64 remaining_bytes_; int64_t remaining_bytes_;
net::Error range_parse_result_;
base::WeakPtrFactory<URLRequestAsarJob> weak_ptr_factory_; base::WeakPtrFactory<URLRequestAsarJob> weak_ptr_factory_;

View file

@ -78,7 +78,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
scoped_ptr<base::ListValue> list(new base::ListValue); scoped_ptr<base::ListValue> list(new base::ListValue);
GetUploadData(list.get(), request); GetUploadData(list.get(), request);
if (!list->empty()) if (!list->empty())
details->Set("uploadData", list.Pass()); details->Set("uploadData", std::move(list));
} }
void ToDictionary(base::DictionaryValue* details, void ToDictionary(base::DictionaryValue* details,
@ -87,7 +87,7 @@ void ToDictionary(base::DictionaryValue* details,
net::HttpRequestHeaders::Iterator it(headers); net::HttpRequestHeaders::Iterator it(headers);
while (it.GetNext()) while (it.GetNext())
dict->SetString(it.name(), it.value()); dict->SetString(it.name(), it.value());
details->Set("requestHeaders", dict.Pass()); details->Set("requestHeaders", std::move(dict));
} }
void ToDictionary(base::DictionaryValue* details, void ToDictionary(base::DictionaryValue* details,
@ -107,10 +107,10 @@ void ToDictionary(base::DictionaryValue* details,
} else { } else {
scoped_ptr<base::ListValue> values(new base::ListValue); scoped_ptr<base::ListValue> values(new base::ListValue);
values->AppendString(value); values->AppendString(value);
dict->Set(key, values.Pass()); dict->Set(key, std::move(values));
} }
} }
details->Set("responseHeaders", dict.Pass()); details->Set("responseHeaders", std::move(dict));
details->SetString("statusLine", headers->GetStatusLine()); details->SetString("statusLine", headers->GetStatusLine());
details->SetInteger("statusCode", headers->response_code()); details->SetInteger("statusCode", headers->response_code());
} }

View file

@ -18,8 +18,8 @@ namespace atom {
namespace { namespace {
uint16 GetSSLProtocolVersion(const std::string& version_string) { uint16_t GetSSLProtocolVersion(const std::string& version_string) {
uint16 version = 0; // Invalid uint16_t version = 0; // Invalid
if (version_string == "tls1") if (version_string == "tls1")
version = net::SSL_PROTOCOL_VERSION_TLS1; version = net::SSL_PROTOCOL_VERSION_TLS1;
else if (version_string == "tls1.1") else if (version_string == "tls1.1")
@ -29,13 +29,13 @@ uint16 GetSSLProtocolVersion(const std::string& version_string) {
return version; return version;
} }
std::vector<uint16> ParseCipherSuites( std::vector<uint16_t> ParseCipherSuites(
const std::vector<std::string>& cipher_strings) { const std::vector<std::string>& cipher_strings) {
std::vector<uint16> cipher_suites; std::vector<uint16_t> cipher_suites;
cipher_suites.reserve(cipher_strings.size()); cipher_suites.reserve(cipher_strings.size());
for (auto& cipher_string : cipher_strings) { for (auto& cipher_string : cipher_strings) {
uint16 cipher_suite = 0; uint16_t cipher_suite = 0;
if (!net::ParseSSLCipherString(cipher_string, &cipher_suite)) { if (!net::ParseSSLCipherString(cipher_string, &cipher_suite)) {
LOG(ERROR) << "Ignoring unrecognised cipher suite : " LOG(ERROR) << "Ignoring unrecognised cipher suite : "
<< cipher_string; << cipher_string;

View file

@ -16,7 +16,9 @@ namespace internal {
namespace { namespace {
// The callback which is passed to |handler|. // The callback which is passed to |handler|.
void HandlerCallback(const ResponseCallback& callback, mate::Arguments* args) { void HandlerCallback(const BeforeStartCallback& before_start,
const ResponseCallback& callback,
mate::Arguments* args) {
// If there is no argument passed then we failed. // If there is no argument passed then we failed.
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
if (!args->GetNext(&value)) { if (!args->GetNext(&value)) {
@ -26,6 +28,9 @@ void HandlerCallback(const ResponseCallback& callback, mate::Arguments* args) {
return; return;
} }
// Give the job a chance to parse V8 value.
before_start.Run(args->isolate(), value);
// Pass whatever user passed to the actaul request job. // Pass whatever user passed to the actaul request job.
V8ValueConverter converter; V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
@ -40,15 +45,17 @@ void HandlerCallback(const ResponseCallback& callback, mate::Arguments* args) {
void AskForOptions(v8::Isolate* isolate, void AskForOptions(v8::Isolate* isolate,
const JavaScriptHandler& handler, const JavaScriptHandler& handler,
net::URLRequest* request, net::URLRequest* request,
const BeforeStartCallback& before_start,
const ResponseCallback& callback) { const ResponseCallback& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
v8::Locker locker(isolate); v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
handler.Run(request, handler.Run(
mate::ConvertToV8(isolate, request,
base::Bind(&HandlerCallback, callback))); mate::ConvertToV8(isolate,
base::Bind(&HandlerCallback, before_start, callback)));
} }
bool IsErrorOptions(base::Value* value, int* error) { bool IsErrorOptions(base::Value* value, int* error) {

View file

@ -23,6 +23,8 @@ using JavaScriptHandler =
namespace internal { namespace internal {
using BeforeStartCallback =
base::Callback<void(v8::Isolate*, v8::Local<v8::Value>)>;
using ResponseCallback = using ResponseCallback =
base::Callback<void(bool, scoped_ptr<base::Value> options)>; base::Callback<void(bool, scoped_ptr<base::Value> options)>;
@ -30,6 +32,7 @@ using ResponseCallback =
void AskForOptions(v8::Isolate* isolate, void AskForOptions(v8::Isolate* isolate,
const JavaScriptHandler& handler, const JavaScriptHandler& handler,
net::URLRequest* request, net::URLRequest* request,
const BeforeStartCallback& before_start,
const ResponseCallback& callback); const ResponseCallback& callback);
// Test whether the |options| means an error. // Test whether the |options| means an error.
@ -54,6 +57,7 @@ class JsAsker : public RequestJob {
} }
// Subclass should do initailze work here. // Subclass should do initailze work here.
virtual void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) {}
virtual void StartAsync(scoped_ptr<base::Value> options) = 0; virtual void StartAsync(scoped_ptr<base::Value> options) = 0;
net::URLRequestContextGetter* request_context_getter() const { net::URLRequestContextGetter* request_context_getter() const {
@ -69,6 +73,8 @@ class JsAsker : public RequestJob {
isolate_, isolate_,
handler_, handler_,
RequestJob::request(), RequestJob::request(),
base::Bind(&JsAsker::BeforeStartInUI,
weak_factory_.GetWeakPtr()),
base::Bind(&JsAsker::OnResponse, base::Bind(&JsAsker::OnResponse,
weak_factory_.GetWeakPtr()))); weak_factory_.GetWeakPtr())));
} }
@ -81,7 +87,7 @@ class JsAsker : public RequestJob {
void OnResponse(bool success, scoped_ptr<base::Value> value) { void OnResponse(bool success, scoped_ptr<base::Value> value) {
int error = net::ERR_NOT_IMPLEMENTED; int error = net::ERR_NOT_IMPLEMENTED;
if (success && value && !internal::IsErrorOptions(value.get(), &error)) { if (success && value && !internal::IsErrorOptions(value.get(), &error)) {
StartAsync(value.Pass()); StartAsync(std::move(value));
} else { } else {
RequestJob::NotifyStartError( RequestJob::NotifyStartError(
net::URLRequestStatus(net::URLRequestStatus::FAILED, error)); net::URLRequestStatus(net::URLRequestStatus::FAILED, error));

View file

@ -8,15 +8,14 @@
#include <string> #include <string>
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h" #include "native_mate/dictionary.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher.h" #include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_response_writer.h" #include "net/url_request/url_fetcher_response_writer.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h" using content::BrowserThread;
#include "net/url_request/url_request_status.h"
namespace atom { namespace atom {
@ -81,6 +80,25 @@ URLRequestFetchJob::URLRequestFetchJob(
pending_buffer_size_(0) { pending_buffer_size_(0) {
} }
void URLRequestFetchJob::BeforeStartInUI(
v8::Isolate* isolate, v8::Local<v8::Value> value) {
mate::Dictionary options;
if (!mate::ConvertFromV8(isolate, value, &options))
return;
// When |session| is set to |null| we use a new request context for fetch job.
// TODO(zcbenz): Handle the case when it is not null.
v8::Local<v8::Value> session;
if (options.Get("session", &session) && session->IsNull()) {
// We have to create the URLRequestContextGetter on UI thread.
url_request_context_getter_ = new brightray::URLRequestContextGetter(
this, nullptr, nullptr, base::FilePath(), true,
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
nullptr, content::URLRequestInterceptorScopedVector());
}
}
void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) { void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
if (!options->IsType(base::Value::TYPE_DICTIONARY)) { if (!options->IsType(base::Value::TYPE_DICTIONARY)) {
NotifyStartError(net::URLRequestStatus( NotifyStartError(net::URLRequestStatus(
@ -89,14 +107,12 @@ void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
} }
std::string url, method, referrer; std::string url, method, referrer;
base::Value* session = nullptr;
base::DictionaryValue* upload_data = nullptr; base::DictionaryValue* upload_data = nullptr;
base::DictionaryValue* dict = base::DictionaryValue* dict =
static_cast<base::DictionaryValue*>(options.get()); static_cast<base::DictionaryValue*>(options.get());
dict->GetString("url", &url); dict->GetString("url", &url);
dict->GetString("method", &method); dict->GetString("method", &method);
dict->GetString("referrer", &referrer); dict->GetString("referrer", &referrer);
dict->Get("session", &session);
dict->GetDictionary("uploadData", &upload_data); dict->GetDictionary("uploadData", &upload_data);
// Check if URL is valid. // Check if URL is valid.
@ -117,9 +133,9 @@ void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
fetcher_ = net::URLFetcher::Create(formated_url, request_type, this); fetcher_ = net::URLFetcher::Create(formated_url, request_type, this);
fetcher_->SaveResponseWithWriter(make_scoped_ptr(new ResponsePiper(this))); fetcher_->SaveResponseWithWriter(make_scoped_ptr(new ResponsePiper(this)));
// When |session| is set to |null| we use a new request context for fetch job. // A request context getter is passed by the user.
if (session && session->IsType(base::Value::TYPE_NULL)) if (url_request_context_getter_)
fetcher_->SetRequestContext(CreateRequestContext()); fetcher_->SetRequestContext(url_request_context_getter_.get());
else else
fetcher_->SetRequestContext(request_context_getter()); fetcher_->SetRequestContext(request_context_getter());
@ -144,18 +160,6 @@ void URLRequestFetchJob::StartAsync(scoped_ptr<base::Value> options) {
fetcher_->Start(); fetcher_->Start();
} }
net::URLRequestContextGetter* URLRequestFetchJob::CreateRequestContext() {
if (!url_request_context_getter_.get()) {
auto task_runner = base::ThreadTaskRunnerHandle::Get();
net::URLRequestContextBuilder builder;
builder.set_proxy_service(net::ProxyService::CreateDirect());
request_context_ = builder.Build();
url_request_context_getter_ = new net::TrivialURLRequestContextGetter(
request_context_.get(), task_runner);
}
return url_request_context_getter_.get();
}
void URLRequestFetchJob::HeadersCompleted() { void URLRequestFetchJob::HeadersCompleted() {
response_info_.reset(new net::HttpResponseInfo); response_info_.reset(new net::HttpResponseInfo);
response_info_->headers = fetcher_->GetResponseHeaders(); response_info_->headers = fetcher_->GetResponseHeaders();
@ -181,7 +185,7 @@ int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer, int num_bytes) {
pending_buffer_ = nullptr; pending_buffer_ = nullptr;
pending_buffer_size_ = 0; pending_buffer_size_ = 0;
NotifyReadComplete(bytes_read); ReadRawDataComplete(bytes_read);
return bytes_read; return bytes_read;
} }
@ -190,18 +194,15 @@ void URLRequestFetchJob::Kill() {
fetcher_.reset(); fetcher_.reset();
} }
bool URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
int dest_size,
int* bytes_read) {
if (GetResponseCode() == 204) { if (GetResponseCode() == 204) {
*bytes_read = 0;
request()->set_received_response_content_length(prefilter_bytes_read()); request()->set_received_response_content_length(prefilter_bytes_read());
return true; return 0;
} }
pending_buffer_ = dest; pending_buffer_ = dest;
pending_buffer_size_ = dest_size; pending_buffer_size_ = dest_size;
SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
return false; return dest_size;
} }
bool URLRequestFetchJob::GetMimeType(std::string* mime_type) const { bool URLRequestFetchJob::GetMimeType(std::string* mime_type) const {
@ -234,9 +235,10 @@ void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
pending_buffer_ = nullptr; pending_buffer_ = nullptr;
pending_buffer_size_ = 0; pending_buffer_size_ = 0;
NotifyDone(fetcher_->GetStatus());
if (fetcher_->GetStatus().is_success()) if (fetcher_->GetStatus().is_success())
NotifyReadComplete(0); ReadRawDataComplete(0);
else
NotifyStartError(fetcher_->GetStatus());
} }
} // namespace atom } // namespace atom

View file

@ -8,6 +8,7 @@
#include <string> #include <string>
#include "atom/browser/net/js_asker.h" #include "atom/browser/net/js_asker.h"
#include "browser/url_request_context_getter.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_job.h" #include "net/url_request/url_request_job.h"
@ -17,7 +18,8 @@ namespace atom {
class AtomBrowserContext; class AtomBrowserContext;
class URLRequestFetchJob : public JsAsker<net::URLRequestJob>, class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
public net::URLFetcherDelegate { public net::URLFetcherDelegate,
public brightray::URLRequestContextGetter::Delegate {
public: public:
URLRequestFetchJob(net::URLRequest*, net::NetworkDelegate*); URLRequestFetchJob(net::URLRequest*, net::NetworkDelegate*);
@ -27,13 +29,12 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
protected: protected:
// JsAsker: // JsAsker:
void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) override;
void StartAsync(scoped_ptr<base::Value> options) override; void StartAsync(scoped_ptr<base::Value> options) override;
// net::URLRequestJob: // net::URLRequestJob:
void Kill() override; void Kill() override;
bool ReadRawData(net::IOBuffer* buf, int ReadRawData(net::IOBuffer* buf, int buf_size) override;
int buf_size,
int* bytes_read) override;
bool GetMimeType(std::string* mime_type) const override; bool GetMimeType(std::string* mime_type) const override;
void GetResponseInfo(net::HttpResponseInfo* info) override; void GetResponseInfo(net::HttpResponseInfo* info) override;
int GetResponseCode() const override; int GetResponseCode() const override;
@ -42,10 +43,6 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
void OnURLFetchComplete(const net::URLFetcher* source) override; void OnURLFetchComplete(const net::URLFetcher* source) override;
private: private:
// Create a independent request context.
net::URLRequestContextGetter* CreateRequestContext();
scoped_ptr<net::URLRequestContext> request_context_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
scoped_ptr<net::URLFetcher> fetcher_; scoped_ptr<net::URLFetcher> fetcher_;
scoped_refptr<net::IOBuffer> pending_buffer_; scoped_refptr<net::IOBuffer> pending_buffer_;

View file

@ -152,7 +152,7 @@ void NodeDebugger::DidAccept(
return; return;
} }
accepted_socket_ = socket.Pass(); accepted_socket_ = std::move(socket);
SendConnectMessage(); SendConnectMessage();
} }

View file

@ -28,7 +28,7 @@ void SetPlatformAccelerator(ui::Accelerator* accelerator) {
scoped_ptr<ui::PlatformAccelerator> platform_accelerator( scoped_ptr<ui::PlatformAccelerator> platform_accelerator(
new ui::PlatformAcceleratorCocoa(characters, modifiers)); new ui::PlatformAcceleratorCocoa(characters, modifiers));
accelerator->set_platform_accelerator(platform_accelerator.Pass()); accelerator->set_platform_accelerator(std::move(platform_accelerator));
} }
} // namespace accelerator_util } // namespace accelerator_util

View file

@ -96,7 +96,7 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window,
} }
if (!icon.isNull()) { if (!icon.isNull()) {
NSImage* image = gfx::SkBitmapToNSImageWithColorSpace( NSImage* image = skia::SkBitmapToNSImageWithColorSpace(
*icon.bitmap(), base::mac::GetGenericRGBColorSpace()); *icon.bitmap(), base::mac::GetGenericRGBColorSpace());
[alert setIcon:image]; [alert setIcon:image];
} }

View file

@ -102,9 +102,9 @@ int ShowMessageBoxUTF16(HWND parent,
base::win::ScopedHICON hicon; base::win::ScopedHICON hicon;
if (!icon.isNull()) { if (!icon.isNull()) {
hicon.Set(IconUtil::CreateHICONFromSkBitmap(*icon.bitmap())); hicon = IconUtil::CreateHICONFromSkBitmap(*icon.bitmap());
config.dwFlags |= TDF_USE_HICON_MAIN; config.dwFlags |= TDF_USE_HICON_MAIN;
config.hMainIcon = hicon.Get(); config.hMainIcon = hicon.get();
} else { } else {
// Show icon according to dialog's type. // Show icon according to dialog's type.
switch (type) { switch (type) {

View file

@ -7,7 +7,7 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/macros.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "ui/base/glib/glib_signal.h" #include "ui/base/glib/glib_signal.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"

View file

@ -37,7 +37,7 @@ SubmenuButton::SubmenuButton(views::ButtonListener* listener,
underline_color_(SK_ColorBLACK) { underline_color_(SK_ColorBLACK) {
#if defined(OS_LINUX) #if defined(OS_LINUX)
// Dont' use native style border. // Dont' use native style border.
SetBorder(CreateDefaultBorder().Pass()); SetBorder(std::move(CreateDefaultBorder()));
#endif #endif
if (GetUnderlinePosition(title, &accelerator_, &underline_start_, if (GetUnderlinePosition(title, &accelerator_, &underline_start_,

View file

@ -80,7 +80,7 @@ void NotifyIcon::ResetIcon() {
InitIconData(&icon_data); InitIconData(&icon_data);
icon_data.uFlags |= NIF_MESSAGE; icon_data.uFlags |= NIF_MESSAGE;
icon_data.uCallbackMessage = message_id_; icon_data.uCallbackMessage = message_id_;
icon_data.hIcon = icon_.Get(); icon_data.hIcon = icon_.get();
// If we have an image, then set the NIF_ICON flag, which tells // If we have an image, then set the NIF_ICON flag, which tells
// Shell_NotifyIcon() to set the image for the status icon it creates. // Shell_NotifyIcon() to set the image for the status icon it creates.
if (icon_data.hIcon) if (icon_data.hIcon)
@ -96,8 +96,8 @@ void NotifyIcon::SetImage(const gfx::Image& image) {
NOTIFYICONDATA icon_data; NOTIFYICONDATA icon_data;
InitIconData(&icon_data); InitIconData(&icon_data);
icon_data.uFlags |= NIF_ICON; icon_data.uFlags |= NIF_ICON;
icon_.Set(IconUtil::CreateHICONFromSkBitmap(image.AsBitmap())); icon_ = IconUtil::CreateHICONFromSkBitmap(image.AsBitmap());
icon_data.hIcon = icon_.Get(); icon_data.hIcon = icon_.get();
BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data); BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
if (!result) if (!result)
LOG(WARNING) << "Error setting status tray icon image"; LOG(WARNING) << "Error setting status tray icon image";
@ -132,8 +132,8 @@ void NotifyIcon::DisplayBalloon(const gfx::Image& icon,
base::win::Version win_version = base::win::GetVersion(); base::win::Version win_version = base::win::GetVersion();
if (!icon.IsEmpty() && win_version != base::win::VERSION_PRE_XP) { if (!icon.IsEmpty() && win_version != base::win::VERSION_PRE_XP) {
balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(icon.AsBitmap())); balloon_icon_ = IconUtil::CreateHICONFromSkBitmap(icon.AsBitmap());
icon_data.hBalloonIcon = balloon_icon_.Get(); icon_data.hBalloonIcon = balloon_icon_.get();
icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON; icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON;
} }

View file

@ -11,7 +11,7 @@
#include <string> #include <string>
#include "atom/browser/ui/tray_icon.h" #include "atom/browser/ui/tray_icon.h"
#include "base/basictypes.h" #include "base/macros.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/win/scoped_gdi_object.h" #include "base/win/scoped_gdi_object.h"

View file

@ -15,6 +15,7 @@
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "base/win/wrapped_window_proc.h" #include "base/win/wrapped_window_proc.h"
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
#include "ui/events/win/system_event_state_lookup.h"
#include "ui/gfx/win/hwnd_util.h" #include "ui/gfx/win/hwnd_util.h"
namespace atom { namespace atom {
@ -35,11 +36,11 @@ bool IsWinPressed() {
int GetKeyboardModifers() { int GetKeyboardModifers() {
int modifiers = ui::EF_NONE; int modifiers = ui::EF_NONE;
if (base::win::IsShiftPressed()) if (ui::win::IsShiftPressed())
modifiers |= ui::EF_SHIFT_DOWN; modifiers |= ui::EF_SHIFT_DOWN;
if (base::win::IsCtrlPressed()) if (ui::win::IsCtrlPressed())
modifiers |= ui::EF_CONTROL_DOWN; modifiers |= ui::EF_CONTROL_DOWN;
if (base::win::IsAltPressed()) if (ui::win::IsAltPressed())
modifiers |= ui::EF_ALT_DOWN; modifiers |= ui::EF_ALT_DOWN;
if (IsWinPressed()) if (IsWinPressed())
modifiers |= ui::EF_COMMAND_DOWN; modifiers |= ui::EF_COMMAND_DOWN;

View file

@ -91,7 +91,7 @@ bool TaskbarHost::SetThumbarButtons(
if (!button.icon.IsEmpty()) { if (!button.icon.IsEmpty()) {
thumb_button.dwMask |= THB_ICON; thumb_button.dwMask |= THB_ICON;
icons[i] = IconUtil::CreateHICONFromSkBitmap(button.icon.AsBitmap()); icons[i] = IconUtil::CreateHICONFromSkBitmap(button.icon.AsBitmap());
thumb_button.hIcon = icons[i].Get(); thumb_button.hIcon = icons[i].get();
} }
// Set tooltip. // Set tooltip.
@ -138,8 +138,8 @@ bool TaskbarHost::SetOverlayIcon(
base::win::ScopedHICON icon( base::win::ScopedHICON icon(
IconUtil::CreateHICONFromSkBitmap(overlay.AsBitmap())); IconUtil::CreateHICONFromSkBitmap(overlay.AsBitmap()));
return SUCCEEDED( return SUCCEEDED(taskbar_->SetOverlayIcon(
taskbar_->SetOverlayIcon(window, icon, base::UTF8ToUTF16(text).c_str())); window, icon.get(), base::UTF8ToUTF16(text).c_str()));
} }
bool TaskbarHost::HandleThumbarButtonEvent(int button_id) { bool TaskbarHost::HandleThumbarButtonEvent(int button_id) {

View file

@ -4,12 +4,15 @@
#include "atom/browser/web_contents_preferences.h" #include "atom/browser/web_contents_preferences.h"
#include <algorithm>
#include <string> #include <string>
#include <vector>
#include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h" #include "atom/common/options_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/common/web_preferences.h" #include "content/public/common/web_preferences.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
@ -23,9 +26,13 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::WebContentsPreferences);
namespace atom { namespace atom {
// static
std::vector<WebContentsPreferences*> WebContentsPreferences::instances_;
WebContentsPreferences::WebContentsPreferences( WebContentsPreferences::WebContentsPreferences(
content::WebContents* web_contents, content::WebContents* web_contents,
const mate::Dictionary& web_preferences) { const mate::Dictionary& web_preferences)
: web_contents_(web_contents) {
v8::Isolate* isolate = web_preferences.isolate(); v8::Isolate* isolate = web_preferences.isolate();
mate::Dictionary copied(isolate, web_preferences.GetHandle()->Clone()); mate::Dictionary copied(isolate, web_preferences.GetHandle()->Clone());
// Following fields should not be stored. // Following fields should not be stored.
@ -35,15 +42,31 @@ WebContentsPreferences::WebContentsPreferences(
mate::ConvertFromV8(isolate, copied.GetHandle(), &web_preferences_); mate::ConvertFromV8(isolate, copied.GetHandle(), &web_preferences_);
web_contents->SetUserData(UserDataKey(), this); web_contents->SetUserData(UserDataKey(), this);
instances_.push_back(this);
} }
WebContentsPreferences::~WebContentsPreferences() { WebContentsPreferences::~WebContentsPreferences() {
instances_.erase(
std::remove(instances_.begin(), instances_.end(), this),
instances_.end());
} }
void WebContentsPreferences::Merge(const base::DictionaryValue& extend) { void WebContentsPreferences::Merge(const base::DictionaryValue& extend) {
web_preferences_.MergeDictionary(&extend); web_preferences_.MergeDictionary(&extend);
} }
// static
content::WebContents* WebContentsPreferences::GetWebContentsFromProcessID(
int process_id) {
for (WebContentsPreferences* preferences : instances_) {
content::WebContents* web_contents = preferences->web_contents_;
if (web_contents->GetRenderProcessHost()->GetID() == process_id)
return web_contents;
}
return nullptr;
}
// static // static
void WebContentsPreferences::AppendExtraCommandLineSwitches( void WebContentsPreferences::AppendExtraCommandLineSwitches(
content::WebContents* web_contents, base::CommandLine* command_line) { content::WebContents* web_contents, base::CommandLine* command_line) {

View file

@ -5,6 +5,8 @@
#ifndef ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_ #ifndef ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
#define ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_ #define ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
#include <vector>
#include "base/values.h" #include "base/values.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
@ -26,6 +28,9 @@ namespace atom {
class WebContentsPreferences class WebContentsPreferences
: public content::WebContentsUserData<WebContentsPreferences> { : public content::WebContentsUserData<WebContentsPreferences> {
public: public:
// Get WebContents according to process ID.
static content::WebContents* GetWebContentsFromProcessID(int process_id);
// Append command paramters according to |web_contents|'s preferences. // Append command paramters according to |web_contents|'s preferences.
static void AppendExtraCommandLineSwitches( static void AppendExtraCommandLineSwitches(
content::WebContents* web_contents, base::CommandLine* command_line); content::WebContents* web_contents, base::CommandLine* command_line);
@ -47,6 +52,9 @@ class WebContentsPreferences
private: private:
friend class content::WebContentsUserData<WebContentsPreferences>; friend class content::WebContentsUserData<WebContentsPreferences>;
static std::vector<WebContentsPreferences*> instances_;
content::WebContents* web_contents_;
base::DictionaryValue web_preferences_; base::DictionaryValue web_preferences_;
DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences); DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);

View file

@ -9,6 +9,7 @@
#include "content/public/browser/guest_host.h" #include "content/public/browser/guest_host.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
namespace atom { namespace atom {
@ -101,13 +102,14 @@ void WebViewGuestDelegate::SetAllowTransparency(bool allow) {
auto render_view_host = web_contents()->GetRenderViewHost(); auto render_view_host = web_contents()->GetRenderViewHost();
guest_opaque_ = !allow; guest_opaque_ = !allow;
if (!render_view_host->GetView()) if (!render_view_host->GetWidget()->GetView())
return; return;
if (guest_opaque_) { if (guest_opaque_) {
render_view_host->GetView()->SetBackgroundColorToDefault(); render_view_host->GetWidget()->GetView()->SetBackgroundColorToDefault();
} else { } else {
render_view_host->GetView()->SetBackgroundColor(SK_ColorTRANSPARENT); render_view_host->GetWidget()->GetView()->SetBackgroundColor(
SK_ColorTRANSPARENT);
} }
} }
@ -123,7 +125,8 @@ void WebViewGuestDelegate::RenderViewReady() {
// WebContents::GetRenderWidgetHostView will return the RWHV of an // WebContents::GetRenderWidgetHostView will return the RWHV of an
// interstitial page if one is showing at this time. We only want opacity // interstitial page if one is showing at this time. We only want opacity
// to apply to web pages. // to apply to web pages.
auto render_view_host_view = web_contents()->GetRenderViewHost()->GetView(); auto render_view_host_view =
web_contents()->GetRenderViewHost()->GetWidget()->GetView();
if (guest_opaque_) if (guest_opaque_)
render_view_host_view->SetBackgroundColorToDefault(); render_view_host_view->SetBackgroundColorToDefault();
else else

View file

@ -7,7 +7,7 @@
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/macros.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/observer_list.h" #include "base/observer_list.h"

View file

@ -27,12 +27,12 @@ class Archive : public mate::Wrappable {
scoped_ptr<asar::Archive> archive(new asar::Archive(path)); scoped_ptr<asar::Archive> archive(new asar::Archive(path));
if (!archive->Init()) if (!archive->Init())
return v8::False(isolate); return v8::False(isolate);
return (new Archive(archive.Pass()))->GetWrapper(isolate); return (new Archive(std::move(archive)))->GetWrapper(isolate);
} }
protected: protected:
explicit Archive(scoped_ptr<asar::Archive> archive) explicit Archive(scoped_ptr<asar::Archive> archive)
: archive_(archive.Pass()) {} : archive_(std::move(archive)) {}
// Reads the offset and size of file. // Reads the offset and size of file.
v8::Local<v8::Value> GetFileInfo(v8::Isolate* isolate, v8::Local<v8::Value> GetFileInfo(v8::Isolate* isolate,

View file

@ -109,8 +109,8 @@ base::string16 ReadHtml(mate::Arguments* args) {
base::string16 data; base::string16 data;
base::string16 html; base::string16 html;
std::string url; std::string url;
uint32 start; uint32_t start;
uint32 end; uint32_t end;
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
clipboard->ReadHTML(GetClipboardType(args), &html, &url, &start, &end); clipboard->ReadHTML(GetClipboardType(args), &html, &url, &start, &end);
data = html.substr(start, end - start); data = html.substr(start, end - start);

View file

@ -158,11 +158,11 @@ bool ReadImageSkiaFromICO(gfx::ImageSkia* image, const base::FilePath& path) {
base::win::ScopedHICON icon(static_cast<HICON>( base::win::ScopedHICON icon(static_cast<HICON>(
LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON, 0, 0, LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON, 0, 0,
LR_DEFAULTSIZE | LR_LOADFROMFILE))); LR_DEFAULTSIZE | LR_LOADFROMFILE)));
if (!icon) if (!icon.get())
return false; return false;
// Convert the icon from the Windows specific HICON to gfx::ImageSkia. // Convert the icon from the Windows specific HICON to gfx::ImageSkia.
scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon)); scoped_ptr<SkBitmap> bitmap(IconUtil:: CreateSkBitmapFromHICON(icon.get()));
image->AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0f)); image->AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0f));
return true; return true;
} }

View file

@ -7,6 +7,7 @@
#include <list> #include <list>
#include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
#include "vendor/node/deps/uv/include/uv.h" #include "vendor/node/deps/uv/include/uv.h"

View file

@ -5,7 +5,7 @@
#ifndef ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_ #ifndef ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_
#define ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_ #define ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_
#include "base/basictypes.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"

View file

@ -90,12 +90,12 @@ bool GetNodeFromPath(std::string path,
} }
bool FillFileInfoWithNode(Archive::FileInfo* info, bool FillFileInfoWithNode(Archive::FileInfo* info,
uint32 header_size, uint32_t header_size,
const base::DictionaryValue* node) { const base::DictionaryValue* node) {
int size; int size;
if (!node->GetInteger("size", &size)) if (!node->GetInteger("size", &size))
return false; return false;
info->size = static_cast<uint32>(size); info->size = static_cast<uint32_t>(size);
if (node->GetBoolean("unpacked", &info->unpacked) && info->unpacked) if (node->GetBoolean("unpacked", &info->unpacked) && info->unpacked)
return true; return true;
@ -157,7 +157,7 @@ bool Archive::Init() {
return false; return false;
} }
uint32 size; uint32_t size;
if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())).ReadUInt32( if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())).ReadUInt32(
&size)) { &size)) {
LOG(ERROR) << "Failed to parse header size from " << path_.value(); LOG(ERROR) << "Failed to parse header size from " << path_.value();
@ -296,7 +296,7 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
#endif #endif
*out = temp_file->path(); *out = temp_file->path();
external_files_.set(path, temp_file.Pass()); external_files_.set(path, std::move(temp_file));
return true; return true;
} }

View file

@ -28,8 +28,8 @@ class Archive {
FileInfo() : unpacked(false), executable(false), size(0), offset(0) {} FileInfo() : unpacked(false), executable(false), size(0), offset(0) {}
bool unpacked; bool unpacked;
bool executable; bool executable;
uint32 size; uint32_t size;
uint64 offset; uint64_t offset;
}; };
struct Stats : public FileInfo { struct Stats : public FileInfo {
@ -71,7 +71,7 @@ class Archive {
base::FilePath path_; base::FilePath path_;
base::File file_; base::File file_;
int fd_; int fd_;
uint32 header_size_; uint32_t header_size_;
scoped_ptr<base::DictionaryValue> header_; scoped_ptr<base::DictionaryValue> header_;
// Cached external temporary files. // Cached external temporary files.

View file

@ -51,7 +51,7 @@ bool ScopedTemporaryFile::Init(const base::FilePath::StringType& ext) {
bool ScopedTemporaryFile::InitFromFile(base::File* src, bool ScopedTemporaryFile::InitFromFile(base::File* src,
const base::FilePath::StringType& ext, const base::FilePath::StringType& ext,
uint64 offset, uint64 size) { uint64_t offset, uint64_t size) {
if (!src->IsValid()) if (!src->IsValid())
return false; return false;

View file

@ -28,7 +28,7 @@ class ScopedTemporaryFile {
// Init an temporary file and fill it with content of |path|. // Init an temporary file and fill it with content of |path|.
bool InitFromFile(base::File* src, bool InitFromFile(base::File* src,
const base::FilePath::StringType& ext, const base::FilePath::StringType& ext,
uint64 offset, uint64 size); uint64_t offset, uint64_t size);
base::FilePath path() const { return path_; } base::FilePath path() const { return path_; }

View file

@ -8,7 +8,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/macros.h"
#include "build/build_config.h"
namespace atom { namespace atom {

View file

@ -8,7 +8,7 @@
#ifndef ATOM_COMMON_CHROME_VERSION_H_ #ifndef ATOM_COMMON_CHROME_VERSION_H_
#define ATOM_COMMON_CHROME_VERSION_H_ #define ATOM_COMMON_CHROME_VERSION_H_
#define CHROME_VERSION_STRING "47.0.2526.110" #define CHROME_VERSION_STRING "49.0.2623.75"
#define CHROME_VERSION "v" CHROME_VERSION_STRING #define CHROME_VERSION "v" CHROME_VERSION_STRING
#endif // ATOM_COMMON_CHROME_VERSION_H_ #endif // ATOM_COMMON_CHROME_VERSION_H_

View file

@ -10,7 +10,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/macros.h"
namespace crash_reporter { namespace crash_reporter {

View file

@ -48,7 +48,8 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
if (crashpad_client.StartHandler(handler_path, database_path, if (crashpad_client.StartHandler(handler_path, database_path,
submit_url, submit_url,
StringMap(), StringMap(),
std::vector<std::string>())) { std::vector<std::string>(),
true)) {
crashpad_client.UseHandler(); crashpad_client.UseHandler();
} }
} // @autoreleasepool } // @autoreleasepool

View file

@ -6,7 +6,11 @@
#ifndef ATOM_COMMON_CRASH_REPORTER_LINUX_CRASH_DUMP_HANDLER_H_ #ifndef ATOM_COMMON_CRASH_REPORTER_LINUX_CRASH_DUMP_HANDLER_H_
#define ATOM_COMMON_CRASH_REPORTER_LINUX_CRASH_DUMP_HANDLER_H_ #define ATOM_COMMON_CRASH_REPORTER_LINUX_CRASH_DUMP_HANDLER_H_
#include "base/basictypes.h" #include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "base/macros.h"
#include "vendor/breakpad/src/common/simple_string_dictionary.h" #include "vendor/breakpad/src/common/simple_string_dictionary.h"
namespace crash_reporter { namespace crash_reporter {

View file

@ -86,7 +86,7 @@ bool WriteReportIDToFile(const std::wstring& dump_path,
if (!file.is_open()) if (!file.is_open())
return false; return false;
int64 seconds_since_epoch = int64_t seconds_since_epoch =
(base::Time::Now() - base::Time::UnixEpoch()).InSeconds(); (base::Time::Now() - base::Time::UnixEpoch()).InSeconds();
std::wstring line = base::Int64ToString16(seconds_since_epoch); std::wstring line = base::Int64ToString16(seconds_since_epoch);
line += L','; line += L',';

View file

@ -7,7 +7,7 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/macros.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"

View file

@ -34,7 +34,7 @@ v8::Local<v8::Value> Converter<const net::URLRequest*>::ToV8(
scoped_ptr<base::ListValue> list(new base::ListValue); scoped_ptr<base::ListValue> list(new base::ListValue);
atom::GetUploadData(list.get(), val); atom::GetUploadData(list.get(), val);
if (!list->empty()) if (!list->empty())
dict->Set("uploadData", list.Pass()); dict->Set("uploadData", std::move(list));
return mate::ConvertToV8(isolate, *(dict.get())); return mate::ConvertToV8(isolate, *(dict.get()));
} }
@ -74,7 +74,7 @@ void GetUploadData(base::ListValue* upload_data_list,
const net::UploadDataStream* upload_data = request->get_upload(); const net::UploadDataStream* upload_data = request->get_upload();
if (!upload_data) if (!upload_data)
return; return;
const ScopedVector<net::UploadElementReader>* readers = const std::vector<scoped_ptr<net::UploadElementReader>>* readers =
upload_data->GetElementReaders(); upload_data->GetElementReaders();
for (const auto& reader : *readers) { for (const auto& reader : *readers) {
scoped_ptr<base::DictionaryValue> upload_data_dict( scoped_ptr<base::DictionaryValue> upload_data_dict(
@ -85,14 +85,14 @@ void GetUploadData(base::ListValue* upload_data_list,
scoped_ptr<base::Value> bytes( scoped_ptr<base::Value> bytes(
base::BinaryValue::CreateWithCopiedBuffer(bytes_reader->bytes(), base::BinaryValue::CreateWithCopiedBuffer(bytes_reader->bytes(),
bytes_reader->length())); bytes_reader->length()));
upload_data_dict->Set("bytes", bytes.Pass()); upload_data_dict->Set("bytes", std::move(bytes));
} else if (reader->AsFileReader()) { } else if (reader->AsFileReader()) {
const net::UploadFileElementReader* file_reader = const net::UploadFileElementReader* file_reader =
reader->AsFileReader(); reader->AsFileReader();
auto file_path = file_reader->path().AsUTF8Unsafe(); auto file_path = file_reader->path().AsUTF8Unsafe();
upload_data_dict->SetStringWithoutPathExpansion("file", file_path); upload_data_dict->SetStringWithoutPathExpansion("file", file_path);
} }
upload_data_list->Append(upload_data_dict.Pass()); upload_data_list->Append(std::move(upload_data_dict));
} }
} }

View file

@ -169,7 +169,7 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Array(
CHECK(!child_v8.IsEmpty()); CHECK(!child_v8.IsEmpty());
v8::TryCatch try_catch; v8::TryCatch try_catch;
result->Set(static_cast<uint32>(i), child_v8); result->Set(static_cast<uint32_t>(i), child_v8);
if (try_catch.HasCaught()) if (try_catch.HasCaught())
LOG(ERROR) << "Setter for index " << i << " threw an exception."; LOG(ERROR) << "Setter for index " << i << " threw an exception.";
} }
@ -298,7 +298,7 @@ base::Value* V8ValueConverter::FromV8Array(
base::ListValue* result = new base::ListValue(); base::ListValue* result = new base::ListValue();
// Only fields with integer keys are carried over to the ListValue. // Only fields with integer keys are carried over to the ListValue.
for (uint32 i = 0; i < val->Length(); ++i) { for (uint32_t i = 0; i < val->Length(); ++i) {
v8::TryCatch try_catch; v8::TryCatch try_catch;
v8::Local<v8::Value> child_v8 = val->Get(i); v8::Local<v8::Value> child_v8 = val->Get(i);
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
@ -345,7 +345,7 @@ base::Value* V8ValueConverter::FromV8Object(
scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
v8::Local<v8::Array> property_names(val->GetOwnPropertyNames()); v8::Local<v8::Array> property_names(val->GetOwnPropertyNames());
for (uint32 i = 0; i < property_names->Length(); ++i) { for (uint32_t i = 0; i < property_names->Length(); ++i) {
v8::Local<v8::Value> key(property_names->Get(i)); v8::Local<v8::Value> key(property_names->Get(i));
// Extend this test to cover more types as necessary and if sensible. // Extend this test to cover more types as necessary and if sensible.

View file

@ -5,7 +5,7 @@
#ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_ #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_ #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
#include "base/basictypes.h" #include "base/macros.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"

View file

@ -85,7 +85,7 @@ scoped_ptr<const char*[]> StringVectorToArgArray(
for (size_t i = 0; i < vector.size(); ++i) { for (size_t i = 0; i < vector.size(); ++i) {
array[i] = vector[i].c_str(); array[i] = vector[i].c_str();
} }
return array.Pass(); return array;
} }
base::FilePath GetResourcesPath(bool is_browser) { base::FilePath GetResourcesPath(bool is_browser) {

View file

@ -5,7 +5,7 @@
#ifndef ATOM_COMMON_NODE_BINDINGS_H_ #ifndef ATOM_COMMON_NODE_BINDINGS_H_
#define ATOM_COMMON_NODE_BINDINGS_H_ #define ATOM_COMMON_NODE_BINDINGS_H_
#include "base/basictypes.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
#include "vendor/node/deps/uv/include/uv.h" #include "vendor/node/deps/uv/include/uv.h"

View file

@ -21,13 +21,11 @@ namespace api {
namespace { namespace {
const int kMaxAutoCorrectWordSize = 8;
bool HasWordCharacters(const base::string16& text, int index) { bool HasWordCharacters(const base::string16& text, int index) {
const base::char16* data = text.data(); const base::char16* data = text.data();
int length = text.length(); int length = text.length();
while (index < length) { while (index < length) {
uint32 code = 0; uint32_t code = 0;
U16_NEXT(data, index, length, code); U16_NEXT(data, index, length, code);
UErrorCode error = U_ZERO_ERROR; UErrorCode error = U_ZERO_ERROR;
if (uscript_getScript(code, &error) != USCRIPT_COMMON) if (uscript_getScript(code, &error) != USCRIPT_COMMON)
@ -42,8 +40,7 @@ SpellCheckClient::SpellCheckClient(const std::string& language,
bool auto_spell_correct_turned_on, bool auto_spell_correct_turned_on,
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::Object> provider) v8::Local<v8::Object> provider)
: auto_spell_correct_turned_on_(auto_spell_correct_turned_on), : isolate_(isolate),
isolate_(isolate),
provider_(isolate, provider) { provider_(isolate, provider) {
character_attributes_.SetDefaultLanguage(language); character_attributes_.SetDefaultLanguage(language);
@ -96,14 +93,6 @@ void SpellCheckClient::requestCheckingOfText(
completionCallback->didFinishCheckingText(results); completionCallback->didFinishCheckingText(results);
} }
blink::WebString SpellCheckClient::autoCorrectWord(
const blink::WebString& misspelledWord) {
if (auto_spell_correct_turned_on_)
return GetAutoCorrectionWord(base::string16(misspelledWord));
else
return blink::WebString();
}
void SpellCheckClient::showSpellingUI(bool show) { void SpellCheckClient::showSpellingUI(bool show) {
} }
@ -170,53 +159,6 @@ bool SpellCheckClient::SpellCheckWord(const base::string16& word_to_check) {
return true; return true;
} }
base::string16 SpellCheckClient::GetAutoCorrectionWord(
const base::string16& word) {
base::string16 autocorrect_word;
int word_length = static_cast<int>(word.size());
if (word_length < 2 || word_length > kMaxAutoCorrectWordSize)
return autocorrect_word;
base::char16 misspelled_word[kMaxAutoCorrectWordSize + 1];
const base::char16* word_char = word.c_str();
for (int i = 0; i <= kMaxAutoCorrectWordSize; ++i) {
if (i >= word_length)
misspelled_word[i] = 0;
else
misspelled_word[i] = word_char[i];
}
// Swap adjacent characters and spellcheck.
int misspelling_start, misspelling_len;
for (int i = 0; i < word_length - 1; i++) {
// Swap.
std::swap(misspelled_word[i], misspelled_word[i + 1]);
// Check spelling.
misspelling_start = misspelling_len = 0;
spellCheck(blink::WebString(misspelled_word, word_length),
misspelling_start,
misspelling_len,
NULL);
// Make decision: if only one swap produced a valid word, then we want to
// return it. If we found two or more, we don't do autocorrection.
if (misspelling_len == 0) {
if (autocorrect_word.empty()) {
autocorrect_word.assign(misspelled_word);
} else {
autocorrect_word.clear();
break;
}
}
// Restore the swapped characters.
std::swap(misspelled_word[i], misspelled_word[i + 1]);
}
return autocorrect_word;
}
// Returns whether or not the given string is a valid contraction. // Returns whether or not the given string is a valid contraction.
// This function is a fall-back when the SpellcheckWordIterator class // This function is a fall-back when the SpellcheckWordIterator class
// returns a concatenated word which is not in the selected dictionary // returns a concatenated word which is not in the selected dictionary

View file

@ -41,8 +41,6 @@ class SpellCheckClient : public blink::WebSpellCheckClient {
const blink::WebVector<uint32_t>& markersInText, const blink::WebVector<uint32_t>& markersInText,
const blink::WebVector<unsigned>& markerOffsets, const blink::WebVector<unsigned>& markerOffsets,
blink::WebTextCheckingCompletion* completionCallback) override; blink::WebTextCheckingCompletion* completionCallback) override;
blink::WebString autoCorrectWord(
const blink::WebString& misspelledWord) override;
void showSpellingUI(bool show) override; void showSpellingUI(bool show) override;
bool isShowingSpellingUI() override; bool isShowingSpellingUI() override;
void updateSpellingUIWithMisspelledWord( void updateSpellingUIWithMisspelledWord(

View file

@ -4,7 +4,7 @@
#include "atom/renderer/node_array_buffer_bridge.h" #include "atom/renderer/node_array_buffer_bridge.h"
#include "base/basictypes.h" #include "base/macros.h"
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
#include "native_mate/converter.h" #include "native_mate/converter.h"
#include "third_party/WebKit/public/web/WebArrayBuffer.h" #include "third_party/WebKit/public/web/WebArrayBuffer.h"

View file

@ -12,7 +12,7 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/macros.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
namespace printing { namespace printing {

View file

@ -7,7 +7,7 @@
#include <map> #include <map>
#include "base/basictypes.h" #include "base/macros.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
namespace ui { namespace ui {

View file

@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_H_ #ifndef CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_H_
#define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_H_ #define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_H_
#include "base/basictypes.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "content/public/browser/desktop_media_id.h" #include "content/public/browser/desktop_media_id.h"

View file

@ -34,7 +34,7 @@ const int kDefaultUpdatePeriod = 1000;
// Returns a hash of a DesktopFrame content to detect when image for a desktop // Returns a hash of a DesktopFrame content to detect when image for a desktop
// media source has changed. // media source has changed.
uint32 GetFrameHash(webrtc::DesktopFrame* frame) { uint32_t GetFrameHash(webrtc::DesktopFrame* frame) {
int data_size = frame->stride() * frame->size().height(); int data_size = frame->stride() * frame->size().height();
return base::SuperFastHash(reinterpret_cast<char*>(frame->data()), data_size); return base::SuperFastHash(reinterpret_cast<char*>(frame->data()), data_size);
} }
@ -117,8 +117,8 @@ NativeDesktopMediaList::Worker::Worker(
scoped_ptr<webrtc::ScreenCapturer> screen_capturer, scoped_ptr<webrtc::ScreenCapturer> screen_capturer,
scoped_ptr<webrtc::WindowCapturer> window_capturer) scoped_ptr<webrtc::WindowCapturer> window_capturer)
: media_list_(media_list), : media_list_(media_list),
screen_capturer_(screen_capturer.Pass()), screen_capturer_(std::move(screen_capturer)),
window_capturer_(window_capturer.Pass()) { window_capturer_(std::move(window_capturer)) {
if (screen_capturer_) if (screen_capturer_)
screen_capturer_->Start(this); screen_capturer_->Start(this);
if (window_capturer_) if (window_capturer_)
@ -195,14 +195,14 @@ void NativeDesktopMediaList::Worker::Refresh(
// |current_frame_| may be NULL if capture failed (e.g. because window has // |current_frame_| may be NULL if capture failed (e.g. because window has
// been closed). // been closed).
if (current_frame_) { if (current_frame_) {
uint32 frame_hash = GetFrameHash(current_frame_.get()); uint32_t frame_hash = GetFrameHash(current_frame_.get());
new_image_hashes[source.id] = frame_hash; new_image_hashes[source.id] = frame_hash;
// Scale the image only if it has changed. // Scale the image only if it has changed.
ImageHashesMap::iterator it = image_hashes_.find(source.id); ImageHashesMap::iterator it = image_hashes_.find(source.id);
if (it == image_hashes_.end() || it->second != frame_hash) { if (it == image_hashes_.end() || it->second != frame_hash) {
gfx::ImageSkia thumbnail = gfx::ImageSkia thumbnail =
ScaleDesktopFrame(current_frame_.Pass(), thumbnail_size); ScaleDesktopFrame(std::move(current_frame_), thumbnail_size);
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::Bind(&NativeDesktopMediaList::OnSourceThumbnail, base::Bind(&NativeDesktopMediaList::OnSourceThumbnail,
@ -231,8 +231,8 @@ void NativeDesktopMediaList::Worker::OnCaptureCompleted(
NativeDesktopMediaList::NativeDesktopMediaList( NativeDesktopMediaList::NativeDesktopMediaList(
scoped_ptr<webrtc::ScreenCapturer> screen_capturer, scoped_ptr<webrtc::ScreenCapturer> screen_capturer,
scoped_ptr<webrtc::WindowCapturer> window_capturer) scoped_ptr<webrtc::WindowCapturer> window_capturer)
: screen_capturer_(screen_capturer.Pass()), : screen_capturer_(std::move(screen_capturer)),
window_capturer_(window_capturer.Pass()), window_capturer_(std::move(window_capturer)),
update_period_(base::TimeDelta::FromMilliseconds(kDefaultUpdatePeriod)), update_period_(base::TimeDelta::FromMilliseconds(kDefaultUpdatePeriod)),
thumbnail_size_(100, 100), thumbnail_size_(100, 100),
view_dialog_id_(-1), view_dialog_id_(-1),
@ -269,7 +269,8 @@ void NativeDesktopMediaList::StartUpdating(DesktopMediaListObserver* observer) {
observer_ = observer; observer_ = observer;
worker_.reset(new Worker(weak_factory_.GetWeakPtr(), worker_.reset(new Worker(weak_factory_.GetWeakPtr(),
screen_capturer_.Pass(), window_capturer_.Pass())); std::move(screen_capturer_),
std::move(window_capturer_)));
Refresh(); Refresh();
} }

View file

@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ #ifndef CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_
#define CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ #define CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"

View file

@ -109,21 +109,21 @@ class PdfToEmfUtilityProcessHostClient
private: private:
class GetPageCallbackData { class GetPageCallbackData {
MOVE_ONLY_TYPE_FOR_CPP_03(GetPageCallbackData, RValue); MOVE_ONLY_TYPE_FOR_CPP_03(GetPageCallbackData);
public: public:
GetPageCallbackData(int page_number, GetPageCallbackData(int page_number,
PdfToEmfConverter::GetPageCallback callback) PdfToEmfConverter::GetPageCallback callback)
: page_number_(page_number), callback_(callback) {} : page_number_(page_number), callback_(callback) {}
// Move constructor for STL. GetPageCallbackData(GetPageCallbackData&& other) {
GetPageCallbackData(RValue other) { this->operator=(other); } *this = std::move(other);
}
// Move assignment for STL. GetPageCallbackData& operator=(GetPageCallbackData&& rhs) {
GetPageCallbackData& operator=(RValue rhs) { page_number_ = rhs.page_number_;
page_number_ = rhs.object->page_number_; callback_ = rhs.callback_;
callback_ = rhs.object->callback_; emf_ = std::move(rhs.emf_);
emf_ = rhs.object->emf_.Pass();
return *this; return *this;
} }
@ -256,7 +256,7 @@ void LazyEmf::Close() const {
bool LazyEmf::LoadEmf(Emf* emf) const { bool LazyEmf::LoadEmf(Emf* emf) const {
file_->Seek(base::File::FROM_BEGIN, 0); file_->Seek(base::File::FROM_BEGIN, 0);
int64 size = file_->GetLength(); int64_t size = file_->GetLength();
if (size <= 0) if (size <= 0)
return false; return false;
std::vector<char> data(size); std::vector<char> data(size);

View file

@ -441,7 +441,7 @@ void PrintJob::HoldUntilStopIsCalled() {
} }
void PrintJob::Quit() { void PrintJob::Quit() {
base::MessageLoop::current()->Quit(); base::MessageLoop::current()->QuitWhenIdle();
} }
// Takes settings_ ownership and will be deleted in the receiving thread. // Takes settings_ ownership and will be deleted in the receiving thread.

View file

@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_H_ #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_H_
#define CHROME_BROWSER_PRINTING_PRINT_JOB_H_ #define CHROME_BROWSER_PRINTING_PRINT_JOB_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"

View file

@ -118,7 +118,7 @@ void PrintPreviewMessageHandler::PrintToPDF(
} }
void PrintPreviewMessageHandler::RunPrintToPDFCallback( void PrintPreviewMessageHandler::RunPrintToPDFCallback(
int request_id, uint32 data_size, char* data) { int request_id, uint32_t data_size, char* data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();

View file

@ -47,7 +47,7 @@ class PrintPreviewMessageHandler
const PrintHostMsg_DidPreviewDocument_Params& params); const PrintHostMsg_DidPreviewDocument_Params& params);
void OnPrintPreviewFailed(int document_cookie, int request_id); void OnPrintPreviewFailed(int document_cookie, int request_id);
void RunPrintToPDFCallback(int request_id, uint32 data_size, char* data); void RunPrintToPDFCallback(int request_id, uint32_t data_size, char* data);
PrintToPDFCallbackMap print_to_pdf_callback_map_; PrintToPDFCallbackMap print_to_pdf_callback_map_;

View file

@ -144,7 +144,7 @@ void PrintViewManagerBase::OnDidPrintPage(
#if !defined(OS_WIN) #if !defined(OS_WIN)
// Update the rendered document. It will send notifications to the listener. // Update the rendered document. It will send notifications to the listener.
document->SetPage(params.page_number, document->SetPage(params.page_number,
metafile.Pass(), std::move(metafile),
params.page_size, params.page_size,
params.content_area); params.content_area);
@ -305,7 +305,7 @@ void PrintViewManagerBase::ShouldQuitFromInnerMessageLoop() {
inside_inner_message_loop_) { inside_inner_message_loop_) {
// We are in a message loop created by RenderAllMissingPagesNow. Quit from // We are in a message loop created by RenderAllMissingPagesNow. Quit from
// it. // it.
base::MessageLoop::current()->Quit(); base::MessageLoop::current()->QuitWhenIdle();
inside_inner_message_loop_ = false; inside_inner_message_loop_ = false;
} }
} }
@ -411,9 +411,9 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
// memory-bound. // memory-bound.
static const int kPrinterSettingsTimeout = 60000; static const int kPrinterSettingsTimeout = 60000;
base::OneShotTimer quit_timer; base::OneShotTimer quit_timer;
quit_timer.Start(FROM_HERE, quit_timer.Start(
TimeDelta::FromMilliseconds(kPrinterSettingsTimeout), FROM_HERE, TimeDelta::FromMilliseconds(kPrinterSettingsTimeout),
base::MessageLoop::current(), &base::MessageLoop::Quit); base::MessageLoop::current(), &base::MessageLoop::QuitWhenIdle);
inside_inner_message_loop_ = true; inside_inner_message_loop_ = true;

View file

@ -394,7 +394,7 @@ void PrintingMessageFilter::OnUpdatePrintSettings(
printer_query = queue_->CreatePrinterQuery(host_id, routing_id); printer_query = queue_->CreatePrinterQuery(host_id, routing_id);
} }
printer_query->SetSettings( printer_query->SetSettings(
new_settings.Pass(), std::move(new_settings),
base::Bind(&PrintingMessageFilter::OnUpdatePrintSettingsReply, this, base::Bind(&PrintingMessageFilter::OnUpdatePrintSettingsReply, this,
printer_query, reply_msg)); printer_query, reply_msg));
} }

View file

@ -107,7 +107,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
#if defined(ENABLE_FULL_PRINTING) #if defined(ENABLE_FULL_PRINTING)
// Check to see if print preview has been cancelled. // Check to see if print preview has been cancelled.
void OnCheckForCancel(int32 preview_ui_id, void OnCheckForCancel(int32_t preview_ui_id,
int preview_request_id, int preview_request_id,
bool* cancel); bool* cancel);
#endif #endif

View file

@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_PRINTING_PRINTING_UI_WEB_CONTENTS_OBSERVER_H_ #ifndef CHROME_BROWSER_PRINTING_PRINTING_UI_WEB_CONTENTS_OBSERVER_H_
#define CHROME_BROWSER_PRINTING_PRINTING_UI_WEB_CONTENTS_OBSERVER_H_ #define CHROME_BROWSER_PRINTING_PRINTING_UI_WEB_CONTENTS_OBSERVER_H_
#include "base/basictypes.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"

View file

@ -12,7 +12,6 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include "base/basictypes.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"

View file

@ -54,7 +54,6 @@
#include "atom/common/atom_command_line.h" #include "atom/common/atom_command_line.h"
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/basictypes.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
@ -75,6 +74,7 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
@ -222,7 +222,7 @@ int SetupSocketOnly() {
int sock = socket(PF_UNIX, SOCK_STREAM, 0); int sock = socket(PF_UNIX, SOCK_STREAM, 0);
PCHECK(sock >= 0) << "socket() failed"; PCHECK(sock >= 0) << "socket() failed";
int rv = net::SetNonBlocking(sock); int rv = base::SetNonBlocking(sock);
DCHECK_EQ(0, rv) << "Failed to make non-blocking socket."; DCHECK_EQ(0, rv) << "Failed to make non-blocking socket.";
rv = SetCloseOnExec(sock); rv = SetCloseOnExec(sock);
DCHECK_EQ(0, rv) << "Failed to set CLOEXEC on socket."; DCHECK_EQ(0, rv) << "Failed to set CLOEXEC on socket.";
@ -577,7 +577,7 @@ void ProcessSingleton::LinuxWatcher::OnFileCanReadWithoutBlocking(int fd) {
PLOG(ERROR) << "accept() failed"; PLOG(ERROR) << "accept() failed";
return; return;
} }
int rv = net::SetNonBlocking(connection_socket); int rv = base::SetNonBlocking(connection_socket);
DCHECK_EQ(0, rv) << "Failed to make non-blocking socket."; DCHECK_EQ(0, rv) << "Failed to make non-blocking socket.";
SocketReader* reader = new SocketReader(this, SocketReader* reader = new SocketReader(this,
ui_message_loop_, ui_message_loop_,
@ -990,8 +990,8 @@ bool ProcessSingleton::Create() {
// In Electron the ProcessSingleton is created earlier than the IO // In Electron the ProcessSingleton is created earlier than the IO
// thread gets created, so we have to postpone the call until message // thread gets created, so we have to postpone the call until message
// loop is up an running. // loop is up an running.
scoped_refptr<base::SingleThreadTaskRunner> task_runner( scoped_refptr<base::SingleThreadTaskRunner> task_runner =
base::ThreadTaskRunnerHandle::Get()); base::ThreadTaskRunnerHandle::Get();
task_runner->PostTask( task_runner->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&ProcessSingleton::StartListening, base::Bind(&ProcessSingleton::StartListening,

View file

@ -16,7 +16,6 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/win/metro.h"
#include "base/win/registry.h" #include "base/win/registry.h"
#include "base/win/scoped_handle.h" #include "base/win/scoped_handle.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"

View file

@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_ #ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_
#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_ #define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_
#include "base/basictypes.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "ppapi/host/host_message_context.h" #include "ppapi/host/host_message_context.h"

View file

@ -240,8 +240,8 @@ int32_t PepperFlashClipboardMessageFilter::OnMsgReadData(
base::string16 html; base::string16 html;
std::string url; std::string url;
uint32 fragment_start; uint32_t fragment_start;
uint32 fragment_end; uint32_t fragment_end;
clipboard->ReadHTML(type, &html, &url, &fragment_start, &fragment_end); clipboard->ReadHTML(type, &html, &url, &fragment_start, &fragment_end);
result = PP_OK; result = PP_OK;
clipboard_string = base::UTF16ToUTF8( clipboard_string = base::UTF16ToUTF8(

View file

@ -8,8 +8,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ppapi/host/resource_message_filter.h" #include "ppapi/host/resource_message_filter.h"
#include "ppapi/shared_impl/flash_clipboard_format_registry.h" #include "ppapi/shared_impl/flash_clipboard_format_registry.h"

View file

@ -87,7 +87,7 @@ bool TtsPlatformImplWin::Speak(
// 0.1 -> -10 // 0.1 -> -10
// 1.0 -> 0 // 1.0 -> 0
// 10.0 -> 10 // 10.0 -> 10
speech_synthesizer_->SetRate(static_cast<int32>(10 * log10(params.rate))); speech_synthesizer_->SetRate(static_cast<int32_t>(10 * log10(params.rate)));
} }
if (params.pitch >= 0.0) { if (params.pitch >= 0.0) {
@ -102,7 +102,7 @@ bool TtsPlatformImplWin::Speak(
if (params.volume >= 0.0) { if (params.volume >= 0.0) {
// The TTS api allows a range of 0 to 100 for speech volume. // The TTS api allows a range of 0 to 100 for speech volume.
speech_synthesizer_->SetVolume(static_cast<uint16>(params.volume * 100)); speech_synthesizer_->SetVolume(static_cast<uint16_t>(params.volume * 100));
} }
// TODO(dmazzoni): convert SSML to SAPI xml. http://crbug.com/88072 // TODO(dmazzoni): convert SSML to SAPI xml. http://crbug.com/88072

Some files were not shown because too many files have changed in this diff Show more