Index: components/devtools_discovery/devtools_discovery_manager.cc |
diff --git a/components/devtools_discovery/devtools_discovery_manager.cc b/components/devtools_discovery/devtools_discovery_manager.cc |
index 3c472fa7bfbc1c9894db48d653a24086ca079d89..4d3a039cd3b9ca6b014296e68534213db38d1e7a 100644 |
--- a/components/devtools_discovery/devtools_discovery_manager.cc |
+++ b/components/devtools_discovery/devtools_discovery_manager.cc |
@@ -7,8 +7,12 @@ |
#include "base/stl_util.h" |
#include "components/devtools_discovery/basic_target_descriptor.h" |
#include "content/public/browser/devtools_agent_host.h" |
+#include "content/public/browser/render_widget_host_view.h" |
+#include "content/public/browser/web_contents.h" |
using content::DevToolsAgentHost; |
+using content::WebContents; |
+using content::RenderWidgetHostView; |
namespace devtools_discovery { |
@@ -63,9 +67,9 @@ DevToolsDiscoveryManager::GetDescriptorsFromProviders() { |
} |
std::unique_ptr<base::DictionaryValue> |
-DevToolsDiscoveryManager::HandleNewTargetCommand( |
+DevToolsDiscoveryManager::HandleCreateTargetCommand( |
base::DictionaryValue* command_dict) { |
- int id; |
+ int id, width, height; |
std::string method; |
std::string url; |
const base::DictionaryValue* params_dict = nullptr; |
@@ -78,6 +82,19 @@ DevToolsDiscoveryManager::HandleNewTargetCommand( |
CreateNew(GURL(url)); |
if (!descriptor) |
return nullptr; |
+ |
+ // Set size of WebContents by resizing RWHV if available |
+ if (command_dict->GetInteger("width", &width) && width >= 0 && |
+ command_dict->GetInteger("height", &height) && height >= 0) { |
+ scoped_refptr<DevToolsAgentHost> agent_host = descriptor->GetAgentHost(); |
+ WebContents* web_contents = |
+ agent_host ? agent_host->GetWebContents() : nullptr; |
+ RenderWidgetHostView* view = |
+ web_contents ? web_contents->GetRenderWidgetHostView() : nullptr; |
+ if (view) |
+ view->SetSize(gfx::Size(width, height)); |
+ } |
+ |
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
result->SetInteger("id", id); |
std::unique_ptr<base::DictionaryValue> cmd_result( |