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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
41 #include "content/public/browser/render_frame_host.h" | 41 #include "content/public/browser/render_frame_host.h" |
42 #include "content/public/browser/render_view_host.h" | 42 #include "content/public/browser/render_view_host.h" |
43 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
44 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
45 #include "content/public/browser/web_contents_observer.h" | 45 #include "content/public/browser/web_contents_observer.h" |
46 #include "content/public/common/renderer_preferences.h" | 46 #include "content/public/common/renderer_preferences.h" |
47 #include "content/public/common/url_constants.h" | 47 #include "content/public/common/url_constants.h" |
48 #include "extensions/browser/extension_registry.h" | 48 #include "extensions/browser/extension_registry.h" |
49 #include "extensions/common/permissions/permissions_data.h" | 49 #include "extensions/common/permissions/permissions_data.h" |
50 #include "net/base/net_errors.h" | |
50 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
51 #include "ui/base/page_transition_types.h" | 52 #include "ui/base/page_transition_types.h" |
52 | 53 |
53 using base::DictionaryValue; | 54 using base::DictionaryValue; |
54 using content::BrowserThread; | 55 using content::BrowserThread; |
55 | 56 |
56 namespace content { | 57 namespace content { |
57 struct LoadCommittedDetails; | 58 struct LoadCommittedDetails; |
58 struct FrameNavigateParams; | 59 struct FrameNavigateParams; |
59 } | 60 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 return file_system_value; | 97 return file_system_value; |
97 } | 98 } |
98 | 99 |
99 Browser* FindBrowser(content::WebContents* web_contents) { | 100 Browser* FindBrowser(content::WebContents* web_contents) { |
100 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 101 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
101 int tab_index = it->tab_strip_model()->GetIndexOfWebContents( | 102 int tab_index = it->tab_strip_model()->GetIndexOfWebContents( |
102 web_contents); | 103 web_contents); |
103 if (tab_index != TabStripModel::kNoTab) | 104 if (tab_index != TabStripModel::kNoTab) |
104 return *it; | 105 return *it; |
105 } | 106 } |
106 return NULL; | 107 return nullptr; |
107 } | 108 } |
108 | 109 |
109 // DevToolsConfirmInfoBarDelegate --------------------------------------------- | 110 // DevToolsConfirmInfoBarDelegate --------------------------------------------- |
110 | 111 |
111 typedef base::Callback<void(bool)> InfoBarCallback; | 112 typedef base::Callback<void(bool)> InfoBarCallback; |
112 | 113 |
113 class DevToolsConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { | 114 class DevToolsConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { |
114 public: | 115 public: |
115 // If |infobar_service| is NULL, runs |callback| with a single argument with | 116 // If |infobar_service| is null, runs |callback| with a single argument with |
116 // value "false". Otherwise, creates a dev tools confirm infobar and delegate | 117 // value "false". Otherwise, creates a dev tools confirm infobar and delegate |
117 // and adds the infobar to |infobar_service|. | 118 // and adds the infobar to |infobar_service|. |
118 static void Create(InfoBarService* infobar_service, | 119 static void Create(InfoBarService* infobar_service, |
119 const InfoBarCallback& callback, | 120 const InfoBarCallback& callback, |
120 const base::string16& message); | 121 const base::string16& message); |
121 | 122 |
122 private: | 123 private: |
123 DevToolsConfirmInfoBarDelegate( | 124 DevToolsConfirmInfoBarDelegate( |
124 const InfoBarCallback& callback, | 125 const InfoBarCallback& callback, |
125 const base::string16& message); | 126 const base::string16& message); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 void DevToolsUIBindings::FrontendWebContentsObserver:: | 306 void DevToolsUIBindings::FrontendWebContentsObserver:: |
306 DidNavigateMainFrame(const content::LoadCommittedDetails& details, | 307 DidNavigateMainFrame(const content::LoadCommittedDetails& details, |
307 const content::FrameNavigateParams& params) { | 308 const content::FrameNavigateParams& params) { |
308 devtools_bindings_->DidNavigateMainFrame(); | 309 devtools_bindings_->DidNavigateMainFrame(); |
309 } | 310 } |
310 | 311 |
311 // DevToolsUIBindings --------------------------------------------------------- | 312 // DevToolsUIBindings --------------------------------------------------------- |
312 | 313 |
313 DevToolsUIBindings* DevToolsUIBindings::ForWebContents( | 314 DevToolsUIBindings* DevToolsUIBindings::ForWebContents( |
314 content::WebContents* web_contents) { | 315 content::WebContents* web_contents) { |
315 if (g_instances == NULL) | 316 if (g_instances == nullptr) |
316 return NULL; | 317 return nullptr; |
317 DevToolsUIBindingsList* instances = g_instances.Pointer(); | 318 DevToolsUIBindingsList* instances = g_instances.Pointer(); |
318 for (DevToolsUIBindingsList::iterator it(instances->begin()); | 319 for (DevToolsUIBindings* bindings : *instances) { |
319 it != instances->end(); ++it) { | 320 if (bindings->web_contents() == web_contents) |
320 if ((*it)->web_contents() == web_contents) | 321 return bindings; |
321 return *it; | |
322 } | 322 } |
323 return NULL; | 323 return nullptr; |
324 } | 324 } |
325 | 325 |
326 // static | 326 // static |
327 GURL DevToolsUIBindings::ApplyThemeToURL(Profile* profile, | 327 GURL DevToolsUIBindings::ApplyThemeToURL(Profile* profile, |
328 const GURL& base_url) { | 328 const GURL& base_url) { |
329 std::string frontend_url = base_url.spec(); | 329 std::string frontend_url = base_url.spec(); |
330 ThemeService* tp = ThemeServiceFactory::GetForProfile(profile); | 330 ThemeService* tp = ThemeServiceFactory::GetForProfile(profile); |
331 DCHECK(tp); | 331 DCHECK(tp); |
332 std::string url_string( | 332 std::string url_string( |
333 frontend_url + | 333 frontend_url + |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 entry->GetFavicon().image = gfx::Image(); | 369 entry->GetFavicon().image = gfx::Image(); |
370 entry->GetFavicon().valid = true; | 370 entry->GetFavicon().valid = true; |
371 | 371 |
372 // Register on-load actions. | 372 // Register on-load actions. |
373 registrar_.Add( | 373 registrar_.Add( |
374 this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 374 this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
375 content::Source<ThemeService>( | 375 content::Source<ThemeService>( |
376 ThemeServiceFactory::GetForProfile(profile_))); | 376 ThemeServiceFactory::GetForProfile(profile_))); |
377 | 377 |
378 embedder_message_dispatcher_.reset( | 378 embedder_message_dispatcher_.reset( |
379 DevToolsEmbedderMessageDispatcher::createForDevToolsFrontend(this)); | 379 DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this)); |
380 | 380 |
381 frontend_host_.reset(content::DevToolsFrontendHost::Create( | 381 frontend_host_.reset(content::DevToolsFrontendHost::Create( |
382 web_contents_->GetMainFrame(), this)); | 382 web_contents_->GetMainFrame(), this)); |
383 } | 383 } |
384 | 384 |
385 DevToolsUIBindings::~DevToolsUIBindings() { | 385 DevToolsUIBindings::~DevToolsUIBindings() { |
386 if (agent_host_.get()) | 386 if (agent_host_.get()) |
387 agent_host_->DetachClient(); | 387 agent_host_->DetachClient(); |
388 | 388 |
389 for (IndexingJobsMap::const_iterator jobs_it(indexing_jobs_.begin()); | 389 for (const auto& job : indexing_jobs_) { |
390 jobs_it != indexing_jobs_.end(); ++jobs_it) { | 390 job.second->Stop(); |
391 jobs_it->second->Stop(); | |
392 } | 391 } |
393 indexing_jobs_.clear(); | 392 indexing_jobs_.clear(); |
394 SetDeviceCountUpdatesEnabled(false); | 393 SetDeviceCountUpdatesEnabled(0, false); |
395 SetDevicesUpdatesEnabled(false); | 394 SetDevicesUpdatesEnabled(0, false); |
396 | 395 |
397 // Remove self from global list. | 396 // Remove self from global list. |
398 DevToolsUIBindingsList* instances = g_instances.Pointer(); | 397 DevToolsUIBindingsList* instances = g_instances.Pointer(); |
399 DevToolsUIBindingsList::iterator it( | 398 DevToolsUIBindingsList::iterator it( |
400 std::find(instances->begin(), instances->end(), this)); | 399 std::find(instances->begin(), instances->end(), this)); |
401 DCHECK(it != instances->end()); | 400 DCHECK(it != instances->end()); |
402 instances->erase(it); | 401 instances->erase(it); |
403 } | 402 } |
404 | 403 |
405 // content::NotificationObserver overrides ------------------------------------ | 404 // content::NotificationObserver overrides ------------------------------------ |
406 void DevToolsUIBindings::Observe(int type, | 405 void DevToolsUIBindings::Observe(int type, |
407 const content::NotificationSource& source, | 406 const content::NotificationSource& source, |
408 const content::NotificationDetails& details) { | 407 const content::NotificationDetails& details) { |
409 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); | 408 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
410 UpdateTheme(); | 409 UpdateTheme(); |
411 } | 410 } |
412 | 411 |
413 // content::DevToolsFrontendHost::Delegate implementation --------------------- | 412 // content::DevToolsFrontendHost::Delegate implementation --------------------- |
414 void DevToolsUIBindings::HandleMessageFromDevToolsFrontend( | 413 void DevToolsUIBindings::HandleMessageFromDevToolsFrontend( |
415 const std::string& message) { | 414 const std::string& message) { |
416 std::string method; | 415 std::string method; |
417 base::ListValue empty_params; | 416 base::ListValue empty_params; |
418 base::ListValue* params = &empty_params; | 417 base::ListValue* params = &empty_params; |
419 | 418 |
420 base::DictionaryValue* dict = NULL; | 419 base::DictionaryValue* dict = nullptr; |
421 scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message)); | 420 scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message)); |
422 if (!parsed_message || | 421 if (!parsed_message || |
423 !parsed_message->GetAsDictionary(&dict) || | 422 !parsed_message->GetAsDictionary(&dict) || |
424 !dict->GetString(kFrontendHostMethod, &method) || | 423 !dict->GetString(kFrontendHostMethod, &method) || |
425 (dict->HasKey(kFrontendHostParams) && | 424 (dict->HasKey(kFrontendHostParams) && |
426 !dict->GetList(kFrontendHostParams, ¶ms))) { | 425 !dict->GetList(kFrontendHostParams, ¶ms))) { |
427 LOG(ERROR) << "Invalid message was sent to embedder: " << message; | 426 LOG(ERROR) << "Invalid message was sent to embedder: " << message; |
428 return; | 427 return; |
429 } | 428 } |
430 | |
431 int id = 0; | 429 int id = 0; |
432 dict->GetInteger(kFrontendHostId, &id); | 430 dict->GetInteger(kFrontendHostId, &id); |
433 | 431 embedder_message_dispatcher_->Dispatch(id, method, params); |
434 std::string error; | |
435 embedder_message_dispatcher_->Dispatch(method, params, &error); | |
436 if (id) { | |
437 base::FundamentalValue id_value(id); | |
438 base::StringValue error_value(error); | |
439 CallClientFunction("DevToolsAPI.embedderMessageAck", | |
440 &id_value, &error_value, NULL); | |
441 } | |
442 } | 432 } |
443 | 433 |
444 void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend( | 434 void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend( |
445 const std::string& message) { | 435 const std::string& message) { |
446 if (agent_host_.get()) | 436 if (agent_host_.get()) |
447 agent_host_->DispatchProtocolMessage(message); | 437 agent_host_->DispatchProtocolMessage(message); |
448 } | 438 } |
449 | 439 |
450 // content::DevToolsAgentHostClient implementation -------------------------- | 440 // content::DevToolsAgentHostClient implementation -------------------------- |
451 void DevToolsUIBindings::DispatchProtocolMessage( | 441 void DevToolsUIBindings::DispatchProtocolMessage( |
452 content::DevToolsAgentHost* agent_host, const std::string& message) { | 442 content::DevToolsAgentHost* agent_host, const std::string& message) { |
453 DCHECK(agent_host == agent_host_.get()); | 443 DCHECK(agent_host == agent_host_.get()); |
454 | 444 |
455 if (message.length() < kMaxMessageChunkSize) { | 445 if (message.length() < kMaxMessageChunkSize) { |
456 base::string16 javascript = base::UTF8ToUTF16( | 446 base::string16 javascript = base::UTF8ToUTF16( |
457 "DevToolsAPI.dispatchMessage(" + message + ");"); | 447 "DevToolsAPI.dispatchMessage(" + message + ");"); |
458 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); | 448 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); |
459 return; | 449 return; |
460 } | 450 } |
461 | 451 |
462 base::FundamentalValue total_size(static_cast<int>(message.length())); | 452 base::FundamentalValue total_size(static_cast<int>(message.length())); |
463 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { | 453 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { |
464 base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize)); | 454 base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize)); |
465 CallClientFunction("DevToolsAPI.dispatchMessageChunk", | 455 CallClientFunction("DevToolsAPI.dispatchMessageChunk", |
466 &message_value, pos ? NULL : &total_size, NULL); | 456 &message_value, pos ? nullptr : &total_size, nullptr); |
467 } | 457 } |
468 } | 458 } |
469 | 459 |
470 void DevToolsUIBindings::AgentHostClosed( | 460 void DevToolsUIBindings::AgentHostClosed( |
471 content::DevToolsAgentHost* agent_host, | 461 content::DevToolsAgentHost* agent_host, |
472 bool replaced_with_another_client) { | 462 bool replaced_with_another_client) { |
473 DCHECK(agent_host == agent_host_.get()); | 463 DCHECK(agent_host == agent_host_.get()); |
474 agent_host_ = NULL; | 464 agent_host_ = nullptr; |
475 delegate_->InspectedContentsClosing(); | 465 delegate_->InspectedContentsClosing(); |
476 } | 466 } |
477 | 467 |
478 // DevToolsEmbedderMessageDispatcher::Delegate implementation ----------------- | 468 // DevToolsEmbedderMessageDispatcher::Delegate implementation ----------------- |
479 void DevToolsUIBindings::ActivateWindow() { | 469 void DevToolsUIBindings::ActivateWindow(int request_id) { |
480 delegate_->ActivateWindow(); | 470 delegate_->ActivateWindow(); |
481 } | 471 } |
482 | 472 |
483 void DevToolsUIBindings::CloseWindow() { | 473 void DevToolsUIBindings::CloseWindow(int request_id) { |
484 delegate_->CloseWindow(); | 474 delegate_->CloseWindow(); |
485 } | 475 } |
486 | 476 |
487 void DevToolsUIBindings::LoadCompleted() { | 477 void DevToolsUIBindings::LoadCompleted(int request_id) { |
488 FrontendLoaded(); | 478 FrontendLoaded(); |
489 } | 479 } |
490 | 480 |
491 void DevToolsUIBindings::SetInspectedPageBounds(const gfx::Rect& rect) { | 481 void DevToolsUIBindings::SetInspectedPageBounds(int request_id, |
482 const gfx::Rect& rect) { | |
492 delegate_->SetInspectedPageBounds(rect); | 483 delegate_->SetInspectedPageBounds(rect); |
493 } | 484 } |
494 | 485 |
495 void DevToolsUIBindings::SetIsDocked(bool dock_requested) { | 486 void DevToolsUIBindings::SetIsDocked(int request_id, bool dock_requested) { |
496 delegate_->SetIsDocked(dock_requested); | 487 delegate_->SetIsDocked(dock_requested); |
488 base::FundamentalValue id_value(request_id); | |
489 CallClientFunction("DevToolsAPI.embedderMessageAck", | |
dgozman
2015/02/12 10:20:36
You should make a separate function for this, e.g.
vkuzkokov
2015/02/27 14:00:05
Done.
| |
490 &id_value, nullptr, nullptr); | |
497 } | 491 } |
498 | 492 |
499 void DevToolsUIBindings::InspectElementCompleted() { | 493 void DevToolsUIBindings::InspectElementCompleted(int request_id) { |
500 delegate_->InspectElementCompleted(); | 494 delegate_->InspectElementCompleted(); |
501 } | 495 } |
502 | 496 |
503 void DevToolsUIBindings::InspectedURLChanged(const std::string& url) { | 497 void DevToolsUIBindings::InspectedURLChanged(int request_id, |
498 const std::string& url) { | |
504 content::NavigationController& controller = web_contents()->GetController(); | 499 content::NavigationController& controller = web_contents()->GetController(); |
505 content::NavigationEntry* entry = controller.GetActiveEntry(); | 500 content::NavigationEntry* entry = controller.GetActiveEntry(); |
506 // DevTools UI is not localized. | 501 // DevTools UI is not localized. |
507 entry->SetTitle( | 502 entry->SetTitle( |
508 base::UTF8ToUTF16(base::StringPrintf(kTitleFormat, url.c_str()))); | 503 base::UTF8ToUTF16(base::StringPrintf(kTitleFormat, url.c_str()))); |
509 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); | 504 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); |
510 } | 505 } |
511 | 506 |
512 void DevToolsUIBindings::OpenInNewTab(const std::string& url) { | 507 void DevToolsUIBindings::OpenInNewTab(int request_id, const std::string& url) { |
513 delegate_->OpenInNewTab(url); | 508 delegate_->OpenInNewTab(url); |
514 } | 509 } |
515 | 510 |
516 void DevToolsUIBindings::SaveToFile(const std::string& url, | 511 void DevToolsUIBindings::SaveToFile(int request_id, |
512 const std::string& url, | |
517 const std::string& content, | 513 const std::string& content, |
518 bool save_as) { | 514 bool save_as) { |
519 file_helper_->Save(url, content, save_as, | 515 file_helper_->Save(url, content, save_as, |
520 base::Bind(&DevToolsUIBindings::FileSavedAs, | 516 base::Bind(&DevToolsUIBindings::FileSavedAs, |
521 weak_factory_.GetWeakPtr(), url), | 517 weak_factory_.GetWeakPtr(), url), |
522 base::Bind(&DevToolsUIBindings::CanceledFileSaveAs, | 518 base::Bind(&DevToolsUIBindings::CanceledFileSaveAs, |
523 weak_factory_.GetWeakPtr(), url)); | 519 weak_factory_.GetWeakPtr(), url)); |
524 } | 520 } |
525 | 521 |
526 void DevToolsUIBindings::AppendToFile(const std::string& url, | 522 void DevToolsUIBindings::AppendToFile(int request_id, |
523 const std::string& url, | |
527 const std::string& content) { | 524 const std::string& content) { |
528 file_helper_->Append(url, content, | 525 file_helper_->Append(url, content, |
529 base::Bind(&DevToolsUIBindings::AppendedTo, | 526 base::Bind(&DevToolsUIBindings::AppendedTo, |
530 weak_factory_.GetWeakPtr(), url)); | 527 weak_factory_.GetWeakPtr(), url)); |
531 } | 528 } |
532 | 529 |
533 void DevToolsUIBindings::RequestFileSystems() { | 530 void DevToolsUIBindings::RequestFileSystems(int request_id) { |
534 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); | 531 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); |
535 file_helper_->RequestFileSystems(base::Bind( | 532 file_helper_->RequestFileSystems(base::Bind( |
536 &DevToolsUIBindings::FileSystemsLoaded, weak_factory_.GetWeakPtr())); | 533 &DevToolsUIBindings::FileSystemsLoaded, weak_factory_.GetWeakPtr())); |
537 } | 534 } |
538 | 535 |
539 void DevToolsUIBindings::AddFileSystem() { | 536 void DevToolsUIBindings::AddFileSystem(int request_id) { |
540 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); | 537 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); |
541 file_helper_->AddFileSystem( | 538 file_helper_->AddFileSystem( |
542 base::Bind(&DevToolsUIBindings::FileSystemAdded, | 539 base::Bind(&DevToolsUIBindings::FileSystemAdded, |
543 weak_factory_.GetWeakPtr()), | 540 weak_factory_.GetWeakPtr()), |
544 base::Bind(&DevToolsUIBindings::ShowDevToolsConfirmInfoBar, | 541 base::Bind(&DevToolsUIBindings::ShowDevToolsConfirmInfoBar, |
545 weak_factory_.GetWeakPtr())); | 542 weak_factory_.GetWeakPtr())); |
546 } | 543 } |
547 | 544 |
548 void DevToolsUIBindings::RemoveFileSystem( | 545 void DevToolsUIBindings::RemoveFileSystem(int request_id, |
549 const std::string& file_system_path) { | 546 const std::string& file_system_path) { |
550 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); | 547 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); |
551 file_helper_->RemoveFileSystem(file_system_path); | 548 file_helper_->RemoveFileSystem(file_system_path); |
552 base::StringValue file_system_path_value(file_system_path); | 549 base::StringValue file_system_path_value(file_system_path); |
553 CallClientFunction("DevToolsAPI.fileSystemRemoved", | 550 CallClientFunction("DevToolsAPI.fileSystemRemoved", |
554 &file_system_path_value, NULL, NULL); | 551 &file_system_path_value, nullptr, nullptr); |
555 } | 552 } |
556 | 553 |
557 void DevToolsUIBindings::UpgradeDraggedFileSystemPermissions( | 554 void DevToolsUIBindings::UpgradeDraggedFileSystemPermissions( |
555 int request_id, | |
558 const std::string& file_system_url) { | 556 const std::string& file_system_url) { |
559 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); | 557 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); |
560 file_helper_->UpgradeDraggedFileSystemPermissions( | 558 file_helper_->UpgradeDraggedFileSystemPermissions( |
561 file_system_url, | 559 file_system_url, |
562 base::Bind(&DevToolsUIBindings::FileSystemAdded, | 560 base::Bind(&DevToolsUIBindings::FileSystemAdded, |
563 weak_factory_.GetWeakPtr()), | 561 weak_factory_.GetWeakPtr()), |
564 base::Bind(&DevToolsUIBindings::ShowDevToolsConfirmInfoBar, | 562 base::Bind(&DevToolsUIBindings::ShowDevToolsConfirmInfoBar, |
565 weak_factory_.GetWeakPtr())); | 563 weak_factory_.GetWeakPtr())); |
566 } | 564 } |
567 | 565 |
568 void DevToolsUIBindings::IndexPath(int request_id, | 566 void DevToolsUIBindings::IndexPath(int request_id, |
567 int index_request_id, | |
569 const std::string& file_system_path) { | 568 const std::string& file_system_path) { |
570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
571 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); | 570 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); |
572 if (!file_helper_->IsFileSystemAdded(file_system_path)) { | 571 if (!file_helper_->IsFileSystemAdded(file_system_path)) { |
573 IndexingDone(request_id, file_system_path); | 572 IndexingDone(index_request_id, file_system_path); |
574 return; | 573 return; |
575 } | 574 } |
576 indexing_jobs_[request_id] = | 575 indexing_jobs_[index_request_id] = |
577 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>( | 576 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>( |
578 file_system_indexer_->IndexPath( | 577 file_system_indexer_->IndexPath( |
579 file_system_path, | 578 file_system_path, |
580 Bind(&DevToolsUIBindings::IndexingTotalWorkCalculated, | 579 Bind(&DevToolsUIBindings::IndexingTotalWorkCalculated, |
581 weak_factory_.GetWeakPtr(), | 580 weak_factory_.GetWeakPtr(), |
582 request_id, | 581 index_request_id, |
583 file_system_path), | 582 file_system_path), |
584 Bind(&DevToolsUIBindings::IndexingWorked, | 583 Bind(&DevToolsUIBindings::IndexingWorked, |
585 weak_factory_.GetWeakPtr(), | 584 weak_factory_.GetWeakPtr(), |
586 request_id, | 585 index_request_id, |
587 file_system_path), | 586 file_system_path), |
588 Bind(&DevToolsUIBindings::IndexingDone, | 587 Bind(&DevToolsUIBindings::IndexingDone, |
589 weak_factory_.GetWeakPtr(), | 588 weak_factory_.GetWeakPtr(), |
590 request_id, | 589 index_request_id, |
591 file_system_path))); | 590 file_system_path))); |
592 } | 591 } |
593 | 592 |
594 void DevToolsUIBindings::StopIndexing(int request_id) { | 593 void DevToolsUIBindings::StopIndexing(int request_id, int index_request_id) { |
595 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 594 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
596 IndexingJobsMap::iterator it = indexing_jobs_.find(request_id); | 595 IndexingJobsMap::iterator it = indexing_jobs_.find(index_request_id); |
597 if (it == indexing_jobs_.end()) | 596 if (it == indexing_jobs_.end()) |
598 return; | 597 return; |
599 it->second->Stop(); | 598 it->second->Stop(); |
600 indexing_jobs_.erase(it); | 599 indexing_jobs_.erase(it); |
601 } | 600 } |
602 | 601 |
603 void DevToolsUIBindings::SearchInPath(int request_id, | 602 void DevToolsUIBindings::SearchInPath(int request_id, |
603 int search_request_id, | |
604 const std::string& file_system_path, | 604 const std::string& file_system_path, |
605 const std::string& query) { | 605 const std::string& query) { |
606 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 606 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
607 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); | 607 CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme)); |
608 if (!file_helper_->IsFileSystemAdded(file_system_path)) { | 608 if (!file_helper_->IsFileSystemAdded(file_system_path)) { |
609 SearchCompleted(request_id, file_system_path, std::vector<std::string>()); | 609 SearchCompleted(search_request_id, |
610 file_system_path, | |
611 std::vector<std::string>()); | |
610 return; | 612 return; |
611 } | 613 } |
612 file_system_indexer_->SearchInPath(file_system_path, | 614 file_system_indexer_->SearchInPath(file_system_path, |
613 query, | 615 query, |
614 Bind(&DevToolsUIBindings::SearchCompleted, | 616 Bind(&DevToolsUIBindings::SearchCompleted, |
615 weak_factory_.GetWeakPtr(), | 617 weak_factory_.GetWeakPtr(), |
616 request_id, | 618 search_request_id, |
617 file_system_path)); | 619 file_system_path)); |
618 } | 620 } |
619 | 621 |
620 void DevToolsUIBindings::SetWhitelistedShortcuts( | 622 void DevToolsUIBindings::SetWhitelistedShortcuts(int request_id, |
621 const std::string& message) { | 623 const std::string& message) { |
622 delegate_->SetWhitelistedShortcuts(message); | 624 delegate_->SetWhitelistedShortcuts(message); |
623 } | 625 } |
624 | 626 |
625 void DevToolsUIBindings::ZoomIn() { | 627 void DevToolsUIBindings::ZoomIn(int request_id) { |
626 ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_IN); | 628 ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_IN); |
627 } | 629 } |
628 | 630 |
629 void DevToolsUIBindings::ZoomOut() { | 631 void DevToolsUIBindings::ZoomOut(int request_id) { |
630 ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_OUT); | 632 ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_OUT); |
631 } | 633 } |
632 | 634 |
633 void DevToolsUIBindings::ResetZoom() { | 635 void DevToolsUIBindings::ResetZoom(int request_id) { |
634 ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_RESET); | 636 ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_RESET); |
635 } | 637 } |
636 | 638 |
637 static void InspectTarget(Profile* profile, DevToolsTargetImpl* target) { | 639 static void InspectTarget(Profile* profile, DevToolsTargetImpl* target) { |
638 if (target) | 640 if (target) |
639 target->Inspect(profile); | 641 target->Inspect(profile); |
640 } | 642 } |
641 | 643 |
642 void DevToolsUIBindings::OpenUrlOnRemoteDeviceAndInspect( | 644 void DevToolsUIBindings::OpenUrlOnRemoteDeviceAndInspect( |
645 int request_id, | |
643 const std::string& browser_id, | 646 const std::string& browser_id, |
644 const std::string& url) { | 647 const std::string& url) { |
645 if (remote_targets_handler_) { | 648 if (remote_targets_handler_) { |
646 remote_targets_handler_->Open(browser_id, url, | 649 remote_targets_handler_->Open(browser_id, url, |
647 base::Bind(&InspectTarget, profile_)); | 650 base::Bind(&InspectTarget, profile_)); |
648 } | 651 } |
649 } | 652 } |
650 | 653 |
651 void DevToolsUIBindings::SetDeviceCountUpdatesEnabled(bool enabled) { | 654 void DevToolsUIBindings::SetDeviceCountUpdatesEnabled(int request_id, |
655 bool enabled) { | |
652 if (device_count_updates_enabled_ == enabled) | 656 if (device_count_updates_enabled_ == enabled) |
653 return; | 657 return; |
654 DevToolsAndroidBridge* adb_bridge = | 658 DevToolsAndroidBridge* adb_bridge = |
655 DevToolsAndroidBridge::Factory::GetForProfile(profile_); | 659 DevToolsAndroidBridge::Factory::GetForProfile(profile_); |
656 if (!adb_bridge) | 660 if (!adb_bridge) |
657 return; | 661 return; |
658 | 662 |
659 device_count_updates_enabled_ = enabled; | 663 device_count_updates_enabled_ = enabled; |
660 if (enabled) | 664 if (enabled) |
661 adb_bridge->AddDeviceCountListener(this); | 665 adb_bridge->AddDeviceCountListener(this); |
662 else | 666 else |
663 adb_bridge->RemoveDeviceCountListener(this); | 667 adb_bridge->RemoveDeviceCountListener(this); |
664 } | 668 } |
665 | 669 |
666 void DevToolsUIBindings::SetDevicesUpdatesEnabled(bool enabled) { | 670 void DevToolsUIBindings::SetDevicesUpdatesEnabled(int request_id, |
671 bool enabled) { | |
667 if (devices_updates_enabled_ == enabled) | 672 if (devices_updates_enabled_ == enabled) |
668 return; | 673 return; |
669 devices_updates_enabled_ = enabled; | 674 devices_updates_enabled_ = enabled; |
670 if (enabled) { | 675 if (enabled) { |
671 remote_targets_handler_ = DevToolsTargetsUIHandler::CreateForAdb( | 676 remote_targets_handler_ = DevToolsTargetsUIHandler::CreateForAdb( |
672 base::Bind(&DevToolsUIBindings::DevicesUpdated, | 677 base::Bind(&DevToolsUIBindings::DevicesUpdated, |
673 base::Unretained(this)), | 678 base::Unretained(this)), |
674 profile_); | 679 profile_); |
675 } else { | 680 } else { |
676 remote_targets_handler_.reset(); | 681 remote_targets_handler_.reset(); |
677 } | 682 } |
678 } | 683 } |
679 | 684 |
680 void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) { | 685 void DevToolsUIBindings::SendMessageToBrowser(int request_id, |
686 const std::string& message) { | |
681 if (agent_host_.get()) | 687 if (agent_host_.get()) |
682 agent_host_->DispatchProtocolMessage(message); | 688 agent_host_->DispatchProtocolMessage(message); |
683 } | 689 } |
684 | 690 |
685 void DevToolsUIBindings::RecordActionUMA(const std::string& name, int action) { | 691 void DevToolsUIBindings::RecordActionUMA(int request_id, |
692 const std::string& name, | |
693 int action) { | |
686 if (name == kDevToolsActionTakenHistogram) | 694 if (name == kDevToolsActionTakenHistogram) |
687 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary); | 695 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary); |
688 else if (name == kDevToolsPanelShownHistogram) | 696 else if (name == kDevToolsPanelShownHistogram) |
689 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary); | 697 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary); |
690 } | 698 } |
691 | 699 |
700 void DevToolsUIBindings::SendJsonRequest(int request_id, | |
701 const std::string& browser_id, | |
702 const std::string& url) { | |
703 remote_targets_handler_->SendJsonRequest(browser_id, url, | |
704 base::Bind(&DevToolsUIBindings::JsonReceived, | |
705 weak_factory_.GetWeakPtr(), | |
706 request_id)); | |
707 } | |
708 | |
709 void DevToolsUIBindings::JsonReceived(int request_id, | |
710 int result, | |
711 const std::string& message) { | |
712 base::FundamentalValue request_id_value(request_id); | |
713 if (result != net::OK) { | |
714 CallClientFunction("DevToolsAPI.embedderMessageAck", | |
715 &request_id_value, nullptr, nullptr); | |
716 return; | |
717 } | |
718 base::StringValue message_value(message); | |
719 CallClientFunction("DevToolsAPI.embedderMessageAck", | |
720 &request_id_value, &message_value, nullptr); | |
721 } | |
722 | |
692 void DevToolsUIBindings::DeviceCountChanged(int count) { | 723 void DevToolsUIBindings::DeviceCountChanged(int count) { |
693 base::FundamentalValue value(count); | 724 base::FundamentalValue value(count); |
694 CallClientFunction("DevToolsAPI.deviceCountUpdated", &value, NULL, | 725 CallClientFunction("DevToolsAPI.deviceCountUpdated", |
695 NULL); | 726 &value, nullptr, nullptr); |
696 } | 727 } |
697 | 728 |
698 void DevToolsUIBindings::DevicesUpdated( | 729 void DevToolsUIBindings::DevicesUpdated( |
699 const std::string& source, | 730 const std::string& source, |
700 const base::ListValue& targets) { | 731 const base::ListValue& targets) { |
701 CallClientFunction("DevToolsAPI.devicesUpdated", &targets, NULL, | 732 CallClientFunction("DevToolsAPI.devicesUpdated", &targets, nullptr, nullptr); |
702 NULL); | |
703 } | 733 } |
704 | 734 |
705 void DevToolsUIBindings::FileSavedAs(const std::string& url) { | 735 void DevToolsUIBindings::FileSavedAs(const std::string& url) { |
706 base::StringValue url_value(url); | 736 base::StringValue url_value(url); |
707 CallClientFunction("DevToolsAPI.savedURL", &url_value, NULL, NULL); | 737 CallClientFunction("DevToolsAPI.savedURL", &url_value, nullptr, nullptr); |
708 } | 738 } |
709 | 739 |
710 void DevToolsUIBindings::CanceledFileSaveAs(const std::string& url) { | 740 void DevToolsUIBindings::CanceledFileSaveAs(const std::string& url) { |
711 base::StringValue url_value(url); | 741 base::StringValue url_value(url); |
712 CallClientFunction("DevToolsAPI.canceledSaveURL", | 742 CallClientFunction("DevToolsAPI.canceledSaveURL", |
713 &url_value, NULL, NULL); | 743 &url_value, nullptr, nullptr); |
714 } | 744 } |
715 | 745 |
716 void DevToolsUIBindings::AppendedTo(const std::string& url) { | 746 void DevToolsUIBindings::AppendedTo(const std::string& url) { |
717 base::StringValue url_value(url); | 747 base::StringValue url_value(url); |
718 CallClientFunction("DevToolsAPI.appendedToURL", &url_value, NULL, | 748 CallClientFunction("DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr); |
719 NULL); | |
720 } | 749 } |
721 | 750 |
722 void DevToolsUIBindings::FileSystemsLoaded( | 751 void DevToolsUIBindings::FileSystemsLoaded( |
723 const std::vector<DevToolsFileHelper::FileSystem>& file_systems) { | 752 const std::vector<DevToolsFileHelper::FileSystem>& file_systems) { |
724 base::ListValue file_systems_value; | 753 base::ListValue file_systems_value; |
725 for (size_t i = 0; i < file_systems.size(); ++i) | 754 for (const DevToolsFileHelper::FileSystem& file_system : file_systems) { |
726 file_systems_value.Append(CreateFileSystemValue(file_systems[i])); | 755 file_systems_value.Append(CreateFileSystemValue(file_system)); |
756 } | |
727 CallClientFunction("DevToolsAPI.fileSystemsLoaded", | 757 CallClientFunction("DevToolsAPI.fileSystemsLoaded", |
728 &file_systems_value, NULL, NULL); | 758 &file_systems_value, nullptr, nullptr); |
729 } | 759 } |
730 | 760 |
731 void DevToolsUIBindings::FileSystemAdded( | 761 void DevToolsUIBindings::FileSystemAdded( |
732 const DevToolsFileHelper::FileSystem& file_system) { | 762 const DevToolsFileHelper::FileSystem& file_system) { |
733 scoped_ptr<base::StringValue> error_string_value( | 763 scoped_ptr<base::StringValue> error_string_value( |
734 new base::StringValue(std::string())); | 764 new base::StringValue(std::string())); |
735 scoped_ptr<base::DictionaryValue> file_system_value; | 765 scoped_ptr<base::DictionaryValue> file_system_value; |
736 if (!file_system.file_system_path.empty()) | 766 if (!file_system.file_system_path.empty()) |
737 file_system_value.reset(CreateFileSystemValue(file_system)); | 767 file_system_value.reset(CreateFileSystemValue(file_system)); |
738 CallClientFunction("DevToolsAPI.fileSystemAdded", | 768 CallClientFunction("DevToolsAPI.fileSystemAdded", error_string_value.get(), |
739 error_string_value.get(), file_system_value.get(), NULL); | 769 file_system_value.get(), nullptr); |
740 } | 770 } |
741 | 771 |
742 void DevToolsUIBindings::IndexingTotalWorkCalculated( | 772 void DevToolsUIBindings::IndexingTotalWorkCalculated( |
743 int request_id, | 773 int request_id, |
744 const std::string& file_system_path, | 774 const std::string& file_system_path, |
745 int total_work) { | 775 int total_work) { |
746 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 776 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
747 base::FundamentalValue request_id_value(request_id); | 777 base::FundamentalValue request_id_value(request_id); |
748 base::StringValue file_system_path_value(file_system_path); | 778 base::StringValue file_system_path_value(file_system_path); |
749 base::FundamentalValue total_work_value(total_work); | 779 base::FundamentalValue total_work_value(total_work); |
(...skipping 13 matching lines...) Expand all Loading... | |
763 &file_system_path_value, &worked_value); | 793 &file_system_path_value, &worked_value); |
764 } | 794 } |
765 | 795 |
766 void DevToolsUIBindings::IndexingDone(int request_id, | 796 void DevToolsUIBindings::IndexingDone(int request_id, |
767 const std::string& file_system_path) { | 797 const std::string& file_system_path) { |
768 indexing_jobs_.erase(request_id); | 798 indexing_jobs_.erase(request_id); |
769 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 799 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
770 base::FundamentalValue request_id_value(request_id); | 800 base::FundamentalValue request_id_value(request_id); |
771 base::StringValue file_system_path_value(file_system_path); | 801 base::StringValue file_system_path_value(file_system_path); |
772 CallClientFunction("DevToolsAPI.indexingDone", &request_id_value, | 802 CallClientFunction("DevToolsAPI.indexingDone", &request_id_value, |
773 &file_system_path_value, NULL); | 803 &file_system_path_value, nullptr); |
774 } | 804 } |
775 | 805 |
776 void DevToolsUIBindings::SearchCompleted( | 806 void DevToolsUIBindings::SearchCompleted( |
777 int request_id, | 807 int request_id, |
778 const std::string& file_system_path, | 808 const std::string& file_system_path, |
779 const std::vector<std::string>& file_paths) { | 809 const std::vector<std::string>& file_paths) { |
780 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 810 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
781 base::ListValue file_paths_value; | 811 base::ListValue file_paths_value; |
782 for (std::vector<std::string>::const_iterator it(file_paths.begin()); | 812 for (const std::string& file_path : file_paths) { |
783 it != file_paths.end(); ++it) { | 813 file_paths_value.AppendString(file_path); |
784 file_paths_value.AppendString(*it); | |
785 } | 814 } |
786 base::FundamentalValue request_id_value(request_id); | 815 base::FundamentalValue request_id_value(request_id); |
787 base::StringValue file_system_path_value(file_system_path); | 816 base::StringValue file_system_path_value(file_system_path); |
788 CallClientFunction("DevToolsAPI.searchCompleted", &request_id_value, | 817 CallClientFunction("DevToolsAPI.searchCompleted", &request_id_value, |
789 &file_system_path_value, &file_paths_value); | 818 &file_system_path_value, &file_paths_value); |
790 } | 819 } |
791 | 820 |
792 void DevToolsUIBindings::ShowDevToolsConfirmInfoBar( | 821 void DevToolsUIBindings::ShowDevToolsConfirmInfoBar( |
793 const base::string16& message, | 822 const base::string16& message, |
794 const InfoBarCallback& callback) { | 823 const InfoBarCallback& callback) { |
(...skipping 19 matching lines...) Expand all Loading... | |
814 if (!registry) | 843 if (!registry) |
815 return; | 844 return; |
816 | 845 |
817 base::ListValue results; | 846 base::ListValue results; |
818 for (const scoped_refptr<const extensions::Extension>& extension : | 847 for (const scoped_refptr<const extensions::Extension>& extension : |
819 registry->enabled_extensions()) { | 848 registry->enabled_extensions()) { |
820 if (extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) | 849 if (extensions::chrome_manifest_urls::GetDevToolsPage(extension.get()) |
821 .is_empty()) | 850 .is_empty()) |
822 continue; | 851 continue; |
823 base::DictionaryValue* extension_info = new base::DictionaryValue(); | 852 base::DictionaryValue* extension_info = new base::DictionaryValue(); |
824 extension_info->Set( | 853 extension_info->SetString("startPage", |
825 "startPage", | 854 extensions::chrome_manifest_urls::GetDevToolsPage( |
826 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage( | 855 extension.get()).spec()); |
827 extension.get()).spec())); | 856 extension_info->SetString("name", extension->name()); |
828 extension_info->Set("name", new base::StringValue(extension->name())); | 857 extension_info->SetBoolean("exposeExperimentalAPIs", |
829 extension_info->Set("exposeExperimentalAPIs", | 858 extension->permissions_data()->HasAPIPermission( |
830 new base::FundamentalValue( | 859 extensions::APIPermission::kExperimental)); |
831 extension->permissions_data()->HasAPIPermission( | |
832 extensions::APIPermission::kExperimental))); | |
833 results.Append(extension_info); | 860 results.Append(extension_info); |
834 } | 861 } |
835 CallClientFunction("DevToolsAPI.addExtensions", | 862 CallClientFunction("DevToolsAPI.addExtensions", &results, nullptr, nullptr); |
836 &results, NULL, NULL); | |
837 } | 863 } |
838 | 864 |
839 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { | 865 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { |
840 delegate_.reset(delegate); | 866 delegate_.reset(delegate); |
841 } | 867 } |
842 | 868 |
843 void DevToolsUIBindings::AttachTo( | 869 void DevToolsUIBindings::AttachTo( |
844 const scoped_refptr<content::DevToolsAgentHost>& agent_host) { | 870 const scoped_refptr<content::DevToolsAgentHost>& agent_host) { |
845 if (agent_host_.get()) | 871 if (agent_host_.get()) |
846 Detach(); | 872 Detach(); |
847 agent_host_ = agent_host; | 873 agent_host_ = agent_host; |
848 agent_host_->AttachClient(this); | 874 agent_host_->AttachClient(this); |
849 } | 875 } |
850 | 876 |
851 void DevToolsUIBindings::Reattach() { | 877 void DevToolsUIBindings::Reattach() { |
852 DCHECK(agent_host_.get()); | 878 DCHECK(agent_host_.get()); |
853 agent_host_->DetachClient(); | 879 agent_host_->DetachClient(); |
854 agent_host_->AttachClient(this); | 880 agent_host_->AttachClient(this); |
855 } | 881 } |
856 | 882 |
857 void DevToolsUIBindings::Detach() { | 883 void DevToolsUIBindings::Detach() { |
858 if (agent_host_.get()) | 884 if (agent_host_.get()) |
859 agent_host_->DetachClient(); | 885 agent_host_->DetachClient(); |
860 agent_host_ = NULL; | 886 agent_host_ = nullptr; |
861 } | 887 } |
862 | 888 |
863 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { | 889 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { |
864 return agent_host_.get() == agent_host; | 890 return agent_host_.get() == agent_host; |
865 } | 891 } |
866 | 892 |
867 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, | 893 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, |
868 const base::Value* arg1, | 894 const base::Value* arg1, |
869 const base::Value* arg2, | 895 const base::Value* arg2, |
870 const base::Value* arg3) { | 896 const base::Value* arg3) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
904 if (frontend_loaded_) | 930 if (frontend_loaded_) |
905 return; | 931 return; |
906 frontend_loaded_ = true; | 932 frontend_loaded_ = true; |
907 | 933 |
908 // Call delegate first - it seeds importants bit of information. | 934 // Call delegate first - it seeds importants bit of information. |
909 delegate_->OnLoadCompleted(); | 935 delegate_->OnLoadCompleted(); |
910 | 936 |
911 UpdateTheme(); | 937 UpdateTheme(); |
912 AddDevToolsExtensionsToClient(); | 938 AddDevToolsExtensionsToClient(); |
913 } | 939 } |
OLD | NEW |