Skip to content

Commit df6e7a3

Browse files
GnorTechrogerwang
authored andcommitted
rebase to Chromium 61
1 parent 0cbe755 commit df6e7a3

11 files changed

+50
-48
lines changed

src/api/nw_clipboard_api.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace extensions {
2626
namespace {
2727
const char* kPNGDataUriPrefix = "data:image/png;base64,";
2828
const char* kJPEGDataUriPrefix = "data:image/jpeg;base64,";
29-
const int kQulity = 100;
29+
const int kQuality = 100;
3030

3131
class ClipboardReader {
3232
public:
@@ -103,13 +103,7 @@ namespace {
103103
error_ = "Failed to encode as PNG";
104104
return false;
105105
} else if (data.type == TYPE_JPEG &&
106-
!gfx::JPEGCodec::Encode(reinterpret_cast<const unsigned char*>(bitmap.getPixels()),
107-
gfx::JPEGCodec::FORMAT_SkBitmap,
108-
bitmap.width(),
109-
bitmap.height(),
110-
bitmap.rowBytes(),
111-
kQulity,
112-
&encoded_image)) {
106+
!gfx::JPEGCodec::Encode(bitmap, kQuality, &encoded_image)) {
113107
LOG(INFO) << "NwClipboardGetSyncFunction::RunSync(" << nwapi::nw__clipboard::ToString(data.type) << ") failed when converting to JPEG";
114108
error_ = "Failed to encode as JPEG";
115109
return false;

src/api/nw_screen_api.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,8 @@ namespace extensions {
204204

205205
webrtc::DesktopCaptureOptions options = webrtc::DesktopCaptureOptions::CreateDefault();
206206
options.set_disable_effects(false);
207-
std::unique_ptr<webrtc::DesktopCapturer> screenCapturer(screens ? webrtc::DesktopCapturer::CreateScreenCapturer(options) : nullptr);
208-
std::unique_ptr<webrtc::DesktopCapturer> windowCapturer(windows ? webrtc::DesktopCapturer::CreateWindowCapturer(options) : nullptr);
209207

210-
media_list_.reset(new NativeDesktopMediaList(std::move(screenCapturer), std::move(windowCapturer)));
208+
media_list_.reset(new NativeDesktopMediaList(content::DesktopMediaID::TYPE_SCREEN, webrtc::DesktopCapturer::CreateScreenCapturer(options)));
211209

212210
media_list_->StartUpdating(this);
213211
}

src/api/nw_window_api.cc

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,7 @@ void NwCurrentWindowInternalCapturePageInternalFunction::OnCaptureSuccess(const
255255
std::string mime_type;
256256
switch (image_format_) {
257257
case api::extension_types::IMAGE_FORMAT_JPEG:
258-
encoded = gfx::JPEGCodec::Encode(
259-
reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
260-
gfx::JPEGCodec::FORMAT_SkBitmap,
261-
bitmap.width(),
262-
bitmap.height(),
263-
static_cast<int>(bitmap.rowBytes()),
264-
image_quality_,
265-
&data);
258+
encoded = gfx::JPEGCodec::Encode(bitmap, image_quality_, &data);
266259
mime_type = kMimeTypeJpeg;
267260
break;
268261
case api::extension_types::IMAGE_FORMAT_PNG:
@@ -694,8 +687,8 @@ bool NwCurrentWindowInternalGetWinParamInternalFunction::RunNWSync(base::ListVal
694687
int frame_id = created_frame->GetRoutingID();
695688

696689
base::DictionaryValue* result = new base::DictionaryValue;
697-
result->Set("frameId", new base::Value(frame_id));
698-
result->Set("id", new base::Value(app_window->window_key()));
690+
result->Set("frameId", base::MakeUnique<base::Value>(frame_id));
691+
result->Set("id", base::MakeUnique<base::Value>(app_window->window_key()));
699692
app_window->GetSerializedState(result);
700693

701694
response->Append(base::WrapUnique(result));

src/browser/menubar_view.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class MenuBarButton : public views::MenuButton {
5757
};
5858

5959
MenuBarView::MenuBarView() {
60-
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
60+
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, gfx::Insets(), 0));
6161
}
6262

6363
MenuBarView::~MenuBarView() {
@@ -114,7 +114,7 @@ void MenuBarView::ButtonPressed(views::Button* sender,
114114

115115
void MenuBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
116116
// Use menu background color for menubar
117-
set_background(views::Background::CreateSolidBackground(theme->
117+
SetBackground(views::CreateSolidBackground(theme->
118118
GetSystemColor(ui::NativeTheme::kColorId_MenuBackgroundColor)));
119119
// Force to repaint the menubar
120120
SchedulePaint();

src/browser/nw_chrome_browser_hooks.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "extensions/common/extension.h"
4949

5050
#include "net/cert/x509_certificate.h"
51+
#include "net/url_request/url_request_context.h"
5152
#include "sql/connection.h"
5253
#include "sql/meta_table.h"
5354
#include "sql/transaction.h"
@@ -173,7 +174,7 @@ bool GetDirUserData(base::FilePath *user_data_dir) {
173174

174175
void SetTrustAnchorsOnIOThread(IOThread* io_thread, const net::CertificateList& trust_anchors) {
175176
PolicyCertVerifier* verifier =
176-
(PolicyCertVerifier*)io_thread->globals()->cert_verifier.get();
177+
(PolicyCertVerifier*)io_thread->globals()->system_request_context->cert_verifier();
177178
verifier->SetTrustAnchors(trust_anchors);
178179
}
179180

src/browser/nw_extensions_browser_hooks.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void AmendManifestStringList(base::DictionaryValue* manifest,
106106

107107
pattern_list->Append(base::WrapUnique(new base::Value(string_value)));
108108
if (!amend)
109-
manifest->Set(path, pattern_list);
109+
manifest->Set(path, base::WrapUnique(pattern_list));
110110
}
111111

112112
void AmendManifestList(base::DictionaryValue* manifest,
@@ -121,7 +121,7 @@ void AmendManifestList(base::DictionaryValue* manifest,
121121
}
122122
} else {
123123
pattern_list = list_value.DeepCopy();
124-
manifest->Set(path, pattern_list);
124+
manifest->Set(path, base::WrapUnique(pattern_list));
125125
}
126126
}
127127

@@ -223,7 +223,7 @@ void LoadNWAppAsExtensionHook(base::DictionaryValue* manifest,
223223
return;
224224
}
225225

226-
manifest->Set(manifest_keys::kNWJSInternalManifest, package->root()->DeepCopy());
226+
manifest->Set(manifest_keys::kNWJSInternalManifest, base::WrapUnique(package->root()->DeepCopy()));
227227

228228
if (manifest->GetString(manifest_keys::kNWJSMain, &main_url)) {
229229
if (base::EndsWith(main_url, ".js", base::CompareCase::INSENSITIVE_ASCII)) {

src/nw_custom_bindings.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ using namespace blink;
2424
#endif
2525

2626
//#undef FROM_HERE
27+
#if 0
2728
#undef TRACE_EVENT0
2829
#undef TRACE_EVENT1
2930
#undef TRACE_EVENT2
@@ -43,18 +44,19 @@ using namespace blink;
4344
#undef TRACE_EVENT_SCOPED_SAMPLING_STATE_FOR_BUCKET
4445
#undef TRACE_EVENT_GET_SAMPLING_STATE_FOR_BUCKET
4546
#undef TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET
46-
#undef TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED
47+
//#undef TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED
4748
#undef TRACE_EVENT_API_ADD_TRACE_EVENT
4849
#undef TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION
4950
#undef INTERNAL_TRACE_EVENT_UID2
50-
#undef INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO
51+
//#undef INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO
5152
#undef INTERNAL_TRACE_EVENT_ADD
5253
#undef INTERNAL_TRACE_EVENT_ADD_SCOPED
5354
#undef INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW
5455
#undef INTERNAL_TRACE_EVENT_ADD_WITH_ID
5556
#undef INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP
5657
#undef INTERNAL_TRACE_EVENT_SCOPED_CONTEXT
57-
#undef INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE
58+
//#undef INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE
59+
#endif
5860
//#include "third_party/WebKit/Source/config.h"
5961
#include "third_party/WebKit/Source/core/html/HTMLIFrameElement.h"
6062
#include "third_party/WebKit/Source/core/dom/Document.h"
@@ -159,7 +161,7 @@ void NWCustomBindings::CallInWindow(
159161
v8::Local<v8::Value>* argv = new v8::Local<v8::Value>[args.Length() - 2];
160162
for (int i = 0; i < args.Length() - 2; i++)
161163
argv[i] = args[i + 2];
162-
context->CallFunction(func, args.Length() - 2, argv);
164+
context->SafeCallFunction(func, args.Length() - 2, argv);
163165
delete[] argv;
164166
}
165167

@@ -203,7 +205,8 @@ void NWCustomBindings::EvalScript(
203205
base::string16 jscript = *v8::String::Value(args[1]);
204206
#endif
205207
if (web_frame) {
206-
result = web_frame->ExecuteScriptAndReturnValue(blink::WebScriptSource(blink::WebString::FromUTF16(jscript)));
208+
blink::WebLocalFrame* local_frame = web_frame->ToWebLocalFrame();
209+
result = local_frame->ExecuteScriptAndReturnValue(blink::WebScriptSource(blink::WebString::FromUTF16(jscript)));
207210
}
208211
args.GetReturnValue().Set(result);
209212
return;
@@ -244,7 +247,8 @@ void NWCustomBindings::EvalNWBin(
244247
blink::HTMLIFrameElement* iframe = blink::V8HTMLIFrameElement::toImpl(frm);
245248
web_frame = blink::WebFrame::FromFrame(iframe->ContentFrame());
246249
}
247-
v8::Context::Scope cscope (web_frame->MainWorldScriptContext());
250+
blink::WebLocalFrame* local_frame = web_frame->ToWebLocalFrame();
251+
v8::Context::Scope cscope (local_frame->MainWorldScriptContext());
248252
v8::FixSourceNWBin(isolate, script);
249253
result = script->BindToCurrentContext()->Run();
250254
args.GetReturnValue().Set(result);

src/nw_package.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,9 @@ bool Package::InitFromPath(const base::FilePath& path_in) {
350350

351351
// Force window field no empty.
352352
if (!root_->HasKey(switches::kmWindow)) {
353-
base::DictionaryValue* window = new base::DictionaryValue();
353+
auto window = base::MakeUnique<base::DictionaryValue>();
354354
window->SetString(switches::kmPosition, "center");
355-
root_->Set(switches::kmWindow, window);
355+
root_->Set(switches::kmWindow, std::move(window));
356356
}
357357

358358
#if 0
@@ -380,15 +380,15 @@ void Package::InitWithDefault() {
380380
root_.reset(new base::DictionaryValue());
381381
root()->SetString(switches::kmName, "nwjs");
382382
root()->SetString(switches::kmMain, "nw:blank");
383-
base::DictionaryValue* window = new base::DictionaryValue();
384-
root()->Set(switches::kmWindow, window);
383+
auto window = base::MakeUnique<base::DictionaryValue>();
385384

386385
// Hide toolbar if specifed in the command line.
387386
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoToolbar))
388387
window->SetBoolean(switches::kmToolbar, false);
389388

390389
// Window should show in center by default.
391390
window->SetString(switches::kmPosition, "center");
391+
root()->Set(switches::kmWindow, std::move(window));
392392
}
393393

394394
bool Package::ExtractPath(const base::FilePath& path_to_extract,

src/nw_version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
#define NW_VERSION_H
2323

2424
#define NW_MAJOR_VERSION 0
25-
#define NW_MINOR_VERSION 24
26-
#define NW_PATCH_VERSION 5
25+
#define NW_MINOR_VERSION 25
26+
#define NW_PATCH_VERSION 0
2727

28-
#define NW_VERSION_IS_RELEASE 1
28+
#define NW_VERSION_IS_RELEASE 0
2929

3030
#ifndef NW_STRINGIFY
3131
#define NW_STRINGIFY(n) NW_STRINGIFY_HELPER(n)
@@ -39,7 +39,7 @@
3939
#else
4040
# define NW_VERSION_STRING NW_STRINGIFY(NW_MAJOR_VERSION) "." \
4141
NW_STRINGIFY(NW_MINOR_VERSION) "." \
42-
NW_STRINGIFY(NW_PATCH_VERSION) "-rc1"
42+
NW_STRINGIFY(NW_PATCH_VERSION) "-beta1"
4343
#endif
4444

4545
#define NW_VERSION "v" NW_VERSION_STRING

src/renderer/nw_extensions_renderer_hooks.cc

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ void WebWorkerStartThreadHook(blink::Frame* frame, const char* path, std::string
145145
v8::Isolate* isolate = v8::Isolate::GetCurrent();
146146
v8::HandleScope scope(isolate);
147147
blink::WebFrame* web_frame = blink::WebFrame::FromFrame(frame);
148-
v8::Local<v8::Context> v8_context = web_frame->MainWorldScriptContext();
148+
blink::WebLocalFrame* local_frame = web_frame->ToWebLocalFrame();
149+
v8::Local<v8::Context> v8_context = local_frame->MainWorldScriptContext();
149150
ScriptContext* script_context =
150151
g_dispatcher->script_context_set().GetByV8Context(v8_context);
151152
if (!script_context || !script_context->extension())
@@ -410,8 +411,11 @@ void DocumentHook2(bool start, content::RenderFrame* frame, Dispatcher* dispatch
410411
return;
411412
v8::Isolate* isolate = v8::Isolate::GetCurrent();
412413
v8::HandleScope scope(isolate);
413-
v8::Local<v8::Context> v8_context = frame->GetRenderView()
414-
->GetWebView()->MainFrame()->MainWorldScriptContext();
414+
blink::WebFrame* f = frame->GetRenderView()->GetWebView()->MainFrame();
415+
if (!f->IsWebLocalFrame())
416+
return;
417+
blink::WebLocalFrame* local_frame = f->ToWebLocalFrame();
418+
v8::Local<v8::Context> v8_context = local_frame->MainWorldScriptContext();
415419
ScriptContext* script_context =
416420
dispatcher->script_context_set().GetByV8Context(v8_context);
417421
if (start)
@@ -423,7 +427,13 @@ void DocumentHook2(bool start, content::RenderFrame* frame, Dispatcher* dispatch
423427
web_frame->MainWorldScriptContext()->Global();
424428
arguments.push_back(v8::Boolean::New(isolate, start));
425429
arguments.push_back(window);
426-
script_context->module_system()->CallModuleMethodSafe("nw.Window", "onDocumentStartEnd", &arguments);
430+
// need require in m61 since the following CallModuleMethodSafe
431+
// won't load it anymore: fedbe848f3024dd690f93545a337a2a6fb2aa81f
432+
{
433+
extensions::ModuleSystem::NativesEnabledScope natives_enabled(script_context->module_system());
434+
script_context->module_system()->Require("nw.Window");
435+
script_context->module_system()->CallModuleMethodSafe("nw.Window", "onDocumentStartEnd", &arguments);
436+
}
427437
}
428438

429439
void DocumentElementHook(blink::WebLocalFrame* frame,
@@ -488,8 +498,10 @@ void willHandleNavigationPolicy(content::RenderView* rv,
488498
bool new_win) {
489499
v8::Isolate* isolate = v8::Isolate::GetCurrent();
490500
v8::HandleScope scope(isolate);
501+
blink::WebFrame* f = rv->GetWebView()->MainFrame();
502+
blink::WebLocalFrame* local_frame = f->ToWebLocalFrame();
491503
v8::Handle<v8::Context> v8_context =
492-
rv->GetWebView()->MainFrame()->MainWorldScriptContext();
504+
local_frame->MainWorldScriptContext();
493505
ScriptContext* script_context =
494506
g_dispatcher->script_context_set().GetByV8Context(v8_context);
495507
//check extension for remote pages, which doesn't have appWindow object
@@ -536,7 +548,7 @@ void willHandleNavigationPolicy(content::RenderView* rv,
536548
}
537549
}
538550

539-
std::unique_ptr<content::V8ValueConverter> converter(content::V8ValueConverter::create());
551+
std::unique_ptr<content::V8ValueConverter> converter(content::V8ValueConverter::Create());
540552
v8::Local<v8::Value> manifest_v8 = policy_obj->Get(v8_str("manifest"));
541553
std::unique_ptr<base::Value> manifest_val(converter->FromV8Value(manifest_v8, v8_context));
542554
std::string manifest_str;

tools/payload.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bool MyComputedHashes::Writer::WriteToFile(const base::FilePath& path) {
121121
top_dictionary.SetInteger("block_size", 4096);
122122
top_dictionary.SetInteger("hash_block_size", 4096);
123123
top_dictionary.SetString("format", "treehash");
124-
top_dictionary.Set(kFileHashesKey, file_list_.release());
124+
top_dictionary.Set(kFileHashesKey, std::move(file_list_));
125125

126126
if (!base::JSONWriter::Write(top_dictionary, &json))
127127
return false;

0 commit comments

Comments
 (0)