diff --git a/atom.gyp b/atom.gyp index 345474b5b6d..7aa21a9d584 100644 --- a/atom.gyp +++ b/atom.gyp @@ -3,9 +3,8 @@ 'includes': [ 'vendor/native_mate/native_mate_files.gypi', ], - 'project_name': 'atom', - 'product_name': 'Atom', - 'framework_name': 'Atom Framework', + 'project_name%': 'atom', + 'product_name%': 'Atom', 'app_sources': [ 'atom/app/atom_main.cc', 'atom/app/atom_main.h', @@ -60,6 +59,7 @@ 'atom/app/atom_content_client.h', 'atom/app/atom_main_delegate.cc', 'atom/app/atom_main_delegate.h', + 'atom/app/atom_main_delegate_mac.mm', 'atom/browser/api/atom_api_app.cc', 'atom/browser/api/atom_api_app.h', 'atom/browser/api/atom_api_auto_updater.cc', @@ -238,6 +238,7 @@ 'atom/common/native_mate_converters/gurl_converter.h', 'atom/common/native_mate_converters/image_converter.cc', 'atom/common/native_mate_converters/image_converter.h', + 'atom/common/native_mate_converters/image_converter_mac.mm', 'atom/common/native_mate_converters/string16_converter.h', 'atom/common/native_mate_converters/v8_value_converter.cc', 'atom/common/native_mate_converters/v8_value_converter.h', @@ -419,7 +420,7 @@ 'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Frameworks', 'files': [ '<(PRODUCT_DIR)/<(product_name) Helper.app', - '<(PRODUCT_DIR)/<(framework_name).framework', + '<(PRODUCT_DIR)/<(product_name) Framework.framework', 'external_binaries/Squirrel.framework', 'external_binaries/ReactiveCocoa.framework', 'external_binaries/Mantle.framework', @@ -527,6 +528,7 @@ 'vendor/node/node.gyp:node_lib', ], 'defines': [ + 'PRODUCT_NAME="<(product_name)"', # This is defined in skia/skia_common.gypi. 'SK_SUPPORT_LEGACY_GETTOPDEVICE', # Disable warnings for g_settings_list_schemas. @@ -548,6 +550,8 @@ 'vendor/brightray/vendor/download/libchromiumcontent/src/v8/include', # The `node.h` is using `#include"ares.h"`. 'vendor/node/deps/cares/include', + # The `third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h` is using `platform/PlatformExport.h`. + 'vendor/brightray/vendor/download/libchromiumcontent/src/third_party/WebKit/Source', ], 'direct_dependent_settings': { 'include_dirs': [ @@ -784,7 +788,7 @@ 'targets': [ { 'target_name': '<(project_name)_framework', - 'product_name': '<(framework_name)', + 'product_name': '<(product_name) Framework', 'type': 'shared_library', 'dependencies': [ '<(project_name)_lib', @@ -820,7 +824,7 @@ 'LIBRARY_SEARCH_PATHS': [ '<(libchromiumcontent_library_dir)', ], - 'LD_DYLIB_INSTALL_NAME': '@rpath/<(framework_name).framework/<(framework_name)', + 'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name) Framework.framework/<(product_name) Framework', 'LD_RUNPATH_SEARCH_PATHS': [ '@loader_path/Libraries', ], @@ -830,14 +834,14 @@ }, 'copies': [ { - 'destination': '<(PRODUCT_DIR)/<(framework_name).framework/Versions/A/Libraries', + 'destination': '<(PRODUCT_DIR)/<(product_name) Framework.framework/Versions/A/Libraries', 'files': [ '<(libchromiumcontent_library_dir)/ffmpegsumo.so', '<(libchromiumcontent_library_dir)/libchromiumcontent.dylib', ], }, { - 'destination': '<(PRODUCT_DIR)/<(framework_name).framework/Versions/A/Resources', + 'destination': '<(PRODUCT_DIR)/<(product_name) Framework.framework/Versions/A/Resources', 'files': [ '<(PRODUCT_DIR)/Inspector', '<(PRODUCT_DIR)/crash_report_sender.app', @@ -849,7 +853,7 @@ 'postbuild_name': 'Add symlinks for framework subdirectories', 'action': [ 'tools/mac/create-framework-subdir-symlinks.sh', - '<(framework_name)', + '<(product_name) Framework', 'Libraries', 'Frameworks', ], diff --git a/atom/app/atom_main_delegate.h b/atom/app/atom_main_delegate.h index 9f74386304a..8cd4a28ee1c 100644 --- a/atom/app/atom_main_delegate.h +++ b/atom/app/atom_main_delegate.h @@ -26,6 +26,10 @@ class AtomMainDelegate : public brightray::MainDelegate { scoped_ptr CreateContentClient() override; void AddDataPackFromPath( ui::ResourceBundle* bundle, const base::FilePath& pak_dir) override; +#if defined(OS_MACOSX) + void OverrideChildProcessPath() override; + void OverrideFrameworkBundlePath() override; +#endif private: brightray::ContentClient content_client_; diff --git a/atom/app/atom_main_delegate_mac.mm b/atom/app/atom_main_delegate_mac.mm new file mode 100644 index 00000000000..7232817c94f --- /dev/null +++ b/atom/app/atom_main_delegate_mac.mm @@ -0,0 +1,38 @@ +// Copyright (c) 2014 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/app/atom_main_delegate.h" + +#include "base/mac/bundle_locations.h" +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "brightray/common/mac/main_application_bundle.h" +#include "content/public/common/content_paths.h" + +namespace atom { + +namespace { + +base::FilePath GetFrameworksPath() { + return brightray::MainApplicationBundlePath().Append("Contents") + .Append("Frameworks"); +} + +} // namespace + +void AtomMainDelegate::OverrideFrameworkBundlePath() { + base::mac::SetOverrideFrameworkBundlePath( + GetFrameworksPath().Append(PRODUCT_NAME " Framework.framework")); +} + +void AtomMainDelegate::OverrideChildProcessPath() { + base::FilePath helper_path = + GetFrameworksPath().Append(PRODUCT_NAME " Helper.app") + .Append("Contents") + .Append("MacOS") + .Append(PRODUCT_NAME " Helper"); + PathService::Override(content::CHILD_PROCESS_EXE, helper_path); +} + +} // namespace atom diff --git a/atom/browser/api/atom_api_dialog.cc b/atom/browser/api/atom_api_dialog.cc index 975c30963fa..5834b73e6b6 100644 --- a/atom/browser/api/atom_api_dialog.cc +++ b/atom/browser/api/atom_api_dialog.cc @@ -11,6 +11,7 @@ #include "atom/browser/ui/file_dialog.h" #include "atom/browser/ui/message_box.h" #include "atom/common/native_mate_converters/file_path_converter.h" +#include "atom/common/native_mate_converters/image_converter.h" #include "native_mate/callback.h" #include "native_mate/dictionary.h" @@ -40,21 +41,27 @@ namespace { void ShowMessageBox(int type, const std::vector& buttons, - const std::string& title, - const std::string& message, - const std::string& detail, + const std::vector& texts, + const gfx::ImageSkia& icon, atom::NativeWindow* window, mate::Arguments* args) { + // FIXME We are exceeding the parameters limit of base::Bind here, so we have + // to pass some parameters in an array. We should remove this once we have + // variadic template support in base::Bind. + const std::string& title = texts[0]; + const std::string& message = texts[1]; + const std::string& detail = texts[2]; + v8::Handle peek = args->PeekNext(); atom::MessageBoxCallback callback; if (mate::Converter::FromV8(args->isolate(), peek, &callback)) { atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons, title, - message, detail, callback); + message, detail, icon, callback); } else { int chosen = atom::ShowMessageBox(window, (atom::MessageBoxType)type, - buttons, title, message, detail); + buttons, title, message, detail, icon); args->Return(chosen); } } diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index dfb0d6e1d10..6315c4059d4 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -12,6 +12,7 @@ #include "atom/common/native_mate_converters/string16_converter.h" #include "native_mate/constructor.h" #include "native_mate/dictionary.h" +#include "ui/gfx/image/image.h" #include "atom/common/node_includes.h" @@ -19,7 +20,7 @@ namespace atom { namespace api { -Tray::Tray(const gfx::ImageSkia& image) +Tray::Tray(const gfx::Image& image) : tray_icon_(TrayIcon::Create()) { tray_icon_->SetImage(image); tray_icon_->AddObserver(this); @@ -29,7 +30,7 @@ Tray::~Tray() { } // static -mate::Wrappable* Tray::New(const gfx::ImageSkia& image) { +mate::Wrappable* Tray::New(const gfx::Image& image) { return new Tray(image); } @@ -57,13 +58,13 @@ void Tray::Destroy() { tray_icon_.reset(); } -void Tray::SetImage(mate::Arguments* args, const gfx::ImageSkia& image) { +void Tray::SetImage(mate::Arguments* args, const gfx::Image& image) { if (!CheckTrayLife(args)) return; tray_icon_->SetImage(image); } -void Tray::SetPressedImage(mate::Arguments* args, const gfx::ImageSkia& image) { +void Tray::SetPressedImage(mate::Arguments* args, const gfx::Image& image) { if (!CheckTrayLife(args)) return; tray_icon_->SetPressedImage(image); @@ -92,7 +93,7 @@ void Tray::DisplayBalloon(mate::Arguments* args, if (!CheckTrayLife(args)) return; - gfx::ImageSkia icon; + gfx::Image icon; options.Get("icon", &icon); base::string16 title, content; if (!options.Get("title", &title) || diff --git a/atom/browser/api/atom_api_tray.h b/atom/browser/api/atom_api_tray.h index 87bc84a5014..48828d2c936 100644 --- a/atom/browser/api/atom_api_tray.h +++ b/atom/browser/api/atom_api_tray.h @@ -12,7 +12,7 @@ #include "base/memory/scoped_ptr.h" namespace gfx { -class ImageSkia; +class Image; } namespace mate { @@ -31,13 +31,13 @@ class Menu; class Tray : public mate::EventEmitter, public TrayIconObserver { public: - static mate::Wrappable* New(const gfx::ImageSkia& image); + static mate::Wrappable* New(const gfx::Image& image); static void BuildPrototype(v8::Isolate* isolate, v8::Handle prototype); protected: - explicit Tray(const gfx::ImageSkia& image); + explicit Tray(const gfx::Image& image); virtual ~Tray(); // TrayIconObserver: @@ -48,8 +48,8 @@ class Tray : public mate::EventEmitter, void OnBalloonClosed() override; void Destroy(); - void SetImage(mate::Arguments* args, const gfx::ImageSkia& image); - void SetPressedImage(mate::Arguments* args, const gfx::ImageSkia& image); + void SetImage(mate::Arguments* args, const gfx::Image& image); + void SetPressedImage(mate::Arguments* args, const gfx::Image& image); void SetToolTip(mate::Arguments* args, const std::string& tool_tip); void SetTitle(mate::Arguments* args, const std::string& title); void SetHighlightMode(mate::Arguments* args, bool highlight); diff --git a/atom/browser/api/lib/dialog.coffee b/atom/browser/api/lib/dialog.coffee index 49b1c0ef003..ddb5a20a780 100644 --- a/atom/browser/api/lib/dialog.coffee +++ b/atom/browser/api/lib/dialog.coffee @@ -91,12 +91,12 @@ module.exports = options.title ?= '' options.message ?= '' options.detail ?= '' + options.icon ?= null binding.showMessageBox options.type, options.buttons, - String(options.title), - String(options.message), - String(options.detail), + [options.title, options.message, options.detail], + options.icon, window, callback diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 827dbe4e159..4a5d2d968be 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -87,8 +87,8 @@ void AtomBrowserClient::OverrideWebkitPrefs( prefs->allow_universal_access_from_file_urls = true; prefs->allow_file_access_from_file_urls = true; prefs->experimental_webgl_enabled = true; - prefs->allow_displaying_insecure_content = true; - prefs->allow_running_insecure_content = true; + prefs->allow_displaying_insecure_content = false; + prefs->allow_running_insecure_content = false; // Turn off web security for devtools. if (url.SchemeIs("chrome-devtools")) { diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 38f9bef470c..f81894a5d39 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -8,6 +8,8 @@ #include "atom/browser/net/atom_url_request_job_factory.h" #include "atom/browser/net/asar/asar_protocol_handler.h" #include "atom/browser/web_view/web_view_manager.h" +#include "atom/common/options_switches.h" +#include "base/command_line.h" #include "base/threading/sequenced_worker_pool.h" #include "base/threading/worker_pool.h" #include "chrome/browser/browser_process.h" @@ -26,6 +28,14 @@ namespace { const char* kAsarScheme = "asar"; +class NoCacheBackend : public net::HttpCache::BackendFactory { + int CreateBackend(net::NetLog* net_log, + scoped_ptr* backend, + const net::CompletionCallback& callback) override { + return net::ERR_FAILED; + } +}; + } // namespace AtomBrowserContext::AtomBrowserContext() @@ -69,6 +79,16 @@ net::URLRequestJobFactory* AtomBrowserContext::CreateURLRequestJobFactory( return top_job_factory.release(); } +net::HttpCache::BackendFactory* +AtomBrowserContext::CreateHttpCacheBackendFactory( + const base::FilePath& base_path) { + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kDisableHttpCache)) + return new NoCacheBackend; + else + return brightray::BrowserContext::CreateHttpCacheBackendFactory(base_path); +} + content::BrowserPluginGuestManager* AtomBrowserContext::GetGuestManager() { if (!guest_manager_) guest_manager_.reset(new WebViewManager(this)); diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index 8dd2dc7e0bc..ab28c3e81a0 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -26,6 +26,8 @@ class AtomBrowserContext : public brightray::BrowserContext { net::URLRequestJobFactory* CreateURLRequestJobFactory( content::ProtocolHandlerMap* handlers, content::URLRequestInterceptorScopedVector* interceptors) override; + net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory( + const base::FilePath& base_path) override; // content::BrowserContext: content::BrowserPluginGuestManager* GetGuestManager() override; diff --git a/atom/browser/atom_browser_main_parts_mac.mm b/atom/browser/atom_browser_main_parts_mac.mm index c1a9eae3147..3e80eac223a 100644 --- a/atom/browser/atom_browser_main_parts_mac.mm +++ b/atom/browser/atom_browser_main_parts_mac.mm @@ -13,11 +13,6 @@ namespace atom { -std::string GetApplicationName() { - std::string name = brightray::MainApplicationBundlePath().BaseName().AsUTF8Unsafe(); - return name.substr(0, name.length() - 4/*.app*/); -} - void AtomBrowserMainParts::PreMainMessageLoopStart() { // Initialize locale setting. l10n_util::OverrideLocaleWithCocoaLocale(); @@ -31,7 +26,7 @@ void AtomBrowserMainParts::PreMainMessageLoopStart() { base::FilePath frameworkPath = brightray::MainApplicationBundlePath() .Append("Contents") .Append("Frameworks") - .Append(GetApplicationName() + " Framework.framework"); + .Append(PRODUCT_NAME " Framework.framework"); NSBundle* frameworkBundle = [NSBundle bundleWithPath:base::mac::FilePathToNSString(frameworkPath)]; NSNib* mainNib = [[NSNib alloc] initWithNibNamed:@"MainMenu" diff --git a/atom/browser/lib/chrome-extension.coffee b/atom/browser/lib/chrome-extension.coffee index 724ed5cadd5..e62ad5250de 100644 --- a/atom/browser/lib/chrome-extension.coffee +++ b/atom/browser/lib/chrome-extension.coffee @@ -32,7 +32,7 @@ getExtensionInfoFromPath = (srcDirectory) -> startPage: page name: manifest.name srcDirectory: srcDirectory - extensionInfoMap[manifest.name] + extensionInfoMap[manifest.name] # Load persistented extensions. loadedExtensionsPath = path.join app.getDataPath(), 'DevTools Extensions' @@ -74,8 +74,9 @@ app.once 'ready', -> BrowserWindow.addDevToolsExtension = (srcDirectory) -> extensionInfo = getExtensionInfoFromPath srcDirectory - window._loadDevToolsExtensions [extensionInfo] for window in BrowserWindow.getAllWindows() - extensionInfo.name + if extensionInfo + window._loadDevToolsExtensions [extensionInfo] for window in BrowserWindow.getAllWindows() + extensionInfo.name BrowserWindow.removeDevToolsExtension = (name) -> delete extensionInfoMap[name] diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 9c12c46d759..f9c77597bd2 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -414,6 +414,10 @@ bool NativeWindowMac::IsFocused() { } void NativeWindowMac::Show() { + // This method is supposed to put focus on window, however if the app does not + // have focus then "makeKeyAndOrderFront" will only show the window. + [NSApp activateIgnoringOtherApps:YES]; + [window_ makeKeyAndOrderFront:nil]; } diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index fc6f325908c..79cd224ce94 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.20.2 + 0.20.5 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index cb36df77f52..49cbcd63b60 100644 --- a/atom/browser/resources/win/atom.rc +++ b/atom/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,20,2,0 - PRODUCTVERSION 0,20,2,0 + FILEVERSION 0,20,5,0 + PRODUCTVERSION 0,20,5,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -68,12 +68,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Atom-Shell" - VALUE "FileVersion", "0.20.2" + VALUE "FileVersion", "0.20.5" VALUE "InternalName", "atom.exe" VALUE "LegalCopyright", "Copyright (C) 2013 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "atom.exe" VALUE "ProductName", "Atom-Shell" - VALUE "ProductVersion", "0.20.2" + VALUE "ProductVersion", "0.20.5" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/browser/ui/message_box.h b/atom/browser/ui/message_box.h index bdaa31ec6dc..04792085b7a 100644 --- a/atom/browser/ui/message_box.h +++ b/atom/browser/ui/message_box.h @@ -11,6 +11,10 @@ #include "base/callback_forward.h" #include "base/strings/string16.h" +namespace gfx { +class ImageSkia; +} + namespace atom { class NativeWindow; @@ -28,7 +32,8 @@ int ShowMessageBox(NativeWindow* parent_window, const std::vector& buttons, const std::string& title, const std::string& message, - const std::string& detail); + const std::string& detail, + const gfx::ImageSkia& icon); void ShowMessageBox(NativeWindow* parent_window, MessageBoxType type, @@ -36,6 +41,7 @@ void ShowMessageBox(NativeWindow* parent_window, const std::string& title, const std::string& message, const std::string& detail, + const gfx::ImageSkia& icon, const MessageBoxCallback& callback); // Like ShowMessageBox with simplest settings, but safe to call at very early diff --git a/atom/browser/ui/message_box_mac.mm b/atom/browser/ui/message_box_mac.mm index 370b5911d0c..b3af25311ea 100644 --- a/atom/browser/ui/message_box_mac.mm +++ b/atom/browser/ui/message_box_mac.mm @@ -96,7 +96,8 @@ int ShowMessageBox(NativeWindow* parent_window, const std::vector& buttons, const std::string& title, const std::string& message, - const std::string& detail) { + const std::string& detail, + const gfx::ImageSkia& icon) { NSAlert* alert = CreateNSAlert( parent_window, type, buttons, title, message, detail); @@ -127,6 +128,7 @@ void ShowMessageBox(NativeWindow* parent_window, const std::string& title, const std::string& message, const std::string& detail, + const gfx::ImageSkia& icon, const MessageBoxCallback& callback) { NSAlert* alert = CreateNSAlert( parent_window, type, buttons, title, message, detail); diff --git a/atom/browser/ui/message_box_views.cc b/atom/browser/ui/message_box_views.cc index 959545c252d..6e1cc9daa2b 100644 --- a/atom/browser/ui/message_box_views.cc +++ b/atom/browser/ui/message_box_views.cc @@ -60,7 +60,8 @@ class MessageDialog : public views::WidgetDelegate, const std::vector& buttons, const std::string& title, const std::string& message, - const std::string& detail); + const std::string& detail, + const gfx::ImageSkia& icon); virtual ~MessageDialog(); void Show(base::RunLoop* run_loop = NULL); @@ -75,24 +76,28 @@ class MessageDialog : public views::WidgetDelegate, private: // Overridden from views::WidgetDelegate: - virtual base::string16 GetWindowTitle() const; - virtual views::Widget* GetWidget() OVERRIDE; - virtual const views::Widget* GetWidget() const OVERRIDE; - virtual views::View* GetContentsView() OVERRIDE; - virtual views::View* GetInitiallyFocusedView() OVERRIDE; - virtual ui::ModalType GetModalType() const OVERRIDE; - virtual views::NonClientFrameView* CreateNonClientFrameView( - views::Widget* widget) OVERRIDE; - virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; + base::string16 GetWindowTitle() const override; + gfx::ImageSkia GetWindowAppIcon() override; + gfx::ImageSkia GetWindowIcon() override; + bool ShouldShowWindowIcon() const override; + views::Widget* GetWidget() override; + const views::Widget* GetWidget() const override; + views::View* GetContentsView() override; + views::View* GetInitiallyFocusedView() override; + ui::ModalType GetModalType() const override; + views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) override; + views::ClientView* CreateClientView(views::Widget* widget) override; // Overridden from views::View: - virtual gfx::Size GetPreferredSize() const OVERRIDE; - virtual void Layout() OVERRIDE; - virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; + gfx::Size GetPreferredSize() const override; + void Layout() override; + bool AcceleratorPressed(const ui::Accelerator& accelerator) override; // Overridden from views::ButtonListener: - virtual void ButtonPressed(views::Button* sender, - const ui::Event& event) OVERRIDE; + void ButtonPressed(views::Button* sender, const ui::Event& event) override; + + gfx::ImageSkia icon_; bool delete_on_close_; int result_; @@ -118,7 +123,7 @@ class MessageDialogClientView : public views::ClientView { } // views::ClientView: - virtual bool CanClose() OVERRIDE { + bool CanClose() override { dialog_->Close(); return false; } @@ -137,8 +142,10 @@ MessageDialog::MessageDialog(NativeWindow* parent_window, const std::vector& buttons, const std::string& title, const std::string& message, - const std::string& detail) - : delete_on_close_(false), + const std::string& detail, + const gfx::ImageSkia& icon) + : icon_(icon), + delete_on_close_(false), result_(-1), title_(base::UTF8ToUTF16(title)), parent_(parent_window), @@ -174,6 +181,7 @@ MessageDialog::MessageDialog(NativeWindow* parent_window, views::Widget::InitParams params; params.delegate = this; + params.type = views::Widget::InitParams::TYPE_WINDOW; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; if (parent_) { params.parent = parent_->GetNativeWindow(); @@ -184,6 +192,7 @@ MessageDialog::MessageDialog(NativeWindow* parent_window, widget_.reset(new views::Widget); widget_->Init(params); + widget_->UpdateWindowIcon(); // Bind to ESC. AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); @@ -230,6 +239,18 @@ base::string16 MessageDialog::GetWindowTitle() const { return title_; } +gfx::ImageSkia MessageDialog::GetWindowAppIcon() { + return icon_; +} + +gfx::ImageSkia MessageDialog::GetWindowIcon() { + return icon_; +} + +bool MessageDialog::ShouldShowWindowIcon() const { + return true; +} + views::Widget* MessageDialog::GetWidget() { return widget_.get(); } @@ -338,8 +359,10 @@ int ShowMessageBox(NativeWindow* parent_window, const std::vector& buttons, const std::string& title, const std::string& message, - const std::string& detail) { - MessageDialog dialog(parent_window, type, buttons, title, message, detail); + const std::string& detail, + const gfx::ImageSkia& icon) { + MessageDialog dialog( + parent_window, type, buttons, title, message, detail, icon); { base::MessageLoop::ScopedNestableTaskAllower allow( base::MessageLoopForUI::current()); @@ -357,10 +380,11 @@ void ShowMessageBox(NativeWindow* parent_window, const std::string& title, const std::string& message, const std::string& detail, + const gfx::ImageSkia& icon, const MessageBoxCallback& callback) { // The dialog would be deleted when the dialog is closed. MessageDialog* dialog = new MessageDialog( - parent_window, type, buttons, title, message, detail); + parent_window, type, buttons, title, message, detail, icon); dialog->set_callback(callback); dialog->Show(); } diff --git a/atom/browser/ui/tray_icon.cc b/atom/browser/ui/tray_icon.cc index c8fb40902d4..68770c1e5cf 100644 --- a/atom/browser/ui/tray_icon.cc +++ b/atom/browser/ui/tray_icon.cc @@ -12,7 +12,7 @@ TrayIcon::TrayIcon() { TrayIcon::~TrayIcon() { } -void TrayIcon::SetPressedImage(const gfx::ImageSkia& image) { +void TrayIcon::SetPressedImage(const gfx::Image& image) { } void TrayIcon::SetTitle(const std::string& title) { @@ -21,7 +21,7 @@ void TrayIcon::SetTitle(const std::string& title) { void TrayIcon::SetHighlightMode(bool highlight) { } -void TrayIcon::DisplayBalloon(const gfx::ImageSkia& icon, +void TrayIcon::DisplayBalloon(const gfx::Image& icon, const base::string16& title, const base::string16& contents) { } diff --git a/atom/browser/ui/tray_icon.h b/atom/browser/ui/tray_icon.h index a27ea82f224..6293b39002b 100644 --- a/atom/browser/ui/tray_icon.h +++ b/atom/browser/ui/tray_icon.h @@ -20,10 +20,10 @@ class TrayIcon { virtual ~TrayIcon(); // Sets the image associated with this status icon. - virtual void SetImage(const gfx::ImageSkia& image) = 0; + virtual void SetImage(const gfx::Image& image) = 0; // Sets the image associated with this status icon when pressed. - virtual void SetPressedImage(const gfx::ImageSkia& image); + virtual void SetPressedImage(const gfx::Image& image); // Sets the hover text for this status icon. This is also used as the label // for the menu item which is created as a replacement for the status icon @@ -41,7 +41,7 @@ class TrayIcon { // Displays a notification balloon with the specified contents. // Depending on the platform it might not appear by the icon tray. - virtual void DisplayBalloon(const gfx::ImageSkia& icon, + virtual void DisplayBalloon(const gfx::Image& icon, const base::string16& title, const base::string16& contents); diff --git a/atom/browser/ui/tray_icon_cocoa.h b/atom/browser/ui/tray_icon_cocoa.h index bec04147af5..8d0cd5d5e29 100644 --- a/atom/browser/ui/tray_icon_cocoa.h +++ b/atom/browser/ui/tray_icon_cocoa.h @@ -22,8 +22,8 @@ class TrayIconCocoa : public TrayIcon { TrayIconCocoa(); virtual ~TrayIconCocoa(); - virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; - virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; + virtual void SetImage(const gfx::Image& image) OVERRIDE; + virtual void SetPressedImage(const gfx::Image& image) OVERRIDE; virtual void SetToolTip(const std::string& tool_tip) OVERRIDE; virtual void SetTitle(const std::string& title) OVERRIDE; virtual void SetHighlightMode(bool highlight) OVERRIDE; diff --git a/atom/browser/ui/tray_icon_cocoa.mm b/atom/browser/ui/tray_icon_cocoa.mm index 143e767831a..408ba29a14e 100644 --- a/atom/browser/ui/tray_icon_cocoa.mm +++ b/atom/browser/ui/tray_icon_cocoa.mm @@ -53,20 +53,14 @@ TrayIconCocoa::~TrayIconCocoa() { [[NSStatusBar systemStatusBar] removeStatusItem:item_]; } -void TrayIconCocoa::SetImage(const gfx::ImageSkia& image) { - if (!image.isNull()) { - gfx::Image neutral(image); - if (!neutral.IsEmpty()) - [item_ setImage:neutral.ToNSImage()]; - } +void TrayIconCocoa::SetImage(const gfx::Image& image) { + if (!image.IsEmpty()) + [item_ setImage:image.ToNSImage()]; } -void TrayIconCocoa::SetPressedImage(const gfx::ImageSkia& image) { - if (!image.isNull()) { - gfx::Image neutral(image); - if (!neutral.IsEmpty()) - [item_ setAlternateImage:neutral.ToNSImage()]; - } +void TrayIconCocoa::SetPressedImage(const gfx::Image& image) { + if (!image.IsEmpty()) + [item_ setAlternateImage:image.ToNSImage()]; } void TrayIconCocoa::SetToolTip(const std::string& tool_tip) { diff --git a/atom/browser/ui/tray_icon_gtk.cc b/atom/browser/ui/tray_icon_gtk.cc index c7a56ddb037..d95109c26e6 100644 --- a/atom/browser/ui/tray_icon_gtk.cc +++ b/atom/browser/ui/tray_icon_gtk.cc @@ -8,6 +8,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h" #include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h" +#include "ui/gfx/image/image.h" namespace atom { @@ -17,18 +18,18 @@ TrayIconGtk::TrayIconGtk() { TrayIconGtk::~TrayIconGtk() { } -void TrayIconGtk::SetImage(const gfx::ImageSkia& image) { +void TrayIconGtk::SetImage(const gfx::Image& image) { if (icon_) { - icon_->SetImage(image); + icon_->SetImage(image.AsImageSkia()); return; } base::string16 empty; if (libgtk2ui::AppIndicatorIcon::CouldOpen()) - icon_.reset( - new libgtk2ui::AppIndicatorIcon(base::GenerateGUID(), image, empty)); + icon_.reset(new libgtk2ui::AppIndicatorIcon( + base::GenerateGUID(), image.AsImageSkia(), empty)); else - icon_.reset(new libgtk2ui::Gtk2StatusIcon(image, empty)); + icon_.reset(new libgtk2ui::Gtk2StatusIcon(image.AsImageSkia(), empty)); icon_->set_delegate(this); } diff --git a/atom/browser/ui/tray_icon_gtk.h b/atom/browser/ui/tray_icon_gtk.h index 5027a2d4489..ce9ae3cf2b7 100644 --- a/atom/browser/ui/tray_icon_gtk.h +++ b/atom/browser/ui/tray_icon_gtk.h @@ -23,7 +23,7 @@ class TrayIconGtk : public TrayIcon, virtual ~TrayIconGtk(); // TrayIcon: - virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; + virtual void SetImage(const gfx::Image& image) OVERRIDE; virtual void SetToolTip(const std::string& tool_tip) OVERRIDE; virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE; diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 97842989559..1a472e2edc1 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -10,6 +10,7 @@ #include "base/win/windows_version.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/icon_util.h" +#include "ui/gfx/image/image.h" #include "ui/gfx/point.h" #include "ui/gfx/rect.h" #include "ui/views/controls/menu/menu_runner.h" @@ -90,19 +91,19 @@ void NotifyIcon::ResetIcon() { LOG(WARNING) << "Unable to re-create status tray icon."; } -void NotifyIcon::SetImage(const gfx::ImageSkia& image) { +void NotifyIcon::SetImage(const gfx::Image& image) { // Create the icon. NOTIFYICONDATA icon_data; InitIconData(&icon_data); icon_data.uFlags = NIF_ICON; - icon_.Set(IconUtil::CreateHICONFromSkBitmap(*image.bitmap())); + icon_.Set(IconUtil::CreateHICONFromSkBitmap(image.AsBitmap())); icon_data.hIcon = icon_.Get(); BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data); if (!result) LOG(WARNING) << "Error setting status tray icon image"; } -void NotifyIcon::SetPressedImage(const gfx::ImageSkia& image) { +void NotifyIcon::SetPressedImage(const gfx::Image& image) { // Ignore pressed images, since the standard on Windows is to not highlight // pressed status icons. } @@ -118,7 +119,7 @@ void NotifyIcon::SetToolTip(const std::string& tool_tip) { LOG(WARNING) << "Unable to set tooltip for status tray icon"; } -void NotifyIcon::DisplayBalloon(const gfx::ImageSkia& icon, +void NotifyIcon::DisplayBalloon(const gfx::Image& icon, const base::string16& title, const base::string16& contents) { NOTIFYICONDATA icon_data; @@ -130,8 +131,8 @@ void NotifyIcon::DisplayBalloon(const gfx::ImageSkia& icon, icon_data.uTimeout = 0; base::win::Version win_version = base::win::GetVersion(); - if (!icon.isNull() && win_version != base::win::VERSION_PRE_XP) { - balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(*icon.bitmap())); + if (!icon.IsEmpty() && win_version != base::win::VERSION_PRE_XP) { + balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(icon.AsBitmap())); icon_data.hBalloonIcon = balloon_icon_.Get(); icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON; } diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index 2ac309d5dba..12eea1fcf72 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -43,10 +43,10 @@ class NotifyIcon : public TrayIcon { UINT message_id() const { return message_id_; } // Overridden from TrayIcon: - void SetImage(const gfx::ImageSkia& image) override; - void SetPressedImage(const gfx::ImageSkia& image) override; + void SetImage(const gfx::Image& image) override; + void SetPressedImage(const gfx::Image& image) override; void SetToolTip(const std::string& tool_tip) override; - void DisplayBalloon(const gfx::ImageSkia& icon, + void DisplayBalloon(const gfx::Image& icon, const base::string16& title, const base::string16& contents) override; void SetContextMenu(ui::SimpleMenuModel* menu_model) override; diff --git a/atom/common/api/lib/screen.coffee b/atom/common/api/lib/screen.coffee index da7701e55a4..e2913fcb8a9 100644 --- a/atom/common/api/lib/screen.coffee +++ b/atom/common/api/lib/screen.coffee @@ -1,6 +1,17 @@ +binding = process.atomBinding 'screen' + +checkAppIsReady = -> + unless process.type is 'renderer' or require('app').isReady() + throw new Error('Can not use screen module before the "ready" event of app module gets emitted') + module.exports = if process.platform in ['linux', 'win32'] and process.type is 'renderer' # On Linux we could not access screen in renderer process. require('remote').require 'screen' else - process.atomBinding 'screen' + getCursorScreenPoint: -> + checkAppIsReady() + binding.getCursorScreenPoint() + getPrimaryDisplay: -> + checkAppIsReady() + binding.getPrimaryDisplay() diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 257a3a7ac45..4aa6ae00e4e 100644 --- a/atom/common/atom_version.h +++ b/atom/common/atom_version.h @@ -7,7 +7,7 @@ #define ATOM_MAJOR_VERSION 0 #define ATOM_MINOR_VERSION 20 -#define ATOM_PATCH_VERSION 2 +#define ATOM_PATCH_VERSION 5 #define ATOM_VERSION_IS_RELEASE 1 diff --git a/atom/common/native_mate_converters/image_converter.cc b/atom/common/native_mate_converters/image_converter.cc index 7f4a434d97c..0c239e199e5 100644 --- a/atom/common/native_mate_converters/image_converter.cc +++ b/atom/common/native_mate_converters/image_converter.cc @@ -12,9 +12,12 @@ #include "base/strings/string_util.h" #include "ui/gfx/codec/jpeg_codec.h" #include "ui/gfx/codec/png_codec.h" +#include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" #include "ui/base/layout.h" +#if !defined(OS_MACOSX) + namespace mate { namespace { @@ -29,6 +32,8 @@ ScaleFactorPair kScaleFactorPairs[] = { { "@2x" , 2.0f }, { "@3x" , 3.0f }, { "@1x" , 1.0f }, + { "@4x" , 4.0f }, + { "@5x" , 5.0f }, { "@1.25x" , 1.25f }, { "@1.33x" , 1.33f }, { "@1.4x" , 1.4f }, @@ -40,10 +45,6 @@ ScaleFactorPair kScaleFactorPairs[] = { float GetScaleFactorFromPath(const base::FilePath& path) { std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe()); - // There is no scale info in the file path. - if (!EndsWith(filename, "x", true)) - return 1.0f; - // We don't try to convert string to float here because it is very very // expensive. for (unsigned i = 0; i < arraysize(kScaleFactorPairs); ++i) { @@ -54,27 +55,9 @@ float GetScaleFactorFromPath(const base::FilePath& path) { return 1.0f; } -void AppendIfExists(std::vector* paths, - const base::FilePath& path) { - if (base::PathExists(path)) - paths->push_back(path); -} - -void PopulatePossibleFilePaths(std::vector* paths, - const base::FilePath& path) { - AppendIfExists(paths, path); - - std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe()); - if (MatchPattern(filename, "*@*x")) - return; - - for (unsigned i = 0; i < arraysize(kScaleFactorPairs); ++i) - AppendIfExists(paths, - path.InsertBeforeExtensionASCII(kScaleFactorPairs[i].name)); -} - -bool AddImageSkiaRepFromPath(gfx::ImageSkia* image, - const base::FilePath& path) { +bool AddImageSkiaRep(gfx::ImageSkia* image, + const base::FilePath& path, + double scale_factor) { std::string file_contents; if (!base::ReadFileToString(path, &file_contents)) return false; @@ -89,13 +72,28 @@ bool AddImageSkiaRepFromPath(gfx::ImageSkia* image, // Try JPEG. decoded.reset(gfx::JPEGCodec::Decode(data, size)); - if (decoded) { - image->AddRepresentation(gfx::ImageSkiaRep( - *decoded.release(), GetScaleFactorFromPath(path))); - return true; - } + if (!decoded) + return false; - return false; + image->AddRepresentation(gfx::ImageSkiaRep(*decoded.release(), scale_factor)); + return true; +} + +bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image, + const base::FilePath& path) { + bool succeed = false; + std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe()); + if (MatchPattern(filename, "*@*x")) + // Don't search for other representations if the DPI has been specified. + return AddImageSkiaRep(image, path, GetScaleFactorFromPath(path)); + else + succeed |= AddImageSkiaRep(image, path, 1.0f); + + for (const ScaleFactorPair& pair : kScaleFactorPairs) + succeed |= AddImageSkiaRep(image, + path.InsertBeforeExtensionASCII(pair.name), + pair.scale); + return succeed; } } // namespace @@ -103,21 +101,27 @@ bool AddImageSkiaRepFromPath(gfx::ImageSkia* image, bool Converter::FromV8(v8::Isolate* isolate, v8::Handle val, gfx::ImageSkia* out) { - base::FilePath path; - if (Converter::FromV8(isolate, val, &path)) { - std::vector paths; - PopulatePossibleFilePaths(&paths, path); - if (paths.empty()) - return false; - - for (size_t i = 0; i < paths.size(); ++i) { - if (!AddImageSkiaRepFromPath(out, paths[i])) - return false; - } + if (val->IsNull()) return true; - } - return false; + base::FilePath path; + if (!Converter::FromV8(isolate, val, &path)) + return false; + + return PopulateImageSkiaRepsFromPath(out, path); +} + +bool Converter::FromV8(v8::Isolate* isolate, + v8::Handle val, + gfx::Image* out) { + gfx::ImageSkia image; + if (!ConvertFromV8(isolate, val, &image)) + return false; + + *out = gfx::Image(image); + return true; } } // namespace mate + +#endif // !defined(OS_MACOSX) diff --git a/atom/common/native_mate_converters/image_converter.h b/atom/common/native_mate_converters/image_converter.h index 53de920d6e0..738b50ad741 100644 --- a/atom/common/native_mate_converters/image_converter.h +++ b/atom/common/native_mate_converters/image_converter.h @@ -8,6 +8,7 @@ #include "native_mate/converter.h" namespace gfx { +class Image; class ImageSkia; } @@ -20,6 +21,13 @@ struct Converter { gfx::ImageSkia* out); }; +template<> +struct Converter { + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, + gfx::Image* out); +}; + } // namespace mate #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_IMAGE_CONVERTER_H_ diff --git a/atom/common/native_mate_converters/image_converter_mac.mm b/atom/common/native_mate_converters/image_converter_mac.mm new file mode 100644 index 00000000000..67871ee32f3 --- /dev/null +++ b/atom/common/native_mate_converters/image_converter_mac.mm @@ -0,0 +1,60 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/common/native_mate_converters/image_converter.h" + +#import + +#include "base/mac/foundation_util.h" +#include "base/mac/scoped_nsobject.h" +#include "base/strings/string_util.h" +#include "base/strings/sys_string_conversions.h" +#include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" + +namespace { + +bool IsTemplateImage(const std::string& path) { + return (MatchPattern(path, "*Template.*") || + MatchPattern(path, "*Template@*x.*")); +} + +} // namespace + +namespace mate { + +bool Converter::FromV8(v8::Isolate* isolate, + v8::Handle val, + gfx::ImageSkia* out) { + gfx::Image image; + if (!ConvertFromV8(isolate, val, &image)) + return false; + + *out = image.AsImageSkia(); + return true; +} + +bool Converter::FromV8(v8::Isolate* isolate, + v8::Handle val, + gfx::Image* out) { + if (val->IsNull()) + return true; + + std::string path; + if (!ConvertFromV8(isolate, val, &path)) + return false; + + base::scoped_nsobject image([[NSImage alloc] + initByReferencingFile:base::SysUTF8ToNSString(path)]); + if (![image isValid]) + return false; + + if (IsTemplateImage(path)) + [image setTemplate:YES]; + + *out = gfx::Image(image.release()); + return true; +} + +} // namespace mate diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index 4d808b356bc..7c34b222ff0 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -16,7 +16,7 @@ namespace atom { namespace { -const int kMaxRecursionDepth = 100; +const int kMaxRecursionDepth = 20; } // namespace @@ -294,10 +294,7 @@ base::Value* V8ValueConverter::FromV8Array( if (!val->HasRealIndexedProperty(i)) continue; - // When parsing elements in an array, we use a new state so we can have the - // same object showed twice in array. - FromV8ValueState new_state; - base::Value* child = FromV8ValueImpl(&new_state, child_v8, isolate); + base::Value* child = FromV8ValueImpl(state, child_v8, isolate); if (child) result->Append(child); else diff --git a/atom/common/node_includes.h b/atom/common/node_includes.h index c2594122be7..80567cbd49b 100644 --- a/atom/common/node_includes.h +++ b/atom/common/node_includes.h @@ -7,6 +7,7 @@ // Include common headers for using node APIs. +#undef ASSERT #undef CHECK #undef CHECK_EQ #undef CHECK_NE @@ -15,6 +16,7 @@ #undef CHECK_LE #undef CHECK_LT #undef DISALLOW_COPY_AND_ASSIGN +#undef NO_RETURN #undef debug_string // This is defined in OS X 10.9 SDK in AssertMacros.h. #include "vendor/node/src/env.h" #include "vendor/node/src/env-inl.h" diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index 43107e36462..76cfad3319a 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -80,6 +80,9 @@ const char kOverlayScrollbars[] = "overlay-scrollbars"; const char kOverlayFullscreenVideo[] = "overlay-fullscreen-video"; const char kSharedWorker[] = "shared-worker"; +// Disable HTTP cache. +const char kDisableHttpCache[] = "disable-http-cache"; + } // namespace switches } // namespace atom diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index cc55331be6f..a2cfb574dfc 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -48,6 +48,8 @@ extern const char kOverlayScrollbars[]; extern const char kOverlayFullscreenVideo[]; extern const char kSharedWorker[]; +extern const char kDisableHttpCache[]; + } // namespace switches } // namespace atom diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index 7d43428f4d0..bf2cd54acbe 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -4,6 +4,11 @@ #include "atom/renderer/api/atom_api_web_frame.h" +// This defines are required by SchemeRegistry.h. +#define OS(WTF_FEATURE) (defined WTF_OS_##WTF_FEATURE && WTF_OS_##WTF_FEATURE) // NOLINT +#define USE(WTF_FEATURE) (defined WTF_USE_##WTF_FEATURE && WTF_USE_##WTF_FEATURE) // NOLINT +#define ENABLE(WTF_FEATURE) (defined ENABLE_##WTF_FEATURE && ENABLE_##WTF_FEATURE) // NOLINT + #include "atom/common/native_mate_converters/string16_converter.h" #include "atom/renderer/api/atom_api_spell_check_client.h" #include "content/public/renderer/render_frame.h" @@ -12,9 +17,28 @@ #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebView.h" +#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h" #include "atom/common/node_includes.h" +namespace mate { + +template<> +struct Converter { + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, + WTF::String* out) { + if (!val->IsString()) + return false; + + v8::String::Value s(val); + *out = WTF::String(reinterpret_cast(*s), s.length()); + return true; + } +}; + +} // namespace mate + namespace atom { namespace api { @@ -82,7 +106,9 @@ mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder( .SetMethod("registerEmbedderCustomElement", &WebFrame::RegisterEmbedderCustomElement) .SetMethod("attachGuest", &WebFrame::AttachGuest) - .SetMethod("setSpellCheckProvider", &WebFrame::SetSpellCheckProvider); + .SetMethod("setSpellCheckProvider", &WebFrame::SetSpellCheckProvider) + .SetMethod("registerUrlSchemeAsSecure", + &blink::SchemeRegistry::registerURLSchemeAsSecure); } // static diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index 6ac57ac97d8..d17e7a9cd9b 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -14,6 +14,10 @@ app.on('ready', function() { }); ``` +## --disable-http-cache + +Disables the disk cache for HTTP requests. + ## --remote-debugging-port=`port` Enables remote debug over HTTP on the specified `port`. @@ -53,3 +57,7 @@ Like `--host-rules` but these `rules` only apply to the host resolver. [app]: app.md [append-switch]: app.md#appcommandlineappendswitchswitch-value [ready]: app.md#event-ready + +## --ignore-certificate-errors + +Ignore certificate related errors. diff --git a/docs/api/dialog.md b/docs/api/dialog.md index 9c1f1c8addb..a0e29f4fd9a 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -76,6 +76,7 @@ would be passed via `callback(filename)` * `title` String - Title of the message box, some platforms will not show it * `message` String - Content of the message box * `detail` String - Extra information of the message + * `icon` [Image](image.md) * `callback` Function Shows a message box, it will block until the message box is closed. It returns @@ -83,3 +84,10 @@ the index of the clicked button. If a `callback` is passed, the API call would be asynchronous and the result would be passed via `callback(response)` + +## dialog.showErrorBox(title, content) + +Runs a modal dialog that shows an error message. + +This API can be called safely before the `ready` event of `app` module emits, it +is usually used to report errors in early stage of startup. diff --git a/docs/api/image.md b/docs/api/image.md index 75545e99ade..d7cf8aeea73 100644 --- a/docs/api/image.md +++ b/docs/api/image.md @@ -13,7 +13,10 @@ var window = new BrowserWindow({icon: '/Users/somebody/images/window.png'}); ## Supported formats -Only `PNG` and `JPG` formats are supported, and `PNG` format is preferred. +On Mac all formats supported by the system can be used, while on Linux and +Windows only `PNG` and `JPG` formats are supported. + +So it is recommended to use `PNG` images for all cases. ## High resolution image @@ -51,4 +54,22 @@ Following suffixes as DPI denses are also supported: * `@2x` * `@2.5x` * `@3x` +* `@4x` +* `@5x` +## Template image + +Template images consist of black and clear colors (and an alpha channel). +Template images are not intended to be used as standalone images and are usually +mixed with other content to create the desired final appearance. + +The most common case is to use template image for menu bar icon so it can adapt +to both light and dark menu bars. + +Template image is only supported on Mac. + +To mark an image as template image, its filename should end with the word +`Template`, examples are: + +* `xxxTemplate.png` +* `xxxTemplate@2x.png` diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index f5bdd695a3c..73b9ee50577 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -53,4 +53,14 @@ require('web-frame').setSpellCheckProvider("en-US", true, { }); ``` +## webFrame.registerUrlSchemeAsSecure(scheme) + +* `scheme` String + +Sets the `scheme` as secure scheme. + +Secure schemes do not trigger mixed content warnings. For example, `https` and +`data` are secure schemes because they cannot be corrupted by active network +attackers. + [spellchecker]: https://github.com/atom/node-spellchecker diff --git a/docs/development/build-instructions-windows.md b/docs/development/build-instructions-windows.md index ae495034bff..1b4bf5282a6 100644 --- a/docs/development/build-instructions-windows.md +++ b/docs/development/build-instructions-windows.md @@ -111,3 +111,8 @@ Simply making that directory [should fix the problem](http://stackoverflow.com/a ```powershell mkdir ~\AppData\Roaming\npm ``` + +### node-gyp is not recognized as an internal or external command + +You may get this error if you are using Git Bash for building, you should use +PowerShell or VS2012 Command Prompt instead. diff --git a/docs/tutorial/application-distribution.md b/docs/tutorial/application-distribution.md index ff1030bbf7d..2a48993fec9 100644 --- a/docs/tutorial/application-distribution.md +++ b/docs/tutorial/application-distribution.md @@ -27,35 +27,6 @@ Then execute `Atom.app` (or `atom` on Linux, and `atom.exe` on Windows), and atom-shell will start as your app. The `atom-shell` directory would then be your distribution that should be delivered to final users. -## Renaming Atom Shell for your app - -The best way to rename Atom Shell is to change the `atom.gyp` file, then build -from source. Open up `atom.gyp` and change the first lines: - -``` -'project_name': 'atom', -'product_name': 'Atom', -'framework_name': 'Atom Framework', -``` - -Once you make the change, re-run `script/bootstrap` then run the command: - -```sh -script/build.py -c Release -t $whatever_you_chose_for_project_name -``` - -If your app is OS X / Linux-only, you can also simply rename the "Atom.app" -folder as well as the names under "Framework" (i.e. "Atom Framework.framework" -=> "MyApp Framework.framework"), but this will break loading native Node -modules on Windows. - -Fixing this is complicated, but a Grunt task has been created that will handle -this automatically, -[grunt-build-atom-shell](https://github.com/paulcbetts/grunt-build-atom-shell). -This task will automatically handle editing the .gyp file, building from -source, then rebuilding your app's native Node modules to match the new -executable name. - ## Packaging your app into a file Apart from shipping your app by copying all its sources files, you can also @@ -63,13 +34,86 @@ package your app into an [asar](https://github.com/atom/asar) archive to avoid exposing your app's source code to users. To use an `asar` archive to replace the `app` folder, you need to rename the -archive to `app.asar`, and put it under atom-shell's resources directory, -atom-shell will then try read the archive and start from it. +archive to `app.asar`, and put it under atom-shell's resources directory like +bellow, and atom-shell will then try read the archive and start from it. + +On Mac OS X: + +```text +atom-shell/Atom.app/Contents/Resources/ +└── app.asar +``` + +On Windows and Linux: + +```text +atom-shell/resources/ +└── app.asar +``` More details can be found in [Application packaging](application-packaging.md). -## Building with grunt +## Rebranding with downloaded binaries -If you build your application with `grunt` there is a grunt task that can -download atom-shell for your current platform automatically: +After bundling your app into atom-shell, you will want to rebrand atom-shell +before distributing it to users. + +If you don't care about the executable name on Windows or the helper process +name on OS X, you can simply rename the downloaded binaries, and there is also a +grunt task that can download prebuilt atom-shell binaries for your current +platform automatically: [grunt-download-atom-shell](https://github.com/atom/grunt-download-atom-shell). + +### Windows + +You can not rename the `atom.exe` otherwise native modules will not load. But +you can edit the executable's icon and other information with tools like +[rcedit](https://github.com/atom/rcedit) or [ResEdit](http://www.resedit.net). + +If you don't use any native Node module, it is fine to rename `atom.exe` to any +name you want. + +### OS X + +You can rename `Atom.app` to whatever you want, and you also have to rename the +`CFBundleDisplayName`, `CFBundleIdentifier` and `CFBundleName` fields in +following manifest files if they have these keys: + +* `Atom.app/Contents/Info.plist` +* `Atom.app/Contents/Frameworks/Atom Helper.app/Contents/Info.plist` + +### Linux + +You can rename the `atom` executable to whatever you want. + +## Rebranding by rebuilding atom-shell from source + +The best way to rename atom-shell is to change the product name and then build +from source. To do this you need to override the `GYP_DEFINES` environment +variable and have a clean rebuild: + +__Windows__ + +```cmd +> set GYP_DEFINES="project_name=myapp product_name=MyApp" +> python script\bootstrap.py +> python script\build.py -c Release -t myapp +``` + +__Bash__ + +```bash +$ export GYP_DEFINES="project_name=myapp product_name=MyApp" +$ script/bootstrap.py +$ script/build.py -c Release -t myapp +``` + +### grunt-build-atom-shell + +Manually checking out atom-shell's code and rebuilding could be complicated, so +a Grunt task has been created that will handle this automatically: +[grunt-build-atom-shell](https://github.com/paulcbetts/grunt-build-atom-shell). + +This task will automatically handle editing the `.gyp` file, building from +source, then rebuilding your app's native Node modules to match the new +executable name. diff --git a/package.json b/package.json index f302f823e08..726b07f2d31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "atom-shell", - "version": "0.20.2", + "version": "0.20.5", "licenses": [ { diff --git a/script/lib/config.py b/script/lib/config.py index daa3f1f8806..6619123a83a 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -4,7 +4,7 @@ import platform import sys BASE_URL = 'http://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent' -LIBCHROMIUMCONTENT_COMMIT = '4a2843d7a370ba135a7549d203d4fe471c2c10fb' +LIBCHROMIUMCONTENT_COMMIT = 'fba5addae75d944d62a8bd5f4fd23c2929405c83' ARCH = { 'cygwin': '32bit', diff --git a/spec/api-ipc-spec.coffee b/spec/api-ipc-spec.coffee index 826b094e534..c63997af7e7 100644 --- a/spec/api-ipc-spec.coffee +++ b/spec/api-ipc-spec.coffee @@ -60,14 +60,6 @@ describe 'ipc module', -> done() ipc.send 'message', obj - it 'should work when sending the same object twice in one message', (done) -> - obj = key: 'some' - ipc.once 'message', (message) -> - assert.deepEqual message[0], obj - assert.deepEqual message[1], obj - done() - ipc.send 'message', [obj, obj] - describe 'ipc.sendSync', -> it 'can be replied by setting event.returnValue', -> msg = ipc.sendSync 'echo', 'test' diff --git a/vendor/brightray b/vendor/brightray index 77e3a33ffd0..1eb88b037d9 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 77e3a33ffd0dff64f6b1cbc59d74796bff9d26f1 +Subproject commit 1eb88b037d99ca1ca7708f30b47f158d9c9639e6 diff --git a/vendor/native_mate b/vendor/native_mate index 4a1d11b2bea..753d5675dd5 160000 --- a/vendor/native_mate +++ b/vendor/native_mate @@ -1 +1 @@ -Subproject commit 4a1d11b2bea0907c66bf986ab635e161a1a16385 +Subproject commit 753d5675dd58aab3d3c429a233803ad4598802bc