REVIEW: move ipc use from rvh to rfh
This commit is contained in:
parent
b552ad7065
commit
5684f8886f
7 changed files with 62 additions and 39 deletions
|
@ -970,15 +970,6 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
|||
}
|
||||
}
|
||||
|
||||
// Should only be used for IPC message maps
|
||||
bool WebContents::Send(IPC::Message* message) {
|
||||
auto host = web_contents()->GetRenderViewHost();
|
||||
|
||||
if (host)
|
||||
return host->Send(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
|
||||
|
@ -1542,10 +1533,10 @@ void WebContents::TabTraverse(bool reverse) {
|
|||
bool WebContents::SendIPCMessage(bool all_frames,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args) {
|
||||
auto host = web_contents()->GetRenderViewHost();
|
||||
if (host) {
|
||||
return host->Send(new AtomViewMsg_Message(host->GetRoutingID(),
|
||||
all_frames, channel, args));
|
||||
auto frame_host = web_contents()->GetMainFrame();
|
||||
if (frame_host) {
|
||||
return frame_host->Send(new AtomFrameMsg_Message(
|
||||
frame_host->GetRoutingID(), all_frames, channel, args));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1836,18 +1827,15 @@ void WebContents::OnSetTemporaryZoomLevel(content::RenderFrameHost* rfh,
|
|||
IPC::Message* reply_msg) {
|
||||
zoom_controller_->SetTemporaryZoomLevel(level);
|
||||
double new_level = zoom_controller_->GetZoomLevel();
|
||||
AtomViewHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg, new_level);
|
||||
|
||||
auto host = web_contents()->GetRenderViewHost();
|
||||
if (host)
|
||||
host->Send(reply_msg);
|
||||
AtomFrameHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg,
|
||||
new_level);
|
||||
rfh->Send(reply_msg);
|
||||
}
|
||||
|
||||
void WebContents::OnGetZoomLevel(IPC::Message* reply_msg) {
|
||||
AtomViewHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
|
||||
auto host = web_contents()->GetRenderViewHost();
|
||||
if (host)
|
||||
host->Send(reply_msg);
|
||||
void WebContents::OnGetZoomLevel(content::RenderFrameHost* rfh,
|
||||
IPC::Message* reply_msg) {
|
||||
AtomFrameHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
|
||||
rfh->Send(reply_msg);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
||||
|
|
|
@ -149,9 +149,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void AddWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
||||
void RemoveWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
||||
|
||||
// IPC
|
||||
bool Send(IPC::Message* message);
|
||||
|
||||
// Editing commands.
|
||||
void Undo();
|
||||
void Redo();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
|
||||
|
@ -60,10 +60,8 @@ bool Event::SendReply(const base::string16& json) {
|
|||
if (message_ == nullptr || sender_ == nullptr)
|
||||
return false;
|
||||
|
||||
AtomViewHostMsg_Message_Sync::WriteReplyParams(message_, json);
|
||||
auto host = sender_->GetRenderViewHost();
|
||||
if (!host) return false;
|
||||
bool success = host->Send(message_);
|
||||
AtomFrameHostMsg_Message_Sync::WriteReplyParams(message_, json);
|
||||
bool success = sender_->Send(message_);
|
||||
message_ = nullptr;
|
||||
sender_ = nullptr;
|
||||
return success;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue