| Index: chrome/browser/devtools/chrome_devtools_manager_delegate.cc
|
| diff --git a/chrome/browser/devtools/chrome_devtools_manager_delegate.cc b/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
|
| index 101d544a6be728d7695c7639e35c8e0173ba8192..c29b6e2f1606d4a178ddacc0101d479c72588207 100644
|
| --- a/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
|
| +++ b/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
|
| @@ -17,9 +17,11 @@
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/ui/browser_navigator.h"
|
| #include "chrome/browser/ui/browser_navigator_params.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
|
| #include "chrome/grit/browser_resources.h"
|
| #include "components/guest_view/browser/guest_view_base.h"
|
| +#include "components/ui_devtools/string_util.h"
|
| #include "content/public/browser/devtools_agent_host.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -38,6 +40,82 @@ char kLocationsParam[] = "locations";
|
| char kHostParam[] = "host";
|
| char kPortParam[] = "port";
|
|
|
| +std::unique_ptr<base::DictionaryValue> HandlePageCommand(
|
| + content::DevToolsAgentHost* agent_host,
|
| + int id,
|
| + std::string method,
|
| + base::DictionaryValue* params) {
|
| + if (method == chrome::devtools::Page::maximizeWindow::kName) {
|
| + BrowserWindow::GetBrowserWindowForNativeWindow(
|
| + agent_host->GetWebContents()->GetTopLevelNativeWindow())
|
| + ->Maximize();
|
| + std::unique_ptr<base::DictionaryValue> result(
|
| + base::MakeUnique<base::DictionaryValue>());
|
| + return DevToolsProtocol::CreateSuccessResponse(id, std::move(result));
|
| + }
|
| + if (method == chrome::devtools::Page::minimizeWindow::kName) {
|
| + BrowserWindow::GetBrowserWindowForNativeWindow(
|
| + agent_host->GetWebContents()->GetTopLevelNativeWindow())
|
| + ->Minimize();
|
| + std::unique_ptr<base::DictionaryValue> result(
|
| + base::MakeUnique<base::DictionaryValue>());
|
| + return DevToolsProtocol::CreateSuccessResponse(id, std::move(result));
|
| + }
|
| + if (method == chrome::devtools::Page::getWindowBounds::kName) {
|
| + BrowserWindow* window = BrowserWindow::GetBrowserWindowForNativeWindow(
|
| + agent_host->GetWebContents()->GetTopLevelNativeWindow());
|
| + gfx::Rect bounds;
|
| + if (window->IsMinimized())
|
| + bounds = window->GetRestoredBounds();
|
| + else
|
| + bounds = window->GetBounds();
|
| + std::unique_ptr<base::DictionaryValue> result(
|
| + base::MakeUnique<base::DictionaryValue>());
|
| + result->SetInteger("left", bounds.x());
|
| + result->SetInteger("top", bounds.y());
|
| + result->SetInteger("width", bounds.width());
|
| + result->SetInteger("height", bounds.height());
|
| + return DevToolsProtocol::CreateSuccessResponse(id, std::move(result));
|
| + }
|
| + if (method == chrome::devtools::Page::setWindowBounds::kName) {
|
| + BrowserWindow* window = BrowserWindow::GetBrowserWindowForNativeWindow(
|
| + agent_host->GetWebContents()->GetTopLevelNativeWindow());
|
| + gfx::Rect bounds;
|
| + if (window->IsMinimized())
|
| + bounds = window->GetRestoredBounds();
|
| + else
|
| + bounds = window->GetBounds();
|
| +
|
| + namespace names = chrome::devtools::Page::setWindowBounds;
|
| + int left, top, width, height;
|
| + bool set_bounds = false;
|
| + // Any part of the bounds can optionally be set by the caller.
|
| + if (params && params->GetInteger(names::kParamLeft, &left)) {
|
| + bounds.set_x(left);
|
| + set_bounds = true;
|
| + }
|
| + if (params && params->GetInteger(names::kParamTop, &top)) {
|
| + bounds.set_y(top);
|
| + set_bounds = true;
|
| + }
|
| + if (params && params->GetInteger(names::kParamWidth, &width)) {
|
| + bounds.set_width(width);
|
| + set_bounds = true;
|
| + }
|
| + if (params && params->GetInteger(names::kParamHeight, &height)) {
|
| + bounds.set_height(height);
|
| + set_bounds = true;
|
| + }
|
| +
|
| + if (set_bounds)
|
| + window->SetBounds(bounds);
|
| + std::unique_ptr<base::DictionaryValue> result(
|
| + base::MakeUnique<base::DictionaryValue>());
|
| + return DevToolsProtocol::CreateSuccessResponse(id, std::move(result));
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| class ChromeDevToolsManagerDelegate::HostData {
|
| public:
|
| HostData() {}
|
| @@ -77,6 +155,14 @@ base::DictionaryValue* ChromeDevToolsManagerDelegate::HandleCommand(
|
| if (!DevToolsProtocol::ParseCommand(command_dict, &id, &method, ¶ms))
|
| return nullptr;
|
|
|
| + using stringUtil = ::ui::devtools::protocol::StringUtil;
|
| + size_t dotIndex = stringUtil::find(method, ".");
|
| + if (dotIndex == stringUtil::kNotFound)
|
| + return nullptr;
|
| + std::string domain = stringUtil::substring(method, 0, dotIndex);
|
| + if (domain == chrome::devtools::Page::kName)
|
| + return HandlePageCommand(agent_host, id, method, params).release();
|
| +
|
| if (method == chrome::devtools::Target::setRemoteLocations::kName)
|
| return SetRemoteLocations(agent_host, id, params).release();
|
|
|
|
|