This repository has been archived by the owner on Jan 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remote callbacks are still used in electron.remote.Menu in browser-la…
…ptop
- Loading branch information
Showing
6 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2016 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "atom/common/api/remote_callback_freer.h" | ||
|
||
#include "atom/common/api/api_messages.h" | ||
#include "base/strings/utf_string_conversions.h" | ||
#include "base/values.h" | ||
#include "content/public/browser/render_view_host.h" | ||
#include "content/public/browser/web_contents.h" | ||
|
||
namespace atom { | ||
|
||
// static | ||
void RemoteCallbackFreer::BindTo(v8::Isolate* isolate, | ||
v8::Local<v8::Object> target, | ||
int object_id, | ||
content::WebContents* web_contents) { | ||
new RemoteCallbackFreer(isolate, target, object_id, web_contents); | ||
} | ||
|
||
RemoteCallbackFreer::RemoteCallbackFreer(v8::Isolate* isolate, | ||
v8::Local<v8::Object> target, | ||
int object_id, | ||
content::WebContents* web_contents) | ||
: ObjectLifeMonitor(isolate, target), | ||
content::WebContentsObserver(web_contents), | ||
object_id_(object_id) { | ||
} | ||
|
||
RemoteCallbackFreer::~RemoteCallbackFreer() { | ||
} | ||
|
||
void RemoteCallbackFreer::RunDestructor() { | ||
base::string16 channel = | ||
base::ASCIIToUTF16("ELECTRON_RENDERER_RELEASE_CALLBACK"); | ||
base::ListValue args; | ||
args.AppendInteger(object_id_); | ||
web_contents()->GetRenderViewHost()->Send(new AtomViewMsg_Message( | ||
web_contents()->GetRenderViewHost()->GetRoutingID(), channel, | ||
args)); | ||
|
||
Observe(nullptr); | ||
} | ||
|
||
void RemoteCallbackFreer::RenderViewDeleted(content::RenderViewHost*) { | ||
delete this; | ||
} | ||
|
||
} // namespace atom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2016 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ATOM_COMMON_API_REMOTE_CALLBACK_FREER_H_ | ||
#define ATOM_COMMON_API_REMOTE_CALLBACK_FREER_H_ | ||
#include "atom/common/api/object_life_monitor.h" | ||
#include "content/public/browser/web_contents_observer.h" | ||
|
||
namespace atom { | ||
|
||
class RemoteCallbackFreer : public ObjectLifeMonitor, | ||
public content::WebContentsObserver { | ||
public: | ||
static void BindTo(v8::Isolate* isolate, | ||
v8::Local<v8::Object> target, | ||
int object_id, | ||
content::WebContents* web_conents); | ||
|
||
protected: | ||
RemoteCallbackFreer(v8::Isolate* isolate, | ||
v8::Local<v8::Object> target, | ||
int object_id, | ||
content::WebContents* web_conents); | ||
~RemoteCallbackFreer() override; | ||
|
||
void RunDestructor() override; | ||
|
||
// content::WebContentsObserver: | ||
void RenderViewDeleted(content::RenderViewHost*) override; | ||
|
||
private: | ||
int object_id_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(RemoteCallbackFreer); | ||
}; | ||
|
||
} // namespace atom | ||
|
||
#endif // ATOM_COMMON_API_REMOTE_CALLBACK_FREER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters