Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(922)

Unified Diff: components/devtools_discovery/devtools_discovery_manager.cc

Issue 2226323002: Resize DevTools target frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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(

Powered by Google App Engine
This is Rietveld 408576698