electron/atom/renderer/atom_render_view_observer.h
Cheng Zhao 0bcc9b7713 Don't handle browser messages before document object is created
When we recevied messages from browser, we will try to transfer the
message to web page, and when we do that blink will create an empty
document when there is no document object yet, which will make our init
script run when window.location is still about:blank.
2015-01-23 18:33:01 -08:00

47 lines
1.3 KiB
C++

// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef 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"
namespace base {
class ListValue;
}
namespace atom {
class AtomRendererClient;
class AtomRenderViewObserver : public content::RenderViewObserver {
public:
explicit AtomRenderViewObserver(content::RenderView* render_view,
AtomRendererClient* renderer_client);
protected:
virtual ~AtomRenderViewObserver();
private:
// content::RenderViewObserver implementation.
virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) OVERRIDE;
virtual void DraggableRegionsChanged(blink::WebFrame* frame) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
void OnBrowserMessage(const base::string16& channel,
const base::ListValue& args);
// Weak reference to renderer client.
AtomRendererClient* renderer_client_;
// Whether the document object has been created.
bool document_created_;
DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver);
};
} // namespace atom
#endif // ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_