mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
WIP: sending reload message to render process on meta-r
This commit is contained in:
@@ -9,13 +9,15 @@ class AtomCefApp : public CefApp,
|
||||
|
||||
// CefApp methods
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE { return this; }
|
||||
|
||||
// CefRenderProcessHandler methods
|
||||
virtual void OnWebKitInitialized() OVERRIDE;
|
||||
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
|
||||
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(AtomCefApp);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "atom_cef_app.h"
|
||||
#import "native/v8_extensions/native.h"
|
||||
#import "native/v8_extensions/onig_reg_exp.h"
|
||||
#include <iostream>
|
||||
|
||||
void AtomCefApp::OnWebKitInitialized() {
|
||||
new NativeHandler();
|
||||
@@ -22,3 +23,10 @@ void AtomCefApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
atom->SetValue("resourcePath", resourcePath, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
|
||||
bool AtomCefApp::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) {
|
||||
std::cout << "MESSAGE RECEIVED ON RENDERER PROCESS:" << message->GetName().ToString();
|
||||
return true;
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "include/cef_process_util.h"
|
||||
#include "include/cef_runnable.h"
|
||||
#include "native/atom_cef_client.h"
|
||||
#include "cef_v8.h"
|
||||
|
||||
AtomCefClient::AtomCefClient(){
|
||||
|
||||
@@ -52,6 +53,37 @@ bool AtomCefClient::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool AtomCefClient::OnKeyEvent(CefRefPtr<CefBrowser> browser,
|
||||
const CefKeyEvent& event,
|
||||
CefEventHandle os_event) {
|
||||
if (event.modifiers == KEY_META && event.character == 'r') {
|
||||
browser->SendProcessMessage(PID_RENDERER, CefProcessMessage::Create("reload"));
|
||||
}
|
||||
|
||||
// if (type == KEYEVENT_RAWKEYDOWN && modifiers == KEY_META && code == 'R') {
|
||||
// CefRefPtr<CefV8Context> context = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();
|
||||
// CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
//
|
||||
// context->Enter();
|
||||
// CefRefPtr<CefV8Value> retval;
|
||||
// CefRefPtr<CefV8Exception> exception;
|
||||
// CefV8ValueList arguments;
|
||||
//
|
||||
// global->GetValue("reload")->ExecuteFunction(global, arguments, retval, exception, true);
|
||||
// if (exception.get()) {
|
||||
// _clientHandler->GetBrowser()->ReloadIgnoreCache();
|
||||
// }
|
||||
// context->Exit();
|
||||
//
|
||||
// return YES;
|
||||
// }
|
||||
// if (type == KEYEVENT_RAWKEYDOWN && modifiers == (KEY_META | KEY_ALT) && code == 'I') {
|
||||
// [self toggleDevTools];
|
||||
// return YES;
|
||||
// }
|
||||
}
|
||||
|
||||
void AtomCefClient::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
|
||||
@@ -65,6 +65,12 @@ class AtomCefClient : public CefClient,
|
||||
int line) OVERRIDE;
|
||||
|
||||
|
||||
|
||||
// CefKeyboardHandler methods
|
||||
virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser,
|
||||
const CefKeyEvent& event,
|
||||
CefEventHandle os_event) OVERRIDE;
|
||||
|
||||
// CefLifeSpanHandler methods
|
||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
#import "include/cef_browser.h"
|
||||
#import "include/cef_frame.h"
|
||||
#import "native/atom_cef_client.h"
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)populateBrowserSettings:(CefBrowserSettings &)settings {
|
||||
CefString(&settings.default_encoding) = "UTF-8";
|
||||
settings.remote_fonts_disabled = true;
|
||||
|
||||
Reference in New Issue
Block a user