OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ui_bindings.h" | 5 #include "chrome/browser/devtools/devtools_ui_bindings.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/base64.h" | 12 #include "base/base64.h" |
13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
15 #include "base/json/string_escape.h" | 15 #include "base/json/string_escape.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_split.h" | |
21 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
23 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
24 #include "base/values.h" | 23 #include "base/values.h" |
25 #include "build/build_config.h" | 24 #include "build/build_config.h" |
26 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/devtools/devtools_file_watcher.h" | 26 #include "chrome/browser/devtools/devtools_file_watcher.h" |
28 #include "chrome/browser/devtools/devtools_protocol.h" | 27 #include "chrome/browser/devtools/devtools_protocol.h" |
29 #include "chrome/browser/devtools/global_confirm_info_bar.h" | 28 #include "chrome/browser/devtools/global_confirm_info_bar.h" |
30 #include "chrome/browser/devtools/url_constants.h" | |
31 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 29 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
32 #include "chrome/browser/infobars/infobar_service.h" | 30 #include "chrome/browser/infobars/infobar_service.h" |
33 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
34 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
35 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
36 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
37 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
38 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" | 37 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" |
40 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
(...skipping 16 matching lines...) Expand all Loading... |
57 #include "content/public/browser/render_view_host.h" | 55 #include "content/public/browser/render_view_host.h" |
58 #include "content/public/browser/user_metrics.h" | 56 #include "content/public/browser/user_metrics.h" |
59 #include "content/public/browser/web_contents.h" | 57 #include "content/public/browser/web_contents.h" |
60 #include "content/public/browser/web_contents_observer.h" | 58 #include "content/public/browser/web_contents_observer.h" |
61 #include "content/public/common/renderer_preferences.h" | 59 #include "content/public/common/renderer_preferences.h" |
62 #include "content/public/common/url_constants.h" | 60 #include "content/public/common/url_constants.h" |
63 #include "extensions/browser/extension_registry.h" | 61 #include "extensions/browser/extension_registry.h" |
64 #include "extensions/common/constants.h" | 62 #include "extensions/common/constants.h" |
65 #include "extensions/common/permissions/permissions_data.h" | 63 #include "extensions/common/permissions/permissions_data.h" |
66 #include "ipc/ipc_channel.h" | 64 #include "ipc/ipc_channel.h" |
67 #include "net/base/escape.h" | |
68 #include "net/base/io_buffer.h" | 65 #include "net/base/io_buffer.h" |
69 #include "net/base/net_errors.h" | 66 #include "net/base/net_errors.h" |
70 #include "net/base/url_util.h" | |
71 #include "net/cert/x509_certificate.h" | 67 #include "net/cert/x509_certificate.h" |
72 #include "net/http/http_response_headers.h" | 68 #include "net/http/http_response_headers.h" |
73 #include "net/url_request/url_fetcher.h" | 69 #include "net/url_request/url_fetcher.h" |
74 #include "net/url_request/url_fetcher_response_writer.h" | 70 #include "net/url_request/url_fetcher_response_writer.h" |
75 #include "third_party/WebKit/public/public_features.h" | 71 #include "third_party/WebKit/public/public_features.h" |
76 #include "ui/base/l10n/l10n_util.h" | 72 #include "ui/base/l10n/l10n_util.h" |
77 #include "ui/base/page_transition_types.h" | 73 #include "ui/base/page_transition_types.h" |
78 | 74 |
79 using base::DictionaryValue; | 75 using base::DictionaryValue; |
80 using content::BrowserThread; | 76 using content::BrowserThread; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 "DevToolsAPI.streamWrite", base::Owned(id), | 292 "DevToolsAPI.streamWrite", base::Owned(id), |
297 base::Owned(chunkValue), base::Owned(encodedValue))); | 293 base::Owned(chunkValue), base::Owned(encodedValue))); |
298 return num_bytes; | 294 return num_bytes; |
299 } | 295 } |
300 | 296 |
301 int ResponseWriter::Finish(int net_error, | 297 int ResponseWriter::Finish(int net_error, |
302 const net::CompletionCallback& callback) { | 298 const net::CompletionCallback& callback) { |
303 return net::OK; | 299 return net::OK; |
304 } | 300 } |
305 | 301 |
306 GURL SanitizeFrontendURL( | |
307 const GURL& url, | |
308 const std::string& scheme, | |
309 const std::string& host, | |
310 const std::string& path, | |
311 bool allow_query); | |
312 | |
313 std::string SanitizeRevision(const std::string& revision) { | |
314 for (size_t i = 0; i < revision.length(); i++) { | |
315 if (!(revision[i] == '@' && i == 0) | |
316 && !(revision[i] >= '0' && revision[i] <= '9') | |
317 && !(revision[i] >= 'a' && revision[i] <= 'z') | |
318 && !(revision[i] >= 'A' && revision[i] <= 'Z')) { | |
319 return std::string(); | |
320 } | |
321 } | |
322 return revision; | |
323 } | |
324 | |
325 std::string SanitizeFrontendPath(const std::string& path) { | |
326 for (size_t i = 0; i < path.length(); i++) { | |
327 if (path[i] != '/' && path[i] != '-' && path[i] != '_' | |
328 && path[i] != '.' && path[i] != '@' | |
329 && !(path[i] >= '0' && path[i] <= '9') | |
330 && !(path[i] >= 'a' && path[i] <= 'z') | |
331 && !(path[i] >= 'A' && path[i] <= 'Z')) { | |
332 return std::string(); | |
333 } | |
334 } | |
335 return path; | |
336 } | |
337 | |
338 std::string SanitizeEndpoint(const std::string& value) { | |
339 if (value.find('&') != std::string::npos | |
340 || value.find('?') != std::string::npos) | |
341 return std::string(); | |
342 return value; | |
343 } | |
344 | |
345 std::string SanitizeRemoteBase(const std::string& value) { | |
346 GURL url(value); | |
347 std::string path = url.path(); | |
348 std::vector<std::string> parts = base::SplitString( | |
349 path, "/", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); | |
350 std::string revision = parts.size() > 2 ? parts[2] : ""; | |
351 revision = SanitizeRevision(revision); | |
352 path = base::StringPrintf("/%s/%s/", kRemoteFrontendPath, revision.c_str()); | |
353 return SanitizeFrontendURL(url, url::kHttpsScheme, | |
354 kRemoteFrontendDomain, path, false).spec(); | |
355 } | |
356 | |
357 std::string SanitizeRemoteFrontendURL(const std::string& value) { | |
358 GURL url(net::UnescapeURLComponent(value, | |
359 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | | |
360 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | | |
361 net::UnescapeRule::REPLACE_PLUS_WITH_SPACE)); | |
362 std::string path = url.path(); | |
363 std::vector<std::string> parts = base::SplitString( | |
364 path, "/", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); | |
365 std::string revision = parts.size() > 2 ? parts[2] : ""; | |
366 revision = SanitizeRevision(revision); | |
367 std::string filename = parts.size() ? parts[parts.size() - 1] : ""; | |
368 if (filename != "devtools.html") | |
369 filename = "inspector.html"; | |
370 path = base::StringPrintf("/serve_rev/%s/%s", | |
371 revision.c_str(), filename.c_str()); | |
372 std::string sanitized = SanitizeFrontendURL(url, url::kHttpsScheme, | |
373 kRemoteFrontendDomain, path, true).spec(); | |
374 return net::EscapeQueryParamValue(sanitized, false); | |
375 } | |
376 | |
377 std::string SanitizeFrontendQueryParam( | |
378 const std::string& key, | |
379 const std::string& value) { | |
380 // Convert boolean flags to true. | |
381 if (key == "can_dock" || key == "debugFrontend" || key == "experiments" || | |
382 key == "isSharedWorker" || key == "v8only" || key == "remoteFrontend") | |
383 return "true"; | |
384 | |
385 // Pass connection endpoints as is. | |
386 if (key == "ws" || key == "service-backend") | |
387 return SanitizeEndpoint(value); | |
388 | |
389 // Only support undocked for old frontends. | |
390 if (key == "dockSide" && value == "undocked") | |
391 return value; | |
392 | |
393 if (key == "panel" && (value == "elements" || value == "console")) | |
394 return value; | |
395 | |
396 if (key == "remoteBase") | |
397 return SanitizeRemoteBase(value); | |
398 | |
399 if (key == "remoteFrontendUrl") | |
400 return SanitizeRemoteFrontendURL(value); | |
401 | |
402 return std::string(); | |
403 } | |
404 | |
405 GURL SanitizeFrontendURL( | |
406 const GURL& url, | |
407 const std::string& scheme, | |
408 const std::string& host, | |
409 const std::string& path, | |
410 bool allow_query) { | |
411 std::vector<std::string> query_parts; | |
412 if (allow_query) { | |
413 for (net::QueryIterator it(url); !it.IsAtEnd(); it.Advance()) { | |
414 std::string value = SanitizeFrontendQueryParam(it.GetKey(), | |
415 it.GetValue()); | |
416 if (!value.empty()) { | |
417 query_parts.push_back( | |
418 base::StringPrintf("%s=%s", it.GetKey().c_str(), value.c_str())); | |
419 } | |
420 } | |
421 } | |
422 std::string query = | |
423 query_parts.empty() ? "" : "?" + base::JoinString(query_parts, "&"); | |
424 std::string constructed = base::StringPrintf("%s://%s%s%s", | |
425 scheme.c_str(), host.c_str(), path.c_str(), query.c_str()); | |
426 GURL result = GURL(constructed); | |
427 if (!result.is_valid()) | |
428 return GURL(); | |
429 return result; | |
430 } | |
431 | |
432 } // namespace | 302 } // namespace |
433 | 303 |
434 // DevToolsUIBindings::FrontendWebContentsObserver ---------------------------- | 304 // DevToolsUIBindings::FrontendWebContentsObserver ---------------------------- |
435 | 305 |
436 class DevToolsUIBindings::FrontendWebContentsObserver | 306 class DevToolsUIBindings::FrontendWebContentsObserver |
437 : public content::WebContentsObserver { | 307 : public content::WebContentsObserver { |
438 public: | 308 public: |
439 explicit FrontendWebContentsObserver(DevToolsUIBindings* ui_bindings); | 309 explicit FrontendWebContentsObserver(DevToolsUIBindings* ui_bindings); |
440 ~FrontendWebContentsObserver() override; | 310 ~FrontendWebContentsObserver() override; |
441 | 311 |
(...skipping 16 matching lines...) Expand all Loading... |
458 DevToolsUIBindings::FrontendWebContentsObserver::FrontendWebContentsObserver( | 328 DevToolsUIBindings::FrontendWebContentsObserver::FrontendWebContentsObserver( |
459 DevToolsUIBindings* devtools_ui_bindings) | 329 DevToolsUIBindings* devtools_ui_bindings) |
460 : WebContentsObserver(devtools_ui_bindings->web_contents()), | 330 : WebContentsObserver(devtools_ui_bindings->web_contents()), |
461 devtools_bindings_(devtools_ui_bindings) { | 331 devtools_bindings_(devtools_ui_bindings) { |
462 } | 332 } |
463 | 333 |
464 DevToolsUIBindings::FrontendWebContentsObserver:: | 334 DevToolsUIBindings::FrontendWebContentsObserver:: |
465 ~FrontendWebContentsObserver() { | 335 ~FrontendWebContentsObserver() { |
466 } | 336 } |
467 | 337 |
468 // static | |
469 GURL DevToolsUIBindings::SanitizeFrontendURL(const GURL& url) { | |
470 return ::SanitizeFrontendURL(url, content::kChromeDevToolsScheme, | |
471 chrome::kChromeUIDevToolsHost, SanitizeFrontendPath(url.path()), true); | |
472 } | |
473 | |
474 void DevToolsUIBindings::FrontendWebContentsObserver::RenderProcessGone( | 338 void DevToolsUIBindings::FrontendWebContentsObserver::RenderProcessGone( |
475 base::TerminationStatus status) { | 339 base::TerminationStatus status) { |
476 bool crashed = true; | 340 bool crashed = true; |
477 switch (status) { | 341 switch (status) { |
478 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 342 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
479 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | 343 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
480 #if defined(OS_CHROMEOS) | 344 #if defined(OS_CHROMEOS) |
481 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: | 345 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: |
482 #endif | 346 #endif |
483 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 347 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
484 case base::TERMINATION_STATUS_LAUNCH_FAILED: | 348 case base::TERMINATION_STATUS_LAUNCH_FAILED: |
485 if (devtools_bindings_->agent_host_.get()) | 349 if (devtools_bindings_->agent_host_.get()) |
486 devtools_bindings_->Detach(); | 350 devtools_bindings_->Detach(); |
487 break; | 351 break; |
488 default: | 352 default: |
489 crashed = false; | 353 crashed = false; |
490 break; | 354 break; |
491 } | 355 } |
492 devtools_bindings_->delegate_->RenderProcessGone(crashed); | 356 devtools_bindings_->delegate_->RenderProcessGone(crashed); |
493 } | 357 } |
494 | 358 |
495 void DevToolsUIBindings::FrontendWebContentsObserver:: | 359 void DevToolsUIBindings::FrontendWebContentsObserver:: |
496 DidStartNavigationToPendingEntry(const GURL& url, | 360 DidStartNavigationToPendingEntry(const GURL& url, |
497 content::ReloadType reload_type) { | 361 content::ReloadType reload_type) { |
498 devtools_bindings_->UpdateFrontendHost(); | 362 devtools_bindings_->frontend_host_.reset( |
| 363 content::DevToolsFrontendHost::Create( |
| 364 web_contents()->GetMainFrame(), |
| 365 base::Bind(&DevToolsUIBindings::HandleMessageFromDevToolsFrontend, |
| 366 base::Unretained(devtools_bindings_)))); |
499 } | 367 } |
500 | 368 |
501 void DevToolsUIBindings::FrontendWebContentsObserver:: | 369 void DevToolsUIBindings::FrontendWebContentsObserver:: |
502 DocumentAvailableInMainFrame() { | 370 DocumentAvailableInMainFrame() { |
503 devtools_bindings_->DocumentAvailableInMainFrame(); | 371 devtools_bindings_->DocumentAvailableInMainFrame(); |
504 } | 372 } |
505 | 373 |
506 void DevToolsUIBindings::FrontendWebContentsObserver:: | 374 void DevToolsUIBindings::FrontendWebContentsObserver:: |
507 DocumentOnLoadCompletedInMainFrame() { | 375 DocumentOnLoadCompletedInMainFrame() { |
508 devtools_bindings_->DocumentOnLoadCompletedInMainFrame(); | 376 devtools_bindings_->DocumentOnLoadCompletedInMainFrame(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 web_contents_->GetMutableRendererPrefs()->can_accept_load_drops = false; | 411 web_contents_->GetMutableRendererPrefs()->can_accept_load_drops = false; |
544 | 412 |
545 file_helper_.reset(new DevToolsFileHelper(web_contents_, profile_, this)); | 413 file_helper_.reset(new DevToolsFileHelper(web_contents_, profile_, this)); |
546 file_system_indexer_ = new DevToolsFileSystemIndexer(); | 414 file_system_indexer_ = new DevToolsFileSystemIndexer(); |
547 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 415 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
548 web_contents_); | 416 web_contents_); |
549 | 417 |
550 // Register on-load actions. | 418 // Register on-load actions. |
551 embedder_message_dispatcher_.reset( | 419 embedder_message_dispatcher_.reset( |
552 DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this)); | 420 DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this)); |
553 UpdateFrontendHost(); | 421 |
| 422 frontend_host_.reset(content::DevToolsFrontendHost::Create( |
| 423 web_contents_->GetMainFrame(), |
| 424 base::Bind(&DevToolsUIBindings::HandleMessageFromDevToolsFrontend, |
| 425 base::Unretained(this)))); |
554 } | 426 } |
555 | 427 |
556 DevToolsUIBindings::~DevToolsUIBindings() { | 428 DevToolsUIBindings::~DevToolsUIBindings() { |
557 for (const auto& pair : pending_requests_) | 429 for (const auto& pair : pending_requests_) |
558 delete pair.first; | 430 delete pair.first; |
559 | 431 |
560 if (agent_host_.get()) | 432 if (agent_host_.get()) |
561 agent_host_->DetachClient(this); | 433 agent_host_->DetachClient(this); |
562 | 434 |
563 for (IndexingJobsMap::const_iterator jobs_it(indexing_jobs_.begin()); | 435 for (IndexingJobsMap::const_iterator jobs_it(indexing_jobs_.begin()); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 876 |
1005 void DevToolsUIBindings::DispatchProtocolMessageFromDevToolsFrontend( | 877 void DevToolsUIBindings::DispatchProtocolMessageFromDevToolsFrontend( |
1006 const std::string& message) { | 878 const std::string& message) { |
1007 if (agent_host_.get()) | 879 if (agent_host_.get()) |
1008 agent_host_->DispatchProtocolMessage(this, message); | 880 agent_host_->DispatchProtocolMessage(this, message); |
1009 } | 881 } |
1010 | 882 |
1011 void DevToolsUIBindings::RecordEnumeratedHistogram(const std::string& name, | 883 void DevToolsUIBindings::RecordEnumeratedHistogram(const std::string& name, |
1012 int sample, | 884 int sample, |
1013 int boundary_value) { | 885 int boundary_value) { |
1014 if (!frontend_host_) | |
1015 return; | |
1016 if (!(boundary_value >= 0 && boundary_value <= 100 && sample >= 0 && | 886 if (!(boundary_value >= 0 && boundary_value <= 100 && sample >= 0 && |
1017 sample < boundary_value)) { | 887 sample < boundary_value)) { |
1018 // TODO(nick): Replace with chrome::bad_message::ReceivedBadMessage(). | 888 // TODO(nick): Replace with chrome::bad_message::ReceivedBadMessage(). |
1019 frontend_host_->BadMessageRecieved(); | 889 frontend_host_->BadMessageRecieved(); |
1020 return; | 890 return; |
1021 } | 891 } |
1022 // Each histogram name must follow a different code path in | 892 // Each histogram name must follow a different code path in |
1023 // order to UMA_HISTOGRAM_ENUMERATION work correctly. | 893 // order to UMA_HISTOGRAM_ENUMERATION work correctly. |
1024 if (name == kDevToolsActionTakenHistogram) | 894 if (name == kDevToolsActionTakenHistogram) |
1025 UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value); | 895 UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 const InfoBarCallback& callback) { | 1061 const InfoBarCallback& callback) { |
1192 if (!delegate_->GetInfoBarService()) { | 1062 if (!delegate_->GetInfoBarService()) { |
1193 callback.Run(false); | 1063 callback.Run(false); |
1194 return; | 1064 return; |
1195 } | 1065 } |
1196 std::unique_ptr<DevToolsConfirmInfoBarDelegate> delegate( | 1066 std::unique_ptr<DevToolsConfirmInfoBarDelegate> delegate( |
1197 new DevToolsConfirmInfoBarDelegate(callback, message)); | 1067 new DevToolsConfirmInfoBarDelegate(callback, message)); |
1198 GlobalConfirmInfoBar::Show(std::move(delegate)); | 1068 GlobalConfirmInfoBar::Show(std::move(delegate)); |
1199 } | 1069 } |
1200 | 1070 |
1201 void DevToolsUIBindings::UpdateFrontendHost() { | |
1202 GURL url = web_contents_->GetVisibleURL(); | |
1203 if (url.spec() != SanitizeFrontendURL(url).spec()) { | |
1204 LOG(ERROR) << "Attempt to navigate to an invalid DevTools front-end URL: " | |
1205 << url.spec(); | |
1206 frontend_host_.reset(); | |
1207 return; | |
1208 } | |
1209 frontend_host_.reset(content::DevToolsFrontendHost::Create( | |
1210 web_contents_->GetMainFrame(), | |
1211 base::Bind(&DevToolsUIBindings::HandleMessageFromDevToolsFrontend, | |
1212 base::Unretained(this)))); | |
1213 } | |
1214 | |
1215 void DevToolsUIBindings::AddDevToolsExtensionsToClient() { | 1071 void DevToolsUIBindings::AddDevToolsExtensionsToClient() { |
1216 const extensions::ExtensionRegistry* registry = | 1072 const extensions::ExtensionRegistry* registry = |
1217 extensions::ExtensionRegistry::Get(profile_->GetOriginalProfile()); | 1073 extensions::ExtensionRegistry::Get(profile_->GetOriginalProfile()); |
1218 if (!registry) | 1074 if (!registry) |
1219 return; | 1075 return; |
1220 | 1076 |
1221 base::ListValue results; | 1077 base::ListValue results; |
1222 for (const scoped_refptr<const extensions::Extension>& extension : | 1078 for (const scoped_refptr<const extensions::Extension>& extension : |
1223 registry->enabled_extensions()) { | 1079 registry->enabled_extensions()) { |
1224 if (extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) | 1080 if (extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { | 1134 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { |
1279 return agent_host_.get() == agent_host; | 1135 return agent_host_.get() == agent_host; |
1280 } | 1136 } |
1281 | 1137 |
1282 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, | 1138 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, |
1283 const base::Value* arg1, | 1139 const base::Value* arg1, |
1284 const base::Value* arg2, | 1140 const base::Value* arg2, |
1285 const base::Value* arg3) { | 1141 const base::Value* arg3) { |
1286 if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)) | 1142 if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)) |
1287 return; | 1143 return; |
1288 // If we're not exposing bindings, we shouldn't call functions either. | |
1289 if (!frontend_host_) | |
1290 return; | |
1291 std::string javascript = function_name + "("; | 1144 std::string javascript = function_name + "("; |
1292 if (arg1) { | 1145 if (arg1) { |
1293 std::string json; | 1146 std::string json; |
1294 base::JSONWriter::Write(*arg1, &json); | 1147 base::JSONWriter::Write(*arg1, &json); |
1295 javascript.append(json); | 1148 javascript.append(json); |
1296 if (arg2) { | 1149 if (arg2) { |
1297 base::JSONWriter::Write(*arg2, &json); | 1150 base::JSONWriter::Write(*arg2, &json); |
1298 javascript.append(", ").append(json); | 1151 javascript.append(", ").append(json); |
1299 if (arg3) { | 1152 if (arg3) { |
1300 base::JSONWriter::Write(*arg3, &json); | 1153 base::JSONWriter::Write(*arg3, &json); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 void DevToolsUIBindings::FrontendLoaded() { | 1186 void DevToolsUIBindings::FrontendLoaded() { |
1334 if (frontend_loaded_) | 1187 if (frontend_loaded_) |
1335 return; | 1188 return; |
1336 frontend_loaded_ = true; | 1189 frontend_loaded_ = true; |
1337 | 1190 |
1338 // Call delegate first - it seeds importants bit of information. | 1191 // Call delegate first - it seeds importants bit of information. |
1339 delegate_->OnLoadCompleted(); | 1192 delegate_->OnLoadCompleted(); |
1340 | 1193 |
1341 AddDevToolsExtensionsToClient(); | 1194 AddDevToolsExtensionsToClient(); |
1342 } | 1195 } |
OLD | NEW |