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" |
20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
23 #include "base/values.h" | 24 #include "base/values.h" |
24 #include "build/build_config.h" | 25 #include "build/build_config.h" |
25 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
26 #include "chrome/browser/devtools/devtools_file_watcher.h" | 27 #include "chrome/browser/devtools/devtools_file_watcher.h" |
27 #include "chrome/browser/devtools/devtools_protocol.h" | 28 #include "chrome/browser/devtools/devtools_protocol.h" |
28 #include "chrome/browser/devtools/global_confirm_info_bar.h" | 29 #include "chrome/browser/devtools/global_confirm_info_bar.h" |
| 30 #include "chrome/browser/devtools/url_constants.h" |
29 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 31 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
30 #include "chrome/browser/infobars/infobar_service.h" | 32 #include "chrome/browser/infobars/infobar_service.h" |
31 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/ui/browser.h" | 34 #include "chrome/browser/ui/browser.h" |
33 #include "chrome/browser/ui/browser_list.h" | 35 #include "chrome/browser/ui/browser_list.h" |
34 #include "chrome/browser/ui/browser_window.h" | 36 #include "chrome/browser/ui/browser_window.h" |
35 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 37 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
36 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
37 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" | 39 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" |
38 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
(...skipping 16 matching lines...) Expand all Loading... |
55 #include "content/public/browser/render_view_host.h" | 57 #include "content/public/browser/render_view_host.h" |
56 #include "content/public/browser/user_metrics.h" | 58 #include "content/public/browser/user_metrics.h" |
57 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
58 #include "content/public/browser/web_contents_observer.h" | 60 #include "content/public/browser/web_contents_observer.h" |
59 #include "content/public/common/renderer_preferences.h" | 61 #include "content/public/common/renderer_preferences.h" |
60 #include "content/public/common/url_constants.h" | 62 #include "content/public/common/url_constants.h" |
61 #include "extensions/browser/extension_registry.h" | 63 #include "extensions/browser/extension_registry.h" |
62 #include "extensions/common/constants.h" | 64 #include "extensions/common/constants.h" |
63 #include "extensions/common/permissions/permissions_data.h" | 65 #include "extensions/common/permissions/permissions_data.h" |
64 #include "ipc/ipc_channel.h" | 66 #include "ipc/ipc_channel.h" |
| 67 #include "net/base/escape.h" |
65 #include "net/base/io_buffer.h" | 68 #include "net/base/io_buffer.h" |
66 #include "net/base/net_errors.h" | 69 #include "net/base/net_errors.h" |
| 70 #include "net/base/url_util.h" |
67 #include "net/cert/x509_certificate.h" | 71 #include "net/cert/x509_certificate.h" |
68 #include "net/http/http_response_headers.h" | 72 #include "net/http/http_response_headers.h" |
69 #include "net/url_request/url_fetcher.h" | 73 #include "net/url_request/url_fetcher.h" |
70 #include "net/url_request/url_fetcher_response_writer.h" | 74 #include "net/url_request/url_fetcher_response_writer.h" |
71 #include "third_party/WebKit/public/public_features.h" | 75 #include "third_party/WebKit/public/public_features.h" |
72 #include "ui/base/l10n/l10n_util.h" | 76 #include "ui/base/l10n/l10n_util.h" |
73 #include "ui/base/page_transition_types.h" | 77 #include "ui/base/page_transition_types.h" |
74 | 78 |
75 using base::DictionaryValue; | 79 using base::DictionaryValue; |
76 using content::BrowserThread; | 80 using content::BrowserThread; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 "DevToolsAPI.streamWrite", base::Owned(id), | 296 "DevToolsAPI.streamWrite", base::Owned(id), |
293 base::Owned(chunkValue), base::Owned(encodedValue))); | 297 base::Owned(chunkValue), base::Owned(encodedValue))); |
294 return num_bytes; | 298 return num_bytes; |
295 } | 299 } |
296 | 300 |
297 int ResponseWriter::Finish(int net_error, | 301 int ResponseWriter::Finish(int net_error, |
298 const net::CompletionCallback& callback) { | 302 const net::CompletionCallback& callback) { |
299 return net::OK; | 303 return net::OK; |
300 } | 304 } |
301 | 305 |
| 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 |
302 } // namespace | 432 } // namespace |
303 | 433 |
304 // DevToolsUIBindings::FrontendWebContentsObserver ---------------------------- | 434 // DevToolsUIBindings::FrontendWebContentsObserver ---------------------------- |
305 | 435 |
306 class DevToolsUIBindings::FrontendWebContentsObserver | 436 class DevToolsUIBindings::FrontendWebContentsObserver |
307 : public content::WebContentsObserver { | 437 : public content::WebContentsObserver { |
308 public: | 438 public: |
309 explicit FrontendWebContentsObserver(DevToolsUIBindings* ui_bindings); | 439 explicit FrontendWebContentsObserver(DevToolsUIBindings* ui_bindings); |
310 ~FrontendWebContentsObserver() override; | 440 ~FrontendWebContentsObserver() override; |
311 | 441 |
(...skipping 16 matching lines...) Expand all Loading... |
328 DevToolsUIBindings::FrontendWebContentsObserver::FrontendWebContentsObserver( | 458 DevToolsUIBindings::FrontendWebContentsObserver::FrontendWebContentsObserver( |
329 DevToolsUIBindings* devtools_ui_bindings) | 459 DevToolsUIBindings* devtools_ui_bindings) |
330 : WebContentsObserver(devtools_ui_bindings->web_contents()), | 460 : WebContentsObserver(devtools_ui_bindings->web_contents()), |
331 devtools_bindings_(devtools_ui_bindings) { | 461 devtools_bindings_(devtools_ui_bindings) { |
332 } | 462 } |
333 | 463 |
334 DevToolsUIBindings::FrontendWebContentsObserver:: | 464 DevToolsUIBindings::FrontendWebContentsObserver:: |
335 ~FrontendWebContentsObserver() { | 465 ~FrontendWebContentsObserver() { |
336 } | 466 } |
337 | 467 |
| 468 // static |
| 469 GURL DevToolsUIBindings::SanitizeFrontendURL(const GURL& url) { |
| 470 return ::SanitizeFrontendURL(url, content::kChromeDevToolsScheme, |
| 471 chrome::kChromeUIDevToolsHost, SanitizeFrontendPath(url.path()), true); |
| 472 } |
| 473 |
338 void DevToolsUIBindings::FrontendWebContentsObserver::RenderProcessGone( | 474 void DevToolsUIBindings::FrontendWebContentsObserver::RenderProcessGone( |
339 base::TerminationStatus status) { | 475 base::TerminationStatus status) { |
340 bool crashed = true; | 476 bool crashed = true; |
341 switch (status) { | 477 switch (status) { |
342 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 478 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
343 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | 479 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
344 #if defined(OS_CHROMEOS) | 480 #if defined(OS_CHROMEOS) |
345 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: | 481 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: |
346 #endif | 482 #endif |
347 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 483 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
348 case base::TERMINATION_STATUS_LAUNCH_FAILED: | 484 case base::TERMINATION_STATUS_LAUNCH_FAILED: |
349 if (devtools_bindings_->agent_host_.get()) | 485 if (devtools_bindings_->agent_host_.get()) |
350 devtools_bindings_->Detach(); | 486 devtools_bindings_->Detach(); |
351 break; | 487 break; |
352 default: | 488 default: |
353 crashed = false; | 489 crashed = false; |
354 break; | 490 break; |
355 } | 491 } |
356 devtools_bindings_->delegate_->RenderProcessGone(crashed); | 492 devtools_bindings_->delegate_->RenderProcessGone(crashed); |
357 } | 493 } |
358 | 494 |
359 void DevToolsUIBindings::FrontendWebContentsObserver:: | 495 void DevToolsUIBindings::FrontendWebContentsObserver:: |
360 DidStartNavigationToPendingEntry(const GURL& url, | 496 DidStartNavigationToPendingEntry(const GURL& url, |
361 content::ReloadType reload_type) { | 497 content::ReloadType reload_type) { |
362 devtools_bindings_->frontend_host_.reset( | 498 devtools_bindings_->UpdateFrontendHost(); |
363 content::DevToolsFrontendHost::Create( | |
364 web_contents()->GetMainFrame(), | |
365 base::Bind(&DevToolsUIBindings::HandleMessageFromDevToolsFrontend, | |
366 base::Unretained(devtools_bindings_)))); | |
367 } | 499 } |
368 | 500 |
369 void DevToolsUIBindings::FrontendWebContentsObserver:: | 501 void DevToolsUIBindings::FrontendWebContentsObserver:: |
370 DocumentAvailableInMainFrame() { | 502 DocumentAvailableInMainFrame() { |
371 devtools_bindings_->DocumentAvailableInMainFrame(); | 503 devtools_bindings_->DocumentAvailableInMainFrame(); |
372 } | 504 } |
373 | 505 |
374 void DevToolsUIBindings::FrontendWebContentsObserver:: | 506 void DevToolsUIBindings::FrontendWebContentsObserver:: |
375 DocumentOnLoadCompletedInMainFrame() { | 507 DocumentOnLoadCompletedInMainFrame() { |
376 devtools_bindings_->DocumentOnLoadCompletedInMainFrame(); | 508 devtools_bindings_->DocumentOnLoadCompletedInMainFrame(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 web_contents_->GetMutableRendererPrefs()->can_accept_load_drops = false; | 543 web_contents_->GetMutableRendererPrefs()->can_accept_load_drops = false; |
412 | 544 |
413 file_helper_.reset(new DevToolsFileHelper(web_contents_, profile_, this)); | 545 file_helper_.reset(new DevToolsFileHelper(web_contents_, profile_, this)); |
414 file_system_indexer_ = new DevToolsFileSystemIndexer(); | 546 file_system_indexer_ = new DevToolsFileSystemIndexer(); |
415 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 547 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
416 web_contents_); | 548 web_contents_); |
417 | 549 |
418 // Register on-load actions. | 550 // Register on-load actions. |
419 embedder_message_dispatcher_.reset( | 551 embedder_message_dispatcher_.reset( |
420 DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this)); | 552 DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this)); |
421 | 553 UpdateFrontendHost(); |
422 frontend_host_.reset(content::DevToolsFrontendHost::Create( | |
423 web_contents_->GetMainFrame(), | |
424 base::Bind(&DevToolsUIBindings::HandleMessageFromDevToolsFrontend, | |
425 base::Unretained(this)))); | |
426 } | 554 } |
427 | 555 |
428 DevToolsUIBindings::~DevToolsUIBindings() { | 556 DevToolsUIBindings::~DevToolsUIBindings() { |
429 for (const auto& pair : pending_requests_) | 557 for (const auto& pair : pending_requests_) |
430 delete pair.first; | 558 delete pair.first; |
431 | 559 |
432 if (agent_host_.get()) | 560 if (agent_host_.get()) |
433 agent_host_->DetachClient(this); | 561 agent_host_->DetachClient(this); |
434 | 562 |
435 for (IndexingJobsMap::const_iterator jobs_it(indexing_jobs_.begin()); | 563 for (IndexingJobsMap::const_iterator jobs_it(indexing_jobs_.begin()); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 | 1004 |
877 void DevToolsUIBindings::DispatchProtocolMessageFromDevToolsFrontend( | 1005 void DevToolsUIBindings::DispatchProtocolMessageFromDevToolsFrontend( |
878 const std::string& message) { | 1006 const std::string& message) { |
879 if (agent_host_.get()) | 1007 if (agent_host_.get()) |
880 agent_host_->DispatchProtocolMessage(this, message); | 1008 agent_host_->DispatchProtocolMessage(this, message); |
881 } | 1009 } |
882 | 1010 |
883 void DevToolsUIBindings::RecordEnumeratedHistogram(const std::string& name, | 1011 void DevToolsUIBindings::RecordEnumeratedHistogram(const std::string& name, |
884 int sample, | 1012 int sample, |
885 int boundary_value) { | 1013 int boundary_value) { |
| 1014 if (!frontend_host_) |
| 1015 return; |
886 if (!(boundary_value >= 0 && boundary_value <= 100 && sample >= 0 && | 1016 if (!(boundary_value >= 0 && boundary_value <= 100 && sample >= 0 && |
887 sample < boundary_value)) { | 1017 sample < boundary_value)) { |
888 // TODO(nick): Replace with chrome::bad_message::ReceivedBadMessage(). | 1018 // TODO(nick): Replace with chrome::bad_message::ReceivedBadMessage(). |
889 frontend_host_->BadMessageRecieved(); | 1019 frontend_host_->BadMessageRecieved(); |
890 return; | 1020 return; |
891 } | 1021 } |
892 // Each histogram name must follow a different code path in | 1022 // Each histogram name must follow a different code path in |
893 // order to UMA_HISTOGRAM_ENUMERATION work correctly. | 1023 // order to UMA_HISTOGRAM_ENUMERATION work correctly. |
894 if (name == kDevToolsActionTakenHistogram) | 1024 if (name == kDevToolsActionTakenHistogram) |
895 UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value); | 1025 UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 const InfoBarCallback& callback) { | 1191 const InfoBarCallback& callback) { |
1062 if (!delegate_->GetInfoBarService()) { | 1192 if (!delegate_->GetInfoBarService()) { |
1063 callback.Run(false); | 1193 callback.Run(false); |
1064 return; | 1194 return; |
1065 } | 1195 } |
1066 std::unique_ptr<DevToolsConfirmInfoBarDelegate> delegate( | 1196 std::unique_ptr<DevToolsConfirmInfoBarDelegate> delegate( |
1067 new DevToolsConfirmInfoBarDelegate(callback, message)); | 1197 new DevToolsConfirmInfoBarDelegate(callback, message)); |
1068 GlobalConfirmInfoBar::Show(std::move(delegate)); | 1198 GlobalConfirmInfoBar::Show(std::move(delegate)); |
1069 } | 1199 } |
1070 | 1200 |
| 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 |
1071 void DevToolsUIBindings::AddDevToolsExtensionsToClient() { | 1215 void DevToolsUIBindings::AddDevToolsExtensionsToClient() { |
1072 const extensions::ExtensionRegistry* registry = | 1216 const extensions::ExtensionRegistry* registry = |
1073 extensions::ExtensionRegistry::Get(profile_->GetOriginalProfile()); | 1217 extensions::ExtensionRegistry::Get(profile_->GetOriginalProfile()); |
1074 if (!registry) | 1218 if (!registry) |
1075 return; | 1219 return; |
1076 | 1220 |
1077 base::ListValue results; | 1221 base::ListValue results; |
1078 for (const scoped_refptr<const extensions::Extension>& extension : | 1222 for (const scoped_refptr<const extensions::Extension>& extension : |
1079 registry->enabled_extensions()) { | 1223 registry->enabled_extensions()) { |
1080 if (extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) | 1224 if (extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { | 1278 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { |
1135 return agent_host_.get() == agent_host; | 1279 return agent_host_.get() == agent_host; |
1136 } | 1280 } |
1137 | 1281 |
1138 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, | 1282 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, |
1139 const base::Value* arg1, | 1283 const base::Value* arg1, |
1140 const base::Value* arg2, | 1284 const base::Value* arg2, |
1141 const base::Value* arg3) { | 1285 const base::Value* arg3) { |
1142 if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)) | 1286 if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)) |
1143 return; | 1287 return; |
| 1288 // If we're not exposing bindings, we shouldn't call functions either. |
| 1289 if (!frontend_host_) |
| 1290 return; |
1144 std::string javascript = function_name + "("; | 1291 std::string javascript = function_name + "("; |
1145 if (arg1) { | 1292 if (arg1) { |
1146 std::string json; | 1293 std::string json; |
1147 base::JSONWriter::Write(*arg1, &json); | 1294 base::JSONWriter::Write(*arg1, &json); |
1148 javascript.append(json); | 1295 javascript.append(json); |
1149 if (arg2) { | 1296 if (arg2) { |
1150 base::JSONWriter::Write(*arg2, &json); | 1297 base::JSONWriter::Write(*arg2, &json); |
1151 javascript.append(", ").append(json); | 1298 javascript.append(", ").append(json); |
1152 if (arg3) { | 1299 if (arg3) { |
1153 base::JSONWriter::Write(*arg3, &json); | 1300 base::JSONWriter::Write(*arg3, &json); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 void DevToolsUIBindings::FrontendLoaded() { | 1333 void DevToolsUIBindings::FrontendLoaded() { |
1187 if (frontend_loaded_) | 1334 if (frontend_loaded_) |
1188 return; | 1335 return; |
1189 frontend_loaded_ = true; | 1336 frontend_loaded_ = true; |
1190 | 1337 |
1191 // Call delegate first - it seeds importants bit of information. | 1338 // Call delegate first - it seeds importants bit of information. |
1192 delegate_->OnLoadCompleted(); | 1339 delegate_->OnLoadCompleted(); |
1193 | 1340 |
1194 AddDevToolsExtensionsToClient(); | 1341 AddDevToolsExtensionsToClient(); |
1195 } | 1342 } |
OLD | NEW |