OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/devtools/devtools_window.h" | 5 #include "chrome/browser/devtools/devtools_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 return; | 98 return; |
99 DictionaryPrefUpdate update(profile->GetPrefs(), prefs::kDevToolsPreferences); | 99 DictionaryPrefUpdate update(profile->GetPrefs(), prefs::kDevToolsPreferences); |
100 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 100 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
101 if (!it.value().IsType(base::Value::TYPE_STRING)) | 101 if (!it.value().IsType(base::Value::TYPE_STRING)) |
102 continue; | 102 continue; |
103 update.Get()->SetWithoutPathExpansion( | 103 update.Get()->SetWithoutPathExpansion( |
104 it.key(), it.value().CreateDeepCopy()); | 104 it.key(), it.value().CreateDeepCopy()); |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 std::string ConvertFlagsToQueryParams(const std::string flags) { | |
pfeldman
2016/10/11 20:51:34
Lets assume it is already of the target form.
dgozman
2016/10/11 21:09:14
Done.
| |
109 std::vector<std::string> query; | |
110 std::unique_ptr<base::Value> json = base::JSONReader::Read(flags); | |
111 if (!json) | |
112 return std::string(); | |
113 base::DictionaryValue* dict; | |
114 json->GetAsDictionary(&dict); | |
115 if (!dict) | |
116 return std::string(); | |
117 base::DictionaryValue result; | |
118 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); | |
119 it.Advance()) { | |
120 if (!it.value().IsType(base::Value::TYPE_STRING)) | |
121 return std::string(); | |
122 std::string value; | |
123 it.value().GetAsString(&value); | |
124 query.push_back( | |
125 base::StringPrintf("%s=%s", it.key().c_str(), value.c_str())); | |
126 } | |
127 if (query.empty()) | |
128 return std::string(); | |
129 return base::JoinString(query, "&"); | |
130 } | |
131 | |
108 // DevToolsToolboxDelegate ---------------------------------------------------- | 132 // DevToolsToolboxDelegate ---------------------------------------------------- |
109 | 133 |
110 class DevToolsToolboxDelegate | 134 class DevToolsToolboxDelegate |
111 : public content::WebContentsObserver, | 135 : public content::WebContentsObserver, |
112 public content::WebContentsDelegate { | 136 public content::WebContentsDelegate { |
113 public: | 137 public: |
114 DevToolsToolboxDelegate( | 138 DevToolsToolboxDelegate( |
115 WebContents* toolbox_contents, | 139 WebContents* toolbox_contents, |
116 DevToolsWindow::ObserverWithAccessor* web_contents_observer); | 140 DevToolsWindow::ObserverWithAccessor* web_contents_observer); |
117 ~DevToolsToolboxDelegate() override; | 141 ~DevToolsToolboxDelegate() override; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 frontend_url + | 223 frontend_url + |
200 ((frontend_url.find("?") == std::string::npos) ? "?" : "&") + | 224 ((frontend_url.find("?") == std::string::npos) ? "?" : "&") + |
201 "dockSide=undocked"); // TODO(dgozman): remove this support in M38. | 225 "dockSide=undocked"); // TODO(dgozman): remove this support in M38. |
202 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 226 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
203 if (command_line->HasSwitch(switches::kEnableDevToolsExperiments)) | 227 if (command_line->HasSwitch(switches::kEnableDevToolsExperiments)) |
204 url_string += "&experiments=true"; | 228 url_string += "&experiments=true"; |
205 | 229 |
206 if (command_line->HasSwitch(switches::kDevToolsFlags)) { | 230 if (command_line->HasSwitch(switches::kDevToolsFlags)) { |
207 std::string flags = command_line->GetSwitchValueASCII( | 231 std::string flags = command_line->GetSwitchValueASCII( |
208 switches::kDevToolsFlags); | 232 switches::kDevToolsFlags); |
209 flags = net::EscapeQueryParamValue(flags, false); | 233 flags = ConvertFlagsToQueryParams(flags); |
210 url_string += "&flags=" + flags; | 234 if (!flags.empty()) |
235 url_string += "&" + flags; | |
211 } | 236 } |
212 | 237 |
213 #if defined(DEBUG_DEVTOOLS) | 238 #if defined(DEBUG_DEVTOOLS) |
214 url_string += "&debugFrontend=true"; | 239 url_string += "&debugFrontend=true"; |
215 #endif // defined(DEBUG_DEVTOOLS) | 240 #endif // defined(DEBUG_DEVTOOLS) |
216 | 241 |
217 return GURL(url_string); | 242 return GURL(url_string); |
218 } | 243 } |
219 | 244 |
220 } // namespace | 245 } // namespace |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 url_string += "&isSharedWorker=true"; | 920 url_string += "&isSharedWorker=true"; |
896 if (v8_only_frontend) | 921 if (v8_only_frontend) |
897 url_string += "&v8only=true"; | 922 url_string += "&v8only=true"; |
898 if (remote_frontend.size()) { | 923 if (remote_frontend.size()) { |
899 url_string += "&remoteFrontend=true"; | 924 url_string += "&remoteFrontend=true"; |
900 } else { | 925 } else { |
901 url_string += "&remoteBase=" + DevToolsUI::GetRemoteBaseURL().spec(); | 926 url_string += "&remoteBase=" + DevToolsUI::GetRemoteBaseURL().spec(); |
902 } | 927 } |
903 if (can_dock) | 928 if (can_dock) |
904 url_string += "&can_dock=true"; | 929 url_string += "&can_dock=true"; |
905 return GURL(url_string); | 930 return DevToolsUI::SanitizeFrontendURL(GURL(url_string)); |
906 } | 931 } |
907 | 932 |
908 // static | 933 // static |
909 DevToolsWindow* DevToolsWindow::FindDevToolsWindow( | 934 DevToolsWindow* DevToolsWindow::FindDevToolsWindow( |
910 DevToolsAgentHost* agent_host) { | 935 DevToolsAgentHost* agent_host) { |
911 if (!agent_host || g_instances == NULL) | 936 if (!agent_host || g_instances == NULL) |
912 return NULL; | 937 return NULL; |
913 DevToolsWindows* instances = g_instances.Pointer(); | 938 DevToolsWindows* instances = g_instances.Pointer(); |
914 for (DevToolsWindows::iterator it(instances->begin()); it != instances->end(); | 939 for (DevToolsWindows::iterator it(instances->begin()); it != instances->end(); |
915 ++it) { | 940 ++it) { |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1371 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { | 1396 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { |
1372 // Only route reload via front-end if the agent is attached. | 1397 // Only route reload via front-end if the agent is attached. |
1373 WebContents* wc = GetInspectedWebContents(); | 1398 WebContents* wc = GetInspectedWebContents(); |
1374 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) | 1399 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) |
1375 return false; | 1400 return false; |
1376 base::FundamentalValue bypass_cache_value(bypass_cache); | 1401 base::FundamentalValue bypass_cache_value(bypass_cache); |
1377 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", | 1402 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", |
1378 &bypass_cache_value, nullptr, nullptr); | 1403 &bypass_cache_value, nullptr, nullptr); |
1379 return true; | 1404 return true; |
1380 } | 1405 } |
OLD | NEW |