diff --git a/brightray/browser/inspectable_web_contents_delegate.h b/brightray/browser/inspectable_web_contents_delegate.h index e9f071cb4d0a..7f004dd4fbd8 100644 --- a/brightray/browser/inspectable_web_contents_delegate.h +++ b/brightray/browser/inspectable_web_contents_delegate.h @@ -10,6 +10,7 @@ class InspectableWebContentsDelegate { virtual ~InspectableWebContentsDelegate() {} // Requested by WebContents of devtools. + virtual void DevToolsReloadPage() {} virtual void DevToolsSaveToFile( const std::string& url, const std::string& content, bool save_as) {} virtual void DevToolsAppendToFile( diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 9484593de47f..645440589517 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -18,6 +18,7 @@ #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" #include "base/prefs/scoped_user_pref_update.h" +#include "base/strings/pattern.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" @@ -480,6 +481,16 @@ void InspectableWebContentsImpl::SetDevicesUpdatesEnabled(bool enabled) { void InspectableWebContentsImpl::DispatchProtocolMessageFromDevToolsFrontend( const std::string& message) { + // If the devtools wants to reload the page, hijack the message and handle it + // to the delegate. + if (base::MatchPattern(message, "{\"id\":*," + "\"method\":\"Page.reload\"," + "\"params\":*}")) { + if (delegate_) + delegate_->DevToolsReloadPage(); + return; + } + if (agent_host_.get()) agent_host_->DispatchProtocolMessage(message); }