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 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 DevToolsTargetDescriptor::List | 55 DevToolsTargetDescriptor::List |
56 DevToolsDiscoveryManager::GetDescriptorsFromProviders() { | 56 DevToolsDiscoveryManager::GetDescriptorsFromProviders() { |
57 DevToolsTargetDescriptor::List result; | 57 DevToolsTargetDescriptor::List result; |
58 for (const auto& provider : providers_) { | 58 for (const auto& provider : providers_) { |
59 DevToolsTargetDescriptor::List partial = provider->GetDescriptors(); | 59 DevToolsTargetDescriptor::List partial = provider->GetDescriptors(); |
60 result.insert(result.begin(), partial.begin(), partial.end()); | 60 result.insert(result.begin(), partial.begin(), partial.end()); |
61 } | 61 } |
62 return result; | 62 return result; |
63 } | 63 } |
64 | 64 |
| 65 std::unique_ptr<base::DictionaryValue> |
| 66 DevToolsDiscoveryManager::MaybeHandleNewPageCommand( |
| 67 base::DictionaryValue* command_dict) { |
| 68 int id; |
| 69 std::string method; |
| 70 std::string initial_url; |
| 71 const base::DictionaryValue* params_dict = nullptr; |
| 72 if (command_dict->GetInteger("id", &id) && |
| 73 command_dict->GetString("method", &method) && |
| 74 method == "Browser.newPage" && |
| 75 command_dict->GetDictionary("params", ¶ms_dict) && |
| 76 params_dict->GetString("initialUrl", &initial_url)) { |
| 77 std::unique_ptr<devtools_discovery::DevToolsTargetDescriptor> descriptor = |
| 78 CreateNew(GURL(initial_url)); |
| 79 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 80 result->SetInteger("id", id); |
| 81 std::unique_ptr<base::DictionaryValue> cmd_result( |
| 82 new base::DictionaryValue()); |
| 83 cmd_result->SetString("pageId", descriptor->GetId()); |
| 84 result->Set("result", std::move(cmd_result)); |
| 85 return result; |
| 86 } |
| 87 return nullptr; |
| 88 } |
| 89 |
65 } // namespace devtools_discovery | 90 } // namespace devtools_discovery |
OLD | NEW |