Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/devtools_discovery/devtools_discovery_manager.h" | 5 #include "components/devtools_discovery/devtools_discovery_manager.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "components/devtools_discovery/basic_target_descriptor.h" | 8 #include "components/devtools_discovery/basic_target_descriptor.h" |
| 9 #include "content/public/browser/devtools_agent_host.h" | 9 #include "content/public/browser/devtools_agent_host.h" |
| 10 #include "content/public/browser/render_widget_host_view.h" | |
| 11 #include "content/public/browser/web_contents.h" | |
| 10 | 12 |
| 11 using content::DevToolsAgentHost; | 13 using content::DevToolsAgentHost; |
| 14 using content::WebContents; | |
| 15 using content::RenderWidgetHostView; | |
| 12 | 16 |
| 13 namespace devtools_discovery { | 17 namespace devtools_discovery { |
| 14 | 18 |
| 15 // static | 19 // static |
| 16 DevToolsDiscoveryManager* DevToolsDiscoveryManager::GetInstance() { | 20 DevToolsDiscoveryManager* DevToolsDiscoveryManager::GetInstance() { |
| 17 return base::Singleton<DevToolsDiscoveryManager>::get(); | 21 return base::Singleton<DevToolsDiscoveryManager>::get(); |
| 18 } | 22 } |
| 19 | 23 |
| 20 DevToolsDiscoveryManager::DevToolsDiscoveryManager() { | 24 DevToolsDiscoveryManager::DevToolsDiscoveryManager() { |
| 21 } | 25 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 DevToolsDiscoveryManager::GetDescriptorsFromProviders() { | 60 DevToolsDiscoveryManager::GetDescriptorsFromProviders() { |
| 57 DevToolsTargetDescriptor::List result; | 61 DevToolsTargetDescriptor::List result; |
| 58 for (auto* provider : providers_) { | 62 for (auto* provider : providers_) { |
| 59 DevToolsTargetDescriptor::List partial = provider->GetDescriptors(); | 63 DevToolsTargetDescriptor::List partial = provider->GetDescriptors(); |
| 60 result.insert(result.begin(), partial.begin(), partial.end()); | 64 result.insert(result.begin(), partial.begin(), partial.end()); |
| 61 } | 65 } |
| 62 return result; | 66 return result; |
| 63 } | 67 } |
| 64 | 68 |
| 65 std::unique_ptr<base::DictionaryValue> | 69 std::unique_ptr<base::DictionaryValue> |
| 66 DevToolsDiscoveryManager::HandleNewTargetCommand( | 70 DevToolsDiscoveryManager::HandleCreateTargetCommand( |
|
alex clarke (OOO till 29th)
2016/08/10 12:39:48
Maybe mention in the patch comment that we don't n
Eric Seckler
2016/08/10 12:57:06
Done.
| |
| 67 base::DictionaryValue* command_dict) { | 71 base::DictionaryValue* command_dict) { |
| 68 int id; | 72 int id, width, height; |
| 69 std::string method; | 73 std::string method; |
| 70 std::string url; | 74 std::string url; |
| 71 const base::DictionaryValue* params_dict = nullptr; | 75 const base::DictionaryValue* params_dict = nullptr; |
| 72 if (command_dict->GetInteger("id", &id) && | 76 if (command_dict->GetInteger("id", &id) && |
| 73 command_dict->GetString("method", &method) && | 77 command_dict->GetString("method", &method) && |
| 74 method == "Browser.createTarget" && | 78 method == "Browser.createTarget" && |
| 75 command_dict->GetDictionary("params", ¶ms_dict) && | 79 command_dict->GetDictionary("params", ¶ms_dict) && |
| 76 params_dict->GetString("url", &url)) { | 80 params_dict->GetString("url", &url)) { |
| 77 std::unique_ptr<devtools_discovery::DevToolsTargetDescriptor> descriptor = | 81 std::unique_ptr<devtools_discovery::DevToolsTargetDescriptor> descriptor = |
| 78 CreateNew(GURL(url)); | 82 CreateNew(GURL(url)); |
| 79 if (!descriptor) | 83 if (!descriptor) |
| 80 return nullptr; | 84 return nullptr; |
| 85 | |
| 86 // Set size of frame by resizing RWHV if available. | |
| 87 if (params_dict->GetInteger("width", &width) && width >= 0 && | |
| 88 params_dict->GetInteger("height", &height) && height >= 0) { | |
| 89 scoped_refptr<DevToolsAgentHost> agent_host = descriptor->GetAgentHost(); | |
| 90 WebContents* web_contents = | |
| 91 agent_host ? agent_host->GetWebContents() : nullptr; | |
| 92 RenderWidgetHostView* view = | |
| 93 web_contents ? web_contents->GetRenderWidgetHostView() : nullptr; | |
| 94 if (view) | |
| 95 view->SetSize(gfx::Size(width, height)); | |
| 96 } | |
| 97 | |
| 81 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 98 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 82 result->SetInteger("id", id); | 99 result->SetInteger("id", id); |
| 83 std::unique_ptr<base::DictionaryValue> cmd_result( | 100 std::unique_ptr<base::DictionaryValue> cmd_result( |
| 84 new base::DictionaryValue()); | 101 new base::DictionaryValue()); |
| 85 cmd_result->SetString("pageId", descriptor->GetId()); | 102 cmd_result->SetString("targetId", descriptor->GetId()); |
| 86 result->Set("result", std::move(cmd_result)); | 103 result->Set("result", std::move(cmd_result)); |
| 87 return result; | 104 return result; |
| 88 } | 105 } |
| 89 return nullptr; | 106 return nullptr; |
| 90 } | 107 } |
| 91 | 108 |
| 92 } // namespace devtools_discovery | 109 } // namespace devtools_discovery |
| OLD | NEW |