IPC fixes for WebContents
This commit is contained in:
parent
1c648f9714
commit
7c8be94a6e
2 changed files with 36 additions and 14 deletions
|
@ -896,6 +896,7 @@ void WebContents::DidFinishNavigation(
|
|||
void WebContents::TitleWasSet(content::NavigationEntry* entry) {
|
||||
auto title = entry ? entry->GetTitle() : base::string16();
|
||||
bool explicit_set;
|
||||
base::string16 final_title;
|
||||
if (entry && entry->GetURL().SchemeIsFile() && title.empty()) {
|
||||
final_title = base::UTF8ToUTF16(entry->GetURL().ExtractFileName());
|
||||
explicit_set = false;
|
||||
|
@ -903,7 +904,7 @@ void WebContents::TitleWasSet(content::NavigationEntry* entry) {
|
|||
base::TrimWhitespace(title, base::TRIM_ALL, &final_title);
|
||||
explicit_set = true;
|
||||
}
|
||||
Emit("page-title-updated", title, explicit_set);
|
||||
Emit("page-title-updated", final_title, explicit_set);
|
||||
}
|
||||
|
||||
void WebContents::DidUpdateFaviconURL(
|
||||
|
@ -967,6 +968,15 @@ 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)
|
||||
|
@ -1275,14 +1285,20 @@ void WebContents::EnableDeviceEmulation(
|
|||
if (type_ == REMOTE)
|
||||
return;
|
||||
|
||||
Send(new ViewMsg_EnableDeviceEmulation(routing_id(), params));
|
||||
auto host = web_contents()->GetRenderViewHost();
|
||||
|
||||
if (host)
|
||||
host->Send(new ViewMsg_EnableDeviceEmulation(host->GetRoutingID(), params));
|
||||
}
|
||||
|
||||
void WebContents::DisableDeviceEmulation() {
|
||||
if (type_ == REMOTE)
|
||||
return;
|
||||
|
||||
Send(new ViewMsg_DisableDeviceEmulation(routing_id()));
|
||||
auto host = web_contents()->GetRenderViewHost();
|
||||
|
||||
if (host)
|
||||
host->Send(new ViewMsg_DisableDeviceEmulation(host->GetRoutingID()));
|
||||
}
|
||||
|
||||
void WebContents::ToggleDevTools() {
|
||||
|
@ -1524,10 +1540,10 @@ void WebContents::TabTraverse(bool reverse) {
|
|||
bool WebContents::SendIPCMessage(bool all_frames,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args) {
|
||||
auto frame_host = web_contents()->GetMainFrame();
|
||||
if (frame_host) {
|
||||
return frame_host->Send(new AtomFrameMsg_Message(
|
||||
frame_host->GetRoutingID(), all_frames, channel, args));
|
||||
auto host = web_contents()->GetRenderViewHost();
|
||||
if (host) {
|
||||
return host->Send(new AtomViewMsg_Message(host->GetRoutingID(),
|
||||
all_frames, channel, args));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1818,15 +1834,18 @@ void WebContents::OnSetTemporaryZoomLevel(content::RenderFrameHost* rfh,
|
|||
IPC::Message* reply_msg) {
|
||||
zoom_controller_->SetTemporaryZoomLevel(level);
|
||||
double new_level = zoom_controller_->GetZoomLevel();
|
||||
AtomFrameHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg,
|
||||
new_level);
|
||||
rfh->Send(reply_msg);
|
||||
AtomViewHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg, new_level);
|
||||
|
||||
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);
|
||||
void WebContents::OnGetZoomLevel(IPC::Message* reply_msg) {
|
||||
AtomViewHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
|
||||
auto host = web_contents()->GetRenderViewHost();
|
||||
if (host)
|
||||
host->Send(reply_msg);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
||||
|
|
|
@ -149,6 +149,9 @@ 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();
|
||||
|
|
Loading…
Reference in a new issue