Merge pull request #622 from atom/chrome37

Upgrade to Chrome37
This commit is contained in:
Cheng Zhao 2014-09-02 17:03:07 +08:00
commit 2832708618
34 changed files with 137 additions and 108 deletions

View file

@ -13,7 +13,8 @@
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "net/url_request/data_protocol_handler.h" #include "net/url_request/data_protocol_handler.h"
#include "net/url_request/file_protocol_handler.h" #include "net/url_request/file_protocol_handler.h"
#include "net/url_request/protocol_intercept_job_factory.h" #include "net/url_request/url_request_intercepting_job_factory.h"
#include "url/url_constants.h"
using content::BrowserThread; using content::BrowserThread;
@ -29,7 +30,7 @@ AtomBrowserContext::~AtomBrowserContext() {
net::URLRequestJobFactory* AtomBrowserContext::CreateURLRequestJobFactory( net::URLRequestJobFactory* AtomBrowserContext::CreateURLRequestJobFactory(
content::ProtocolHandlerMap* handlers, content::ProtocolHandlerMap* handlers,
content::ProtocolHandlerScopedVector* interceptors) { content::URLRequestInterceptorScopedVector* interceptors) {
scoped_ptr<AtomURLRequestJobFactory> job_factory(job_factory_); scoped_ptr<AtomURLRequestJobFactory> job_factory(job_factory_);
for (content::ProtocolHandlerMap::iterator it = handlers->begin(); for (content::ProtocolHandlerMap::iterator it = handlers->begin();
@ -38,18 +39,18 @@ net::URLRequestJobFactory* AtomBrowserContext::CreateURLRequestJobFactory(
handlers->clear(); handlers->clear();
job_factory->SetProtocolHandler( job_factory->SetProtocolHandler(
content::kDataScheme, new net::DataProtocolHandler); url::kDataScheme, new net::DataProtocolHandler);
job_factory->SetProtocolHandler( job_factory->SetProtocolHandler(
content::kFileScheme, new net::FileProtocolHandler( url::kFileScheme, new net::FileProtocolHandler(
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
// Set up interceptors in the reverse order. // Set up interceptors in the reverse order.
scoped_ptr<net::URLRequestJobFactory> top_job_factory = scoped_ptr<net::URLRequestJobFactory> top_job_factory =
job_factory.PassAs<net::URLRequestJobFactory>(); job_factory.PassAs<net::URLRequestJobFactory>();
content::ProtocolHandlerScopedVector::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::ProtocolInterceptJobFactory( top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
top_job_factory.Pass(), make_scoped_ptr(*it))); top_job_factory.Pass(), make_scoped_ptr(*it)));
interceptors->weak_clear(); interceptors->weak_clear();

View file

@ -27,7 +27,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
// brightray::URLRequestContextGetter::Delegate: // brightray::URLRequestContextGetter::Delegate:
virtual net::URLRequestJobFactory* CreateURLRequestJobFactory( virtual net::URLRequestJobFactory* CreateURLRequestJobFactory(
content::ProtocolHandlerMap* handlers, content::ProtocolHandlerMap* handlers,
content::ProtocolHandlerScopedVector* interceptors) OVERRIDE; content::URLRequestInterceptorScopedVector* interceptors) OVERRIDE;
private: private:
// A fake BrowserProcess object that used to feed the source code from chrome. // A fake BrowserProcess object that used to feed the source code from chrome.

View file

@ -7,7 +7,9 @@
namespace atom { namespace atom {
JavascriptEnvironment::JavascriptEnvironment() JavascriptEnvironment::JavascriptEnvironment()
: isolate_(v8::Isolate::GetCurrent()), : isolate_holder_(gin::IsolateHolder::kNonStrictMode),
isolate_(isolate_holder_.isolate()),
isolate_scope_(isolate_),
locker_(isolate_), locker_(isolate_),
handle_scope_(isolate_), handle_scope_(isolate_),
context_(isolate_, v8::Context::New(isolate_)), context_(isolate_, v8::Context::New(isolate_)),

View file

@ -6,7 +6,7 @@
#define ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ #define ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_
#include "base/basictypes.h" #include "base/basictypes.h"
#include "v8/include/v8.h" #include "gin/public/isolate_holder.h"
namespace atom { namespace atom {
@ -20,7 +20,9 @@ class JavascriptEnvironment {
} }
private: private:
gin::IsolateHolder isolate_holder_;
v8::Isolate* isolate_; v8::Isolate* isolate_;
v8::Isolate::Scope isolate_scope_;
v8::Locker locker_; v8::Locker locker_;
v8::HandleScope handle_scope_; v8::HandleScope handle_scope_;
v8::UniquePersistent<v8::Context> context_; v8::UniquePersistent<v8::Context> context_;

View file

@ -145,7 +145,6 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
params.bounds = bounds; params.bounds = bounds;
params.delegate = this; params.delegate = this;
params.type = views::Widget::InitParams::TYPE_WINDOW; params.type = views::Widget::InitParams::TYPE_WINDOW;
params.top_level = true;
params.remove_standard_frame = !has_frame_; params.remove_standard_frame = !has_frame_;
#if defined(USE_X11) #if defined(USE_X11)

View file

@ -44,10 +44,12 @@ NodeDebugger::NodeDebugger() {
if (use_debug_agent) { if (use_debug_agent) {
if (!port_str.empty()) if (!port_str.empty())
base::StringToInt(port_str, &port); base::StringToInt(port_str, &port);
#if 0
v8::Debug::EnableAgent("atom-shell " ATOM_VERSION, port, v8::Debug::EnableAgent("atom-shell " ATOM_VERSION, port,
wait_for_connection); wait_for_connection);
v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessagesInMsgThread, v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessagesInMsgThread,
false); false);
#endif
} }
} }

View file

@ -71,7 +71,7 @@ class MessageDialog : public views::WidgetDelegate,
virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE;
// Overridden from views::View: // Overridden from views::View:
virtual gfx::Size GetPreferredSize() OVERRIDE; virtual gfx::Size GetPreferredSize() const OVERRIDE;
virtual void Layout() OVERRIDE; virtual void Layout() OVERRIDE;
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
@ -160,7 +160,6 @@ MessageDialog::MessageDialog(NativeWindow* parent_window,
views::Widget::InitParams params; views::Widget::InitParams params;
params.delegate = this; params.delegate = this;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.top_level = true;
if (parent_) { if (parent_) {
params.parent = parent_->GetNativeWindow(); params.parent = parent_->GetNativeWindow();
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
@ -264,7 +263,7 @@ views::ClientView* MessageDialog::CreateClientView(views::Widget* widget) {
return new MessageDialogClientView(this, widget); return new MessageDialogClientView(this, widget);
} }
gfx::Size MessageDialog::GetPreferredSize() { gfx::Size MessageDialog::GetPreferredSize() const {
gfx::Size size(0, buttons_[0]->GetPreferredSize().height()); gfx::Size size(0, buttons_[0]->GetPreferredSize().height());
for (size_t i = 0; i < buttons_.size(); ++i) for (size_t i = 0; i < buttons_.size(); ++i)
size.Enlarge(buttons_[i]->GetPreferredSize().width(), 0); size.Enlarge(buttons_[i]->GetPreferredSize().width(), 0);

View file

@ -95,16 +95,16 @@ void FramelessView::UpdateWindowIcon() {
void FramelessView::UpdateWindowTitle() { void FramelessView::UpdateWindowTitle() {
} }
gfx::Size FramelessView::GetPreferredSize() { gfx::Size FramelessView::GetPreferredSize() const {
return frame_->non_client_view()->GetWindowBoundsForClientBounds( return frame_->non_client_view()->GetWindowBoundsForClientBounds(
gfx::Rect(frame_->client_view()->GetPreferredSize())).size(); gfx::Rect(frame_->client_view()->GetPreferredSize())).size();
} }
gfx::Size FramelessView::GetMinimumSize() { gfx::Size FramelessView::GetMinimumSize() const {
return window_->GetMinimumSize(); return window_->GetMinimumSize();
} }
gfx::Size FramelessView::GetMaximumSize() { gfx::Size FramelessView::GetMaximumSize() const {
return window_->GetMaximumSize(); return window_->GetMaximumSize();
} }

View file

@ -38,9 +38,9 @@ class FramelessView : public views::NonClientFrameView {
virtual void UpdateWindowTitle() OVERRIDE; virtual void UpdateWindowTitle() OVERRIDE;
// Overridden from View: // Overridden from View:
virtual gfx::Size GetPreferredSize() OVERRIDE; virtual gfx::Size GetPreferredSize() const OVERRIDE;
virtual gfx::Size GetMinimumSize() OVERRIDE; virtual gfx::Size GetMinimumSize() const OVERRIDE;
virtual gfx::Size GetMaximumSize() OVERRIDE; virtual gfx::Size GetMaximumSize() const OVERRIDE;
virtual const char* GetClassName() const OVERRIDE; virtual const char* GetClassName() const OVERRIDE;
// Not owned. // Not owned.

View file

@ -74,10 +74,10 @@ void MenuBar::SetMenu(ui::MenuModel* model) {
button->set_tag(i); button->set_tag(i);
#if defined(USE_X11) #if defined(USE_X11)
button->SetEnabledColor(enabled_color_); button->SetTextColor(views::Button::STATE_NORMAL, enabled_color_);
button->SetDisabledColor(disabled_color_); button->SetTextColor(views::Button::STATE_DISABLED, disabled_color_);
button->SetHighlightColor(highlight_color_); button->SetTextColor(views::Button::STATE_PRESSED, highlight_color_);
button->SetHoverColor(hover_color_); button->SetTextColor(views::Button::STATE_HOVERED, hover_color_);
button->SetUnderlineColor(enabled_color_); button->SetUnderlineColor(enabled_color_);
#elif defined(OS_WIN) #elif defined(OS_WIN)
button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_GRAYTEXT)); button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_GRAYTEXT));

View file

@ -73,7 +73,7 @@ bool MenuDelegate::IsTriggerableEvent(views::MenuItemView* source,
return delegate()->IsTriggerableEvent(source, e); return delegate()->IsTriggerableEvent(source, e);
} }
bool MenuDelegate::GetAccelerator(int id, ui::Accelerator* accelerator) { bool MenuDelegate::GetAccelerator(int id, ui::Accelerator* accelerator) const {
return delegate()->GetAccelerator(id, accelerator); return delegate()->GetAccelerator(id, accelerator);
} }

View file

@ -35,7 +35,7 @@ class MenuDelegate : public views::MenuDelegate {
virtual bool IsTriggerableEvent(views::MenuItemView* source, virtual bool IsTriggerableEvent(views::MenuItemView* source,
const ui::Event& e) OVERRIDE; const ui::Event& e) OVERRIDE;
virtual bool GetAccelerator(int id, virtual bool GetAccelerator(int id,
ui::Accelerator* accelerator) OVERRIDE; ui::Accelerator* accelerator) const OVERRIDE;
virtual base::string16 GetLabel(int id) const OVERRIDE; virtual base::string16 GetLabel(int id) const OVERRIDE;
virtual const gfx::FontList* GetLabelFontList(int id) const OVERRIDE; virtual const gfx::FontList* GetLabelFontList(int id) const OVERRIDE;
virtual bool IsCommandEnabled(int id) const OVERRIDE; virtual bool IsCommandEnabled(int id) const OVERRIDE;

View file

@ -30,7 +30,7 @@ void MenuLayout::Layout(views::View* host) {
menu_bar->SetBoundsRect(menu_Bar_bounds); menu_bar->SetBoundsRect(menu_Bar_bounds);
} }
gfx::Size MenuLayout::GetPreferredSize(views::View* host) { gfx::Size MenuLayout::GetPreferredSize(const views::View* host) const {
gfx::Size size = views::FillLayout::GetPreferredSize(host); gfx::Size size = views::FillLayout::GetPreferredSize(host);
if (!HasMenu(host)) if (!HasMenu(host))
return size; return size;
@ -39,7 +39,8 @@ gfx::Size MenuLayout::GetPreferredSize(views::View* host) {
return size; return size;
} }
int MenuLayout::GetPreferredHeightForWidth(views::View* host, int width) { int MenuLayout::GetPreferredHeightForWidth(
const views::View* host, int width) const {
int height = views::FillLayout::GetPreferredHeightForWidth(host, width); int height = views::FillLayout::GetPreferredHeightForWidth(host, width);
if (!HasMenu(host)) if (!HasMenu(host))
return height; return height;

View file

@ -16,8 +16,9 @@ class MenuLayout : public views::FillLayout {
// views::LayoutManager: // views::LayoutManager:
virtual void Layout(views::View* host) OVERRIDE; virtual void Layout(views::View* host) OVERRIDE;
virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE; virtual gfx::Size GetPreferredSize(const views::View* host) const OVERRIDE;
virtual int GetPreferredHeightForWidth(views::View* host, int width) OVERRIDE; virtual int GetPreferredHeightForWidth(
const views::View* host, int width) const OVERRIDE;
private: private:
bool HasMenu(const views::View* host) const; bool HasMenu(const views::View* host) const;

View file

@ -8,6 +8,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/text_utils.h" #include "ui/gfx/text_utils.h"
#include "ui/views/controls/button/label_button_border.h"
namespace atom { namespace atom {
@ -34,9 +35,14 @@ SubmenuButton::SubmenuButton(views::ButtonListener* listener,
text_width_(0), text_width_(0),
text_height_(0), text_height_(0),
underline_color_(SK_ColorBLACK) { underline_color_(SK_ColorBLACK) {
#if defined(OS_LINUX)
// Dont' use native style border.
SetBorder(CreateDefaultBorder().PassAs<views::Border>());
#endif
if (GetUnderlinePosition(title, &accelerator_, &underline_start_, if (GetUnderlinePosition(title, &accelerator_, &underline_start_,
&underline_end_)) &underline_end_))
gfx::Canvas::SizeStringInt(text(), font_list(), &text_width_, gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_,
&text_height_, 0, 0); &text_height_, 0, 0);
} }
@ -85,7 +91,7 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
void SubmenuButton::GetCharacterPosition( void SubmenuButton::GetCharacterPosition(
const base::string16& text, int index, int* pos) { const base::string16& text, int index, int* pos) {
int height; int height;
gfx::Canvas::SizeStringInt(text.substr(0, index), font_list(), pos, &height, gfx::Canvas::SizeStringInt(text.substr(0, index), GetFontList(), pos, &height,
0, 0); 0, 0);
} }

View file

@ -20,6 +20,9 @@ class SubmenuButton : public views::MenuButton {
void SetAcceleratorVisibility(bool visible); void SetAcceleratorVisibility(bool visible);
void SetUnderlineColor(SkColor color); void SetUnderlineColor(SkColor color);
void SetEnabledColor(SkColor color);
void SetBackgroundColor(SkColor color);
base::char16 accelerator() const { return accelerator_; } base::char16 accelerator() const { return accelerator_; }
// views::MenuButton: // views::MenuButton:

View file

@ -61,7 +61,6 @@ AtomBindings::AtomBindings() {
call_next_tick_async_.data = this; call_next_tick_async_.data = this;
uv_async_init(uv_default_loop(), &g_callback_uv_handle, UvOnCallback); uv_async_init(uv_default_loop(), &g_callback_uv_handle, UvOnCallback);
v8::V8::SetFatalErrorHandler(FatalErrorCallback);
} }
AtomBindings::~AtomBindings() { AtomBindings::~AtomBindings() {
@ -69,6 +68,8 @@ AtomBindings::~AtomBindings() {
void AtomBindings::BindTo(v8::Isolate* isolate, void AtomBindings::BindTo(v8::Isolate* isolate,
v8::Handle<v8::Object> process) { v8::Handle<v8::Object> process) {
v8::V8::SetFatalErrorHandler(FatalErrorCallback);
mate::Dictionary dict(isolate, process); mate::Dictionary dict(isolate, process);
dict.SetMethod("crash", &Crash); dict.SetMethod("crash", &Crash);
dict.SetMethod("log", &Log); dict.SetMethod("log", &Log);

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 "36.0.1985.125" #define CHROME_VERSION_STRING "37.0.2062.102"
#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

@ -5,6 +5,7 @@
#ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_ #ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
#define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_ #define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
#include "base/strings/string16.h"
#include "content/public/renderer/render_view_observer.h" #include "content/public/renderer/render_view_observer.h"
namespace base { namespace base {

View file

@ -14,10 +14,12 @@
#include "chrome/renderer/printing/print_web_view_helper.h" #include "chrome/renderer/printing/print_web_view_helper.h"
#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_frame_observer.h" #include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_thread.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "native_mate/converter.h" #include "native_mate/converter.h"
#include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
@ -83,7 +85,7 @@ AtomRendererClient::AtomRendererClient()
AtomRendererClient::~AtomRendererClient() { AtomRendererClient::~AtomRendererClient() {
} }
void AtomRendererClient::RenderThreadStarted() { void AtomRendererClient::WebKitInitialized() {
if (!IsNodeBindingEnabled()) if (!IsNodeBindingEnabled())
return; return;
@ -94,12 +96,16 @@ void AtomRendererClient::RenderThreadStarted() {
// Create a default empty environment which would be used when we need to // Create a default empty environment which would be used when we need to
// run V8 code out of a window context (like running a uv callback). // run V8 code out of a window context (like running a uv callback).
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = blink::mainThreadIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate);
global_env = node::Environment::New(context); global_env = node::Environment::New(context);
} }
void AtomRendererClient::RenderThreadStarted() {
content::RenderThread::Get()->AddObserver(this);
}
void AtomRendererClient::RenderFrameCreated( void AtomRendererClient::RenderFrameCreated(
content::RenderFrame* render_frame) { content::RenderFrame* render_frame) {
new AtomRenderFrameObserver(render_frame, this); new AtomRenderFrameObserver(render_frame, this);

View file

@ -9,6 +9,7 @@
#include <vector> #include <vector>
#include "content/public/renderer/content_renderer_client.h" #include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/render_process_observer.h"
namespace node { namespace node {
class Environment; class Environment;
@ -19,7 +20,8 @@ namespace atom {
class AtomRendererBindings; class AtomRendererBindings;
class NodeBindings; class NodeBindings;
class AtomRendererClient : public content::ContentRendererClient { class AtomRendererClient : public content::ContentRendererClient,
public content::RenderProcessObserver {
public: public:
AtomRendererClient(); AtomRendererClient();
virtual ~AtomRendererClient(); virtual ~AtomRendererClient();
@ -41,6 +43,9 @@ class AtomRendererClient : public content::ContentRendererClient {
DISABLE, DISABLE,
}; };
// content::RenderProcessObserver:
virtual void WebKitInitialized() OVERRIDE;
// content::ContentRendererClient: // content::ContentRendererClient:
virtual void RenderThreadStarted() OVERRIDE; virtual void RenderThreadStarted() OVERRIDE;
virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE; virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE;

View file

@ -12,6 +12,7 @@
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job_worker.h" #include "chrome/browser/printing/print_job_worker.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "printing/printed_document.h" #include "printing/printed_document.h"
#include "printing/printed_page.h" #include "printing/printed_page.h"
@ -69,7 +70,10 @@ void PrintJob::Initialize(PrintJobWorkerOwner* job,
settings_ = job->settings(); settings_ = job->settings();
PrintedDocument* new_doc = PrintedDocument* new_doc =
new PrintedDocument(settings_, source_, job->cookie()); new PrintedDocument(settings_,
source_,
job->cookie(),
content::BrowserThread::GetBlockingPool());
new_doc->set_page_count(page_count); new_doc->set_page_count(page_count);
UpdatePrintedDocument(new_doc); UpdatePrintedDocument(new_doc);

View file

@ -120,39 +120,19 @@ void PrintJobWorker::SetSettings(
DCHECK_EQ(message_loop(), base::MessageLoop::current()); DCHECK_EQ(message_loop(), base::MessageLoop::current());
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI,
base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), FROM_HERE,
base::Bind(&HoldRefCallback,
make_scoped_refptr(owner_),
base::Bind(&PrintJobWorker::UpdatePrintSettings, base::Bind(&PrintJobWorker::UpdatePrintSettings,
base::Unretained(this), new_settings))); base::Unretained(this),
base::Owned(new_settings))));
} }
void PrintJobWorker::UpdatePrintSettings( void PrintJobWorker::UpdatePrintSettings(
const base::DictionaryValue* const new_settings) { const base::DictionaryValue* const new_settings) {
// Create new PageRanges based on |new_settings|.
PageRanges new_ranges;
const base::ListValue* page_range_array;
if (new_settings->GetList(kSettingPageRange, &page_range_array)) {
for (size_t index = 0; index < page_range_array->GetSize(); ++index) {
const base::DictionaryValue* dict;
if (!page_range_array->GetDictionary(index, &dict))
continue;
PageRange range;
if (!dict->GetInteger(kSettingPageRangeFrom, &range.from) ||
!dict->GetInteger(kSettingPageRangeTo, &range.to)) {
continue;
}
// Page numbers are 1-based in the dictionary.
// Page numbers are 0-based for the printing context.
range.from--;
range.to--;
new_ranges.push_back(range);
}
}
PrintingContext::Result result = PrintingContext::Result result =
printing_context_->UpdatePrintSettings(*new_settings, new_ranges); printing_context_->UpdatePrintSettings(*new_settings);
delete new_settings;
GetSettingsDone(result); GetSettingsDone(result);
} }
@ -218,8 +198,6 @@ void PrintJobWorker::StartPrinting(PrintedDocument* new_document) {
base::string16 document_name = base::string16 document_name =
printing::SimplifyDocumentTitle(document_->name()); printing::SimplifyDocumentTitle(document_->name());
if (document_name.empty()) { if (document_name.empty()) {
// document_name = printing::SimplifyDocumentTitle(
// l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE));
} }
PrintingContext::Result result = PrintingContext::Result result =
printing_context_->NewDocument(document_name); printing_context_->NewDocument(document_name);
@ -272,8 +250,8 @@ void PrintJobWorker::OnNewPage() {
while (true) { while (true) {
// Is the page available? // Is the page available?
scoped_refptr<PrintedPage> page; scoped_refptr<PrintedPage> page = document_->GetPage(page_number_.ToInt());
if (!document_->GetPage(page_number_.ToInt(), &page)) { if (!page) {
// We need to wait for the page to be available. // We need to wait for the page to be available.
base::MessageLoop::current()->PostDelayedTask( base::MessageLoop::current()->PostDelayedTask(
FROM_HERE, FROM_HERE,

View file

@ -4,8 +4,6 @@
#include "chrome/browser/printing/print_view_manager_base.h" #include "chrome/browser/printing/print_view_manager_base.h"
#include <map>
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
@ -34,12 +32,16 @@
using base::TimeDelta; using base::TimeDelta;
using content::BrowserThread; using content::BrowserThread;
#if defined(OS_WIN) namespace printing {
namespace {
#if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)
// Limits memory usage by raster to 64 MiB. // Limits memory usage by raster to 64 MiB.
const int kMaxRasterSizeInPixels = 16*1024*1024; const int kMaxRasterSizeInPixels = 16*1024*1024;
#endif #endif
namespace printing { } // namespace
PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents) PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents), : content::WebContentsObserver(web_contents),
@ -49,7 +51,8 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
cookie_(0), cookie_(0),
queue_(g_browser_process->print_job_manager()->queue()) { queue_(g_browser_process->print_job_manager()->queue()) {
DCHECK(queue_); DCHECK(queue_);
#if defined(OS_POSIX) && !defined(OS_MACOSX) #if (defined(OS_POSIX) && !defined(OS_MACOSX)) || \
defined(WIN_PDF_METAFILE_FOR_PRINTING)
expecting_first_page_ = true; expecting_first_page_ = true;
#endif #endif
printing_enabled_ = true; printing_enabled_ = true;
@ -103,7 +106,7 @@ void PrintViewManagerBase::OnDidGetDocumentCookie(int cookie) {
} }
void PrintViewManagerBase::OnDidPrintPage( void PrintViewManagerBase::OnDidPrintPage(
const PrintHostMsg_DidPrintPage_Params& params) { const PrintHostMsg_DidPrintPage_Params& params) {
if (!OpportunisticallyCreatePrintJob(params.document_cookie)) if (!OpportunisticallyCreatePrintJob(params.document_cookie))
return; return;
@ -114,9 +117,10 @@ void PrintViewManagerBase::OnDidPrintPage(
return; return;
} }
#if defined(OS_WIN) || defined(OS_MACOSX) #if (defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)) || \
defined(OS_MACOSX)
const bool metafile_must_be_valid = true; const bool metafile_must_be_valid = true;
#elif defined(OS_POSIX) #elif defined(OS_POSIX) || defined(WIN_PDF_METAFILE_FOR_PRINTING)
const bool metafile_must_be_valid = expecting_first_page_; const bool metafile_must_be_valid = expecting_first_page_;
expecting_first_page_ = false; expecting_first_page_ = false;
#endif #endif
@ -139,10 +143,10 @@ void PrintViewManagerBase::OnDidPrintPage(
} }
} }
#if defined(OS_WIN) #if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)
bool big_emf = (params.data_size && params.data_size >= kMetafileMaxSize); bool big_emf = (params.data_size && params.data_size >= kMetafileMaxSize);
int raster_size = std::min(params.page_size.GetArea(), int raster_size =
kMaxRasterSizeInPixels); std::min(params.page_size.GetArea(), kMaxRasterSizeInPixels);
if (big_emf) { if (big_emf) {
scoped_ptr<NativeMetafile> raster_metafile( scoped_ptr<NativeMetafile> raster_metafile(
metafile->RasterizeMetafile(raster_size)); metafile->RasterizeMetafile(raster_size));
@ -156,16 +160,39 @@ void PrintViewManagerBase::OnDidPrintPage(
return; return;
} }
} }
#endif #endif // OS_WIN && !WIN_PDF_METAFILE_FOR_PRINTING
#if !defined(WIN_PDF_METAFILE_FOR_PRINTING)
// 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.release(), metafile.release(),
#if defined(OS_WIN)
params.actual_shrink, params.actual_shrink,
#endif // OS_WIN
params.page_size, params.page_size,
params.content_area); params.content_area);
ShouldQuitFromInnerMessageLoop(); ShouldQuitFromInnerMessageLoop();
#else
if (metafile_must_be_valid) {
scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes(
reinterpret_cast<const unsigned char*>(shared_buf.memory()),
params.data_size);
document->DebugDumpData(bytes, FILE_PATH_LITERAL(".pdf"));
if (!pdf_to_emf_converter_)
pdf_to_emf_converter_ = PdfToEmfConverter::CreateDefault();
const int kPrinterDpi = print_job_->settings().dpi();
pdf_to_emf_converter_->Start(
bytes,
printing::PdfRenderSettings(params.content_area, kPrinterDpi, true),
base::Bind(&PrintViewManagerBase::OnPdfToEmfConverted,
base::Unretained(this),
params));
}
#endif // !WIN_PDF_METAFILE_FOR_PRINTING
} }
void PrintViewManagerBase::OnPrintingFailed(int cookie) { void PrintViewManagerBase::OnPrintingFailed(int cookie) {
@ -186,10 +213,6 @@ void PrintViewManagerBase::OnShowInvalidPrinterSettingsError() {
LOG(ERROR) << "Invalid printer settings"; LOG(ERROR) << "Invalid printer settings";
} }
void PrintViewManagerBase::DidStartLoading(
content::RenderViewHost* render_view_host) {
}
bool PrintViewManagerBase::OnMessageReceived(const IPC::Message& message) { bool PrintViewManagerBase::OnMessageReceived(const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBase, message) IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBase, message)
@ -363,7 +386,8 @@ void PrintViewManagerBase::DisconnectFromCurrentPrintJob() {
// DO NOT wait for the job to finish. // DO NOT wait for the job to finish.
ReleasePrintJob(); ReleasePrintJob();
} }
#if defined(OS_POSIX) && !defined(OS_MACOSX) #if (defined(OS_POSIX) && !defined(OS_MACOSX)) || \
defined(WIN_PDF_METAFILE_FOR_PRINTING)
expecting_first_page_ = true; expecting_first_page_ = true;
#endif #endif
} }

View file

@ -23,6 +23,7 @@ class RenderViewHost;
namespace printing { namespace printing {
class JobEventDetails; class JobEventDetails;
class PdfToEmfConverter;
class PrintJob; class PrintJob;
class PrintJobWorkerOwner; class PrintJobWorkerOwner;
class PrintQueriesQueue; class PrintQueriesQueue;
@ -63,10 +64,6 @@ class PrintViewManagerBase : public content::NotificationObserver,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE; const content::NotificationDetails& details) OVERRIDE;
// content::WebContentsObserver implementation.
virtual void DidStartLoading(
content::RenderViewHost* render_view_host) OVERRIDE;
// Cancels the print job. // Cancels the print job.
virtual void NavigationStopped() OVERRIDE; virtual void NavigationStopped() OVERRIDE;
@ -143,7 +140,8 @@ class PrintViewManagerBase : public content::NotificationObserver,
// print settings are being loaded. // print settings are being loaded.
bool inside_inner_message_loop_; bool inside_inner_message_loop_;
#if defined(OS_POSIX) && !defined(OS_MACOSX) #if (defined(OS_POSIX) && !defined(OS_MACOSX)) || \
defined(WIN_PDF_METAFILE_FOR_PRINTING)
// Set to true when OnDidPrintPage() should be expecting the first page. // Set to true when OnDidPrintPage() should be expecting the first page.
bool expecting_first_page_; bool expecting_first_page_;
#endif #endif

View file

@ -63,10 +63,9 @@ PrintingMessageFilter::PrintingMessageFilter(int render_process_id)
PrintingMessageFilter::~PrintingMessageFilter() { PrintingMessageFilter::~PrintingMessageFilter() {
} }
bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message, bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool* message_was_ok) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(PrintingMessageFilter, message, *message_was_ok) IPC_BEGIN_MESSAGE_MAP(PrintingMessageFilter, message)
#if defined(OS_WIN) #if defined(OS_WIN)
IPC_MESSAGE_HANDLER(PrintHostMsg_DuplicateSection, OnDuplicateSection) IPC_MESSAGE_HANDLER(PrintHostMsg_DuplicateSection, OnDuplicateSection)
#endif #endif

View file

@ -38,8 +38,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
explicit PrintingMessageFilter(int render_process_id); explicit PrintingMessageFilter(int render_process_id);
// content::BrowserMessageFilter methods. // content::BrowserMessageFilter methods.
virtual bool OnMessageReceived(const IPC::Message& message, virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
bool* message_was_ok) OVERRIDE;
private: private:
virtual ~PrintingMessageFilter(); virtual ~PrintingMessageFilter();

View file

@ -10,7 +10,7 @@
], ],
"devDependencies": { "devDependencies": {
"atom-package-manager": "0.89.0", "atom-package-manager": "0.93.0",
"coffee-script": "~1.7.1", "coffee-script": "~1.7.1",
"coffeelint": "~1.3.0" "coffeelint": "~1.3.0"
}, },

View file

@ -4,7 +4,7 @@ import argparse
import os import os
import sys import sys
from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, NODE_VERSION from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL
from lib.util import execute, scoped_cwd, enable_verbose_execute from lib.util import execute, scoped_cwd, enable_verbose_execute
@ -65,7 +65,6 @@ def update_node_modules(dirname):
def update_atom_modules(dirname): def update_atom_modules(dirname):
os.environ['ATOM_NODE_VERSION'] = NODE_VERSION[1:]
with scoped_cwd(dirname): with scoped_cwd(dirname):
apm = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'apm') apm = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'apm')
if sys.platform in ['win32', 'cygwin']: if sys.platform in ['win32', 'cygwin']:

View file

@ -8,8 +8,8 @@ import subprocess
import sys import sys
import tarfile import tarfile
from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, NODE_VERSION, \ from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, TARGET_PLATFORM, \
TARGET_PLATFORM, DIST_ARCH DIST_ARCH
from lib.util import scoped_cwd, rm_rf, get_atom_shell_version, make_zip, \ from lib.util import scoped_cwd, rm_rf, get_atom_shell_version, make_zip, \
safe_mkdir, execute safe_mkdir, execute
@ -20,7 +20,7 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist') DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'Release') OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'Release')
NODE_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'node') NODE_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'node')
DIST_HEADERS_NAME = 'node-{0}'.format(NODE_VERSION) DIST_HEADERS_NAME = 'node-{0}'.format(ATOM_SHELL_VERSION)
DIST_HEADERS_DIR = os.path.join(DIST_DIR, DIST_HEADERS_NAME) DIST_HEADERS_DIR = os.path.join(DIST_DIR, DIST_HEADERS_NAME)
SYMBOL_NAME = { SYMBOL_NAME = {

View file

@ -3,9 +3,8 @@
import platform import platform
import sys import sys
NODE_VERSION = 'v0.11.13'
BASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent' BASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent'
LIBCHROMIUMCONTENT_COMMIT = 'afb4570ceee2ad10f3caf5a81335a2ee11ec68a5' LIBCHROMIUMCONTENT_COMMIT = '2cf80c1743e370c12eb7bf078eb425f3cc355383'
ARCH = { ARCH = {
'cygwin': '32bit', 'cygwin': '32bit',

View file

@ -8,7 +8,7 @@ import subprocess
import sys import sys
import tempfile import tempfile
from lib.config import DIST_ARCH, NODE_VERSION, TARGET_PLATFORM from lib.config import DIST_ARCH, TARGET_PLATFORM
from lib.util import get_atom_shell_version, scoped_cwd, safe_mkdir, execute, \ from lib.util import get_atom_shell_version, scoped_cwd, safe_mkdir, execute, \
s3_config, s3put s3_config, s3put
from lib.github import GitHub from lib.github import GitHub
@ -51,7 +51,7 @@ def main():
# Upload node's headers to S3. # Upload node's headers to S3.
bucket, access_key, secret_key = s3_config() bucket, access_key, secret_key = s3_config()
upload_node(bucket, access_key, secret_key, NODE_VERSION) upload_node(bucket, access_key, secret_key, ATOM_SHELL_VERSION)
if args.publish_release: if args.publish_release:
# Press the publish button. # Press the publish button.
@ -60,7 +60,7 @@ def main():
# Upload the SHASUMS.txt. # Upload the SHASUMS.txt.
execute([sys.executable, execute([sys.executable,
os.path.join(SOURCE_ROOT, 'script', 'upload-checksums.py'), os.path.join(SOURCE_ROOT, 'script', 'upload-checksums.py'),
'-v', NODE_VERSION]) '-v', ATOM_SHELL_VERSION])
def parse_args(): def parse_args():

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit de769889118c6e68ecb0c729be5ab6caef333bf6 Subproject commit dafc85799ca31e3ddd7b5d0cc0ef7fbf38dcf88f

2
vendor/node vendored

@ -1 +1 @@
Subproject commit 6d772c3cda0bb8270857397e128ea1e36c361125 Subproject commit 20b07f3e991f82d6aef22e8b8212f19ef1cb5bcb