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) {
|
void WebContents::TitleWasSet(content::NavigationEntry* entry) {
|
||||||
auto title = entry ? entry->GetTitle() : base::string16();
|
auto title = entry ? entry->GetTitle() : base::string16();
|
||||||
bool explicit_set;
|
bool explicit_set;
|
||||||
|
base::string16 final_title;
|
||||||
if (entry && entry->GetURL().SchemeIsFile() && title.empty()) {
|
if (entry && entry->GetURL().SchemeIsFile() && title.empty()) {
|
||||||
final_title = base::UTF8ToUTF16(entry->GetURL().ExtractFileName());
|
final_title = base::UTF8ToUTF16(entry->GetURL().ExtractFileName());
|
||||||
explicit_set = false;
|
explicit_set = false;
|
||||||
|
@ -903,7 +904,7 @@ void WebContents::TitleWasSet(content::NavigationEntry* entry) {
|
||||||
base::TrimWhitespace(title, base::TRIM_ALL, &final_title);
|
base::TrimWhitespace(title, base::TRIM_ALL, &final_title);
|
||||||
explicit_set = true;
|
explicit_set = true;
|
||||||
}
|
}
|
||||||
Emit("page-title-updated", title, explicit_set);
|
Emit("page-title-updated", final_title, explicit_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::DidUpdateFaviconURL(
|
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 WebContents::OnMessageReceived(const IPC::Message& message) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
|
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
|
||||||
|
@ -1275,14 +1285,20 @@ void WebContents::EnableDeviceEmulation(
|
||||||
if (type_ == REMOTE)
|
if (type_ == REMOTE)
|
||||||
return;
|
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() {
|
void WebContents::DisableDeviceEmulation() {
|
||||||
if (type_ == REMOTE)
|
if (type_ == REMOTE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Send(new ViewMsg_DisableDeviceEmulation(routing_id()));
|
auto host = web_contents()->GetRenderViewHost();
|
||||||
|
|
||||||
|
if (host)
|
||||||
|
host->Send(new ViewMsg_DisableDeviceEmulation(host->GetRoutingID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::ToggleDevTools() {
|
void WebContents::ToggleDevTools() {
|
||||||
|
@ -1524,10 +1540,10 @@ void WebContents::TabTraverse(bool reverse) {
|
||||||
bool WebContents::SendIPCMessage(bool all_frames,
|
bool WebContents::SendIPCMessage(bool all_frames,
|
||||||
const base::string16& channel,
|
const base::string16& channel,
|
||||||
const base::ListValue& args) {
|
const base::ListValue& args) {
|
||||||
auto frame_host = web_contents()->GetMainFrame();
|
auto host = web_contents()->GetRenderViewHost();
|
||||||
if (frame_host) {
|
if (host) {
|
||||||
return frame_host->Send(new AtomFrameMsg_Message(
|
return host->Send(new AtomViewMsg_Message(host->GetRoutingID(),
|
||||||
frame_host->GetRoutingID(), all_frames, channel, args));
|
all_frames, channel, args));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1818,15 +1834,18 @@ void WebContents::OnSetTemporaryZoomLevel(content::RenderFrameHost* rfh,
|
||||||
IPC::Message* reply_msg) {
|
IPC::Message* reply_msg) {
|
||||||
zoom_controller_->SetTemporaryZoomLevel(level);
|
zoom_controller_->SetTemporaryZoomLevel(level);
|
||||||
double new_level = zoom_controller_->GetZoomLevel();
|
double new_level = zoom_controller_->GetZoomLevel();
|
||||||
AtomFrameHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg,
|
AtomViewHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg, new_level);
|
||||||
new_level);
|
|
||||||
rfh->Send(reply_msg);
|
auto host = web_contents()->GetRenderViewHost();
|
||||||
|
if (host)
|
||||||
|
host->Send(reply_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnGetZoomLevel(content::RenderFrameHost* rfh,
|
void WebContents::OnGetZoomLevel(IPC::Message* reply_msg) {
|
||||||
IPC::Message* reply_msg) {
|
AtomViewHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
|
||||||
AtomFrameHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
|
auto host = web_contents()->GetRenderViewHost();
|
||||||
rfh->Send(reply_msg);
|
if (host)
|
||||||
|
host->Send(reply_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
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 AddWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
||||||
void RemoveWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
void RemoveWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
||||||
|
|
||||||
|
// IPC
|
||||||
|
bool Send(IPC::Message* message);
|
||||||
|
|
||||||
// Editing commands.
|
// Editing commands.
|
||||||
void Undo();
|
void Undo();
|
||||||
void Redo();
|
void Redo();
|
||||||
|
|
Loading…
Reference in a new issue