Skip to content

Commit

Permalink
Merge pull request #7104 from electron/chrome53
Browse files Browse the repository at this point in the history
Upgrade to Chrome 53 and Node 6.5.0
  • Loading branch information
zcbenz authored Sep 14, 2016
2 parents cfe7bfd + dc2ced1 commit 4627311
Show file tree
Hide file tree
Showing 69 changed files with 509 additions and 285 deletions.
3 changes: 2 additions & 1 deletion atom/browser/api/atom_api_content_tracing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/node_includes.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "content/public/browser/tracing_controller.h"
#include "native_mate/dictionary.h"

#include "atom/common/node_includes.h"

using content::TracingController;

namespace mate {
Expand Down
7 changes: 4 additions & 3 deletions atom/browser/api/atom_api_debugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/web_contents.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"

#include "atom/common/node_includes.h"

using content::DevToolsAgentHost;

namespace atom {
Expand Down Expand Up @@ -107,7 +108,7 @@ bool Debugger::IsAttached() {
void Debugger::Detach() {
if (!agent_host_.get())
return;
agent_host_->DetachClient();
agent_host_->DetachClient(this);
AgentHostClosed(agent_host_.get(), false);
agent_host_ = nullptr;
}
Expand Down Expand Up @@ -136,7 +137,7 @@ void Debugger::SendCommand(mate::Arguments* args) {

std::string json_args;
base::JSONWriter::Write(request, &json_args);
agent_host_->DispatchProtocolMessage(json_args);
agent_host_->DispatchProtocolMessage(this, json_args);
}

// static
Expand Down
3 changes: 2 additions & 1 deletion atom/browser/api/atom_api_download_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/node_includes.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "native_mate/dictionary.h"
#include "net/base/filename_util.h"

#include "atom/common/node_includes.h"

namespace mate {

template<>
Expand Down
3 changes: 2 additions & 1 deletion atom/browser/api/atom_api_power_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#include "atom/browser/api/atom_api_power_monitor.h"

#include "atom/browser/browser.h"
#include "atom/common/node_includes.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_device_source.h"
#include "native_mate/dictionary.h"

#include "atom/common/node_includes.h"

namespace atom {

namespace api {
Expand Down
35 changes: 20 additions & 15 deletions atom/browser/api/atom_api_power_save_blocker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

#include <string>

#include "atom/common/node_includes.h"
#include "content/public/browser/power_save_blocker.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/dictionary.h"

#include "atom/common/node_includes.h"

namespace mate {

template<>
struct Converter<content::PowerSaveBlocker::PowerSaveBlockerType> {
struct Converter<device::PowerSaveBlocker::PowerSaveBlockerType> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
content::PowerSaveBlocker::PowerSaveBlockerType* out) {
using content::PowerSaveBlocker;
device::PowerSaveBlocker::PowerSaveBlockerType* out) {
using device::PowerSaveBlocker;
std::string type;
if (!ConvertFromV8(isolate, val, &type))
return false;
Expand All @@ -39,7 +40,7 @@ namespace api {

PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
: current_blocker_type_(
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) {
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) {
Init(isolate);
}

Expand All @@ -58,30 +59,34 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
// higher precedence level than |kPowerSaveBlockPreventAppSuspension|.
//
// Only the highest-precedence blocker type takes effect.
content::PowerSaveBlocker::PowerSaveBlockerType new_blocker_type =
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension;
device::PowerSaveBlocker::PowerSaveBlockerType new_blocker_type =
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension;
for (const auto& element : power_save_blocker_types_) {
if (element.second ==
content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep) {
device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep) {
new_blocker_type =
content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
break;
}
}

if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
std::unique_ptr<content::PowerSaveBlocker> new_blocker =
content::PowerSaveBlocker::Create(
std::unique_ptr<device::PowerSaveBlocker> new_blocker(
new device::PowerSaveBlocker(
new_blocker_type,
content::PowerSaveBlocker::kReasonOther,
ATOM_PRODUCT_NAME);
device::PowerSaveBlocker::kReasonOther,
ATOM_PRODUCT_NAME,
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE)));
power_save_blocker_.swap(new_blocker);
current_blocker_type_ = new_blocker_type;
}
}

int PowerSaveBlocker::Start(
content::PowerSaveBlocker::PowerSaveBlockerType type) {
device::PowerSaveBlocker::PowerSaveBlockerType type) {
static int count = 0;
power_save_blocker_types_[count] = type;
UpdatePowerSaveBlocker();
Expand Down
10 changes: 5 additions & 5 deletions atom/browser/api/atom_api_power_save_blocker.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <memory>

#include "atom/browser/api/trackable_object.h"
#include "content/public/browser/power_save_blocker.h"
#include "device/power_save_blocker/power_save_blocker.h"
#include "native_mate/handle.h"

namespace mate {
Expand All @@ -33,18 +33,18 @@ class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {

private:
void UpdatePowerSaveBlocker();
int Start(content::PowerSaveBlocker::PowerSaveBlockerType type);
int Start(device::PowerSaveBlocker::PowerSaveBlockerType type);
bool Stop(int id);
bool IsStarted(int id);

std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_;
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;

// Currnet blocker type used by |power_save_blocker_|
content::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;
device::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;

// Map from id to the corresponding blocker type for each request.
using PowerSaveBlockerTypeMap =
std::map<int, content::PowerSaveBlocker::PowerSaveBlockerType>;
std::map<int, device::PowerSaveBlocker::PowerSaveBlockerType>;
PowerSaveBlockerTypeMap power_save_blocker_types_;

DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
Expand Down
3 changes: 2 additions & 1 deletion atom/browser/api/atom_api_render_process_preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "content/public/browser/render_process_host.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"

#include "atom/common/node_includes.h"

namespace atom {

namespace api {
Expand Down
30 changes: 14 additions & 16 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -77,6 +76,8 @@
#include "ui/aura/window.h"
#endif

#include "atom/common/node_includes.h"

namespace {

struct PrintSettings {
Expand Down Expand Up @@ -527,22 +528,18 @@ void WebContents::FindReply(content::WebContents* web_contents,
const gfx::Rect& selection_rect,
int active_match_ordinal,
bool final_update) {
if (!final_update)
return;

v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());

mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate());
if (number_of_matches == -1) {
result.Set("requestId", request_id);
result.Set("selectionArea", selection_rect);
result.Set("finalUpdate", final_update);
result.Set("activeMatchOrdinal", active_match_ordinal);
Emit("found-in-page", result);
} else if (final_update) {
result.Set("requestId", request_id);
result.Set("matches", number_of_matches);
result.Set("finalUpdate", final_update);
Emit("found-in-page", result);
}
result.Set("requestId", request_id);
result.Set("matches", number_of_matches);
result.Set("selectionArea", selection_rect);
result.Set("activeMatchOrdinal", active_match_ordinal);
result.Set("finalUpdate", final_update); // Deprecate after 2.0
Emit("found-in-page", result);
}

bool WebContents::CheckMediaAccessPermission(
Expand Down Expand Up @@ -871,7 +868,8 @@ void WebContents::DownloadURL(const GURL& url) {
content::BrowserContext::GetDownloadManager(browser_context);

download_manager->DownloadUrl(
content::DownloadUrlParameters::FromWebContents(web_contents(), url));
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents(), url));
}

GURL WebContents::GetURL() const {
Expand Down Expand Up @@ -1177,7 +1175,7 @@ void WebContents::ShowDefinitionForSelection() {
}

void WebContents::CopyImageAt(int x, int y) {
const auto host = web_contents()->GetRenderViewHost();
const auto host = web_contents()->GetMainFrame();
if (host)
host->CopyImageAt(x, y);
}
Expand Down
3 changes: 2 additions & 1 deletion atom/browser/api/atom_api_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "content/public/browser/render_process_host.h"
Expand All @@ -31,6 +30,8 @@
#include "atom/browser/ui/win/taskbar_host.h"
#endif

#include "atom/common/node_includes.h"

#if defined(OS_WIN)
namespace mate {

Expand Down
3 changes: 2 additions & 1 deletion atom/browser/api/frame_subscriber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
#include "atom/browser/api/frame_subscriber.h"

#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/node_includes.h"
#include "base/bind.h"
#include "content/public/browser/render_widget_host.h"

#include "atom/common/node_includes.h"

namespace atom {

namespace api {
Expand Down
72 changes: 47 additions & 25 deletions atom/browser/atom_access_token_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/geolocation_provider.h"

using content::BrowserThread;

namespace atom {

namespace {
Expand All @@ -22,6 +24,49 @@ const char* kGeolocationProviderURL =
"https://www.googleapis.com/geolocation/v1/geolocate?key="
GOOGLEAPIS_API_KEY;

// Loads access tokens and other necessary data on the UI thread, and
// calls back to the originator on the originating thread.
class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
public:
explicit TokenLoadingJob(
const content::AccessTokenStore::LoadAccessTokensCallback& callback)
: callback_(callback), request_context_getter_(nullptr) {}

void Run() {
BrowserThread::PostTaskAndReply(
BrowserThread::UI,
FROM_HERE,
base::Bind(&TokenLoadingJob::PerformWorkOnUIThread, this),
base::Bind(&TokenLoadingJob::RespondOnOriginatingThread, this));
}

private:
friend class base::RefCountedThreadSafe<TokenLoadingJob>;

~TokenLoadingJob() {}

void PerformWorkOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto browser_context = AtomBrowserContext::From("", false);
request_context_getter_ = browser_context->GetRequestContext();
}

void RespondOnOriginatingThread() {
// Equivelent to access_token_map[kGeolocationProviderURL].
// Somehow base::string16 is causing compilation errors when used in a pair
// of std::map on Linux, this can work around it.
content::AccessTokenStore::AccessTokenMap access_token_map;
std::pair<GURL, base::string16> token_pair;
token_pair.first = GURL(kGeolocationProviderURL);
access_token_map.insert(token_pair);

callback_.Run(access_token_map, request_context_getter_);
}

content::AccessTokenStore::LoadAccessTokensCallback callback_;
net::URLRequestContextGetter* request_context_getter_;
};

} // namespace

AtomAccessTokenStore::AtomAccessTokenStore() {
Expand All @@ -33,35 +78,12 @@ AtomAccessTokenStore::~AtomAccessTokenStore() {

void AtomAccessTokenStore::LoadAccessTokens(
const LoadAccessTokensCallback& callback) {
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&AtomAccessTokenStore::GetRequestContextOnUIThread, this),
base::Bind(&AtomAccessTokenStore::RespondOnOriginatingThread,
this, callback));
scoped_refptr<TokenLoadingJob> job(new TokenLoadingJob(callback));
job->Run();
}

void AtomAccessTokenStore::SaveAccessToken(const GURL& server_url,
const base::string16& access_token) {
}

void AtomAccessTokenStore::GetRequestContextOnUIThread() {
auto browser_context = AtomBrowserContext::From("", false);
request_context_getter_ = browser_context->GetRequestContext();
}

void AtomAccessTokenStore::RespondOnOriginatingThread(
const LoadAccessTokensCallback& callback) {
// Equivelent to access_token_map[kGeolocationProviderURL].
// Somehow base::string16 is causing compilation errors when used in a pair
// of std::map on Linux, this can work around it.
AccessTokenMap access_token_map;
std::pair<GURL, base::string16> token_pair;
token_pair.first = GURL(kGeolocationProviderURL);
access_token_map.insert(token_pair);

callback.Run(access_token_map, request_context_getter_.get());
request_context_getter_ = nullptr;
}

} // namespace atom
Loading

0 comments on commit 4627311

Please sign in to comment.