From 9cf890bb61d0e565e3ebf4d9a3c2c3b38d05e76d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 28 May 2013 16:01:44 +0800 Subject: [PATCH] Add BrowserWindow.restart() to restart renderer process. --- browser/api/lib/browser_window.coffee | 3 +++ browser/atom_browser_client.cc | 8 ++++++++ browser/atom_browser_client.h | 4 ++++ vendor/brightray | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/browser/api/lib/browser_window.coffee b/browser/api/lib/browser_window.coffee index 7f21575fd93..2e06ebcb4e7 100644 --- a/browser/api/lib/browser_window.coffee +++ b/browser/api/lib/browser_window.coffee @@ -14,6 +14,9 @@ BrowserWindow::toggleDevTools = -> @openDevTools() v8Util.setHiddenValue this, 'devtoolsOpened', true +BrowserWindow::restart = -> + @loadUrl(@getUrl()) + BrowserWindow.getFocusedWindow = -> windows = objectsRegistry.getAllWindows() return window for window in windows when window.isFocused() diff --git a/browser/atom_browser_client.cc b/browser/atom_browser_client.cc index df60109e82b..8b66167a847 100644 --- a/browser/atom_browser_client.cc +++ b/browser/atom_browser_client.cc @@ -38,6 +38,14 @@ void AtomBrowserClient::OverrideWebkitPrefs( prefs->enable_scroll_animator = false; } +bool AtomBrowserClient::ShouldSwapProcessesForNavigation( + content::SiteInstance* site_instance, + const GURL& current_url, + const GURL& new_url) { + // Restart renderer process if navigating to the same url. + return current_url == new_url; +} + brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts( const content::MainFunctionParams&) { return new AtomBrowserMainParts; diff --git a/browser/atom_browser_client.h b/browser/atom_browser_client.h index 22f08d2eac0..196329d3444 100644 --- a/browser/atom_browser_client.h +++ b/browser/atom_browser_client.h @@ -18,6 +18,10 @@ class AtomBrowserClient : public brightray::BrowserClient { virtual void OverrideWebkitPrefs(content::RenderViewHost* render_view_host, const GURL& url, webkit_glue::WebPreferences* prefs) OVERRIDE; + virtual bool ShouldSwapProcessesForNavigation( + content::SiteInstance* site_instance, + const GURL& current_url, + const GURL& new_url) OVERRIDE; private: virtual brightray::BrowserMainParts* OverrideCreateBrowserMainParts( diff --git a/vendor/brightray b/vendor/brightray index 6b9c1b6761f..e2c74cd6631 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 6b9c1b6761ff164173e4f7fdebc478af99e411e5 +Subproject commit e2c74cd6631fa7289e36e34f5c6e286bb1e961c2