OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/devtools/devtools_window.h" | 5 #include "chrome/browser/devtools/devtools_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/common/render_messages.h" | 32 #include "chrome/common/render_messages.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
34 #include "components/pref_registry/pref_registry_syncable.h" | 34 #include "components/pref_registry/pref_registry_syncable.h" |
35 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
36 #include "content/public/browser/devtools_agent_host.h" | 36 #include "content/public/browser/devtools_agent_host.h" |
37 #include "content/public/browser/devtools_client_host.h" | 37 #include "content/public/browser/devtools_client_host.h" |
38 #include "content/public/browser/devtools_manager.h" | 38 #include "content/public/browser/devtools_manager.h" |
39 #include "content/public/browser/native_web_keyboard_event.h" | 39 #include "content/public/browser/native_web_keyboard_event.h" |
40 #include "content/public/browser/navigation_controller.h" | 40 #include "content/public/browser/navigation_controller.h" |
41 #include "content/public/browser/navigation_entry.h" | 41 #include "content/public/browser/navigation_entry.h" |
42 #include "content/public/browser/notification_source.h" | |
43 #include "content/public/browser/render_frame_host.h" | 42 #include "content/public/browser/render_frame_host.h" |
44 #include "content/public/browser/render_process_host.h" | 43 #include "content/public/browser/render_process_host.h" |
45 #include "content/public/browser/render_view_host.h" | 44 #include "content/public/browser/render_view_host.h" |
46 #include "content/public/browser/render_widget_host_view.h" | 45 #include "content/public/browser/render_widget_host_view.h" |
47 #include "content/public/browser/user_metrics.h" | 46 #include "content/public/browser/user_metrics.h" |
48 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
49 #include "content/public/common/content_client.h" | 48 #include "content/public/common/content_client.h" |
50 #include "content/public/common/page_transition_types.h" | 49 #include "content/public/common/page_transition_types.h" |
51 #include "content/public/common/url_constants.h" | 50 #include "content/public/common/url_constants.h" |
52 #include "content/public/test/test_utils.h" | |
53 #include "third_party/WebKit/public/web/WebInputEvent.h" | 51 #include "third_party/WebKit/public/web/WebInputEvent.h" |
54 #include "ui/events/keycodes/keyboard_codes.h" | 52 #include "ui/events/keycodes/keyboard_codes.h" |
55 | 53 |
56 using base::DictionaryValue; | 54 using base::DictionaryValue; |
57 using blink::WebInputEvent; | 55 using blink::WebInputEvent; |
58 using content::BrowserThread; | 56 using content::BrowserThread; |
59 using content::DevToolsAgentHost; | 57 using content::DevToolsAgentHost; |
60 using content::WebContents; | 58 using content::WebContents; |
61 | 59 |
62 namespace { | 60 namespace { |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 UpdateBrowserToolbar(); | 309 UpdateBrowserToolbar(); |
312 | 310 |
313 if (toolbox_web_contents_) | 311 if (toolbox_web_contents_) |
314 delete toolbox_web_contents_; | 312 delete toolbox_web_contents_; |
315 | 313 |
316 DevToolsWindows* instances = g_instances.Pointer(); | 314 DevToolsWindows* instances = g_instances.Pointer(); |
317 DevToolsWindows::iterator it( | 315 DevToolsWindows::iterator it( |
318 std::find(instances->begin(), instances->end(), this)); | 316 std::find(instances->begin(), instances->end(), this)); |
319 DCHECK(it != instances->end()); | 317 DCHECK(it != instances->end()); |
320 instances->erase(it); | 318 instances->erase(it); |
| 319 |
| 320 if (!close_callback_.is_null()) { |
| 321 close_callback_.Run(); |
| 322 close_callback_ = base::Closure(); |
| 323 } |
321 } | 324 } |
322 | 325 |
323 // static | 326 // static |
324 std::string DevToolsWindow::GetDevToolsWindowPlacementPrefKey() { | 327 std::string DevToolsWindow::GetDevToolsWindowPlacementPrefKey() { |
325 return std::string(prefs::kBrowserWindowPlacement) + "_" + | 328 return std::string(prefs::kBrowserWindowPlacement) + "_" + |
326 std::string(kDevToolsApp); | 329 std::string(kDevToolsApp); |
327 } | 330 } |
328 | 331 |
329 // static | 332 // static |
330 void DevToolsWindow::RegisterProfilePrefs( | 333 void DevToolsWindow::RegisterProfilePrefs( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 for (DevToolsWindows::iterator it(instances->begin()); it != instances->end(); | 399 for (DevToolsWindows::iterator it(instances->begin()); it != instances->end(); |
397 ++it) { | 400 ++it) { |
398 if ((*it)->GetInspectedWebContents() == inspected_web_contents) | 401 if ((*it)->GetInspectedWebContents() == inspected_web_contents) |
399 return *it; | 402 return *it; |
400 } | 403 } |
401 return NULL; | 404 return NULL; |
402 } | 405 } |
403 | 406 |
404 // static | 407 // static |
405 bool DevToolsWindow::IsDevToolsWindow(content::WebContents* web_contents) { | 408 bool DevToolsWindow::IsDevToolsWindow(content::WebContents* web_contents) { |
406 return AsDevToolsWindow(web_contents) != NULL; | 409 if (!web_contents || g_instances == NULL) |
| 410 return false; |
| 411 DevToolsWindows* instances = g_instances.Pointer(); |
| 412 for (DevToolsWindows::iterator it(instances->begin()); it != instances->end(); |
| 413 ++it) { |
| 414 if ((*it)->main_web_contents_ == web_contents || |
| 415 (*it)->toolbox_web_contents_ == web_contents) |
| 416 return true; |
| 417 } |
| 418 return false; |
407 } | 419 } |
408 | 420 |
409 // static | 421 // static |
410 DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker( | 422 DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker( |
411 Profile* profile, | 423 Profile* profile, |
412 DevToolsAgentHost* worker_agent) { | 424 DevToolsAgentHost* worker_agent) { |
413 DevToolsWindow* window = FindDevToolsWindow(worker_agent); | 425 DevToolsWindow* window = FindDevToolsWindow(worker_agent); |
414 if (!window) { | 426 if (!window) { |
415 window = DevToolsWindow::CreateDevToolsWindowForWorker(profile); | 427 window = DevToolsWindow::CreateDevToolsWindowForWorker(profile); |
416 // Will disconnect the current client host if there is one. | 428 // Will disconnect the current client host if there is one. |
417 content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( | 429 content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
418 worker_agent, window->bindings_->frontend_host()); | 430 worker_agent, window->bindings_->frontend_host()); |
419 } | 431 } |
420 window->ScheduleShow(DevToolsToggleAction::Show()); | 432 window->ScheduleShow(DevToolsToggleAction::Show()); |
421 return window; | 433 return window; |
422 } | 434 } |
423 | 435 |
424 // static | 436 // static |
425 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( | 437 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( |
426 Profile* profile) { | 438 Profile* profile) { |
427 content::RecordAction(base::UserMetricsAction("DevTools_InspectWorker")); | 439 content::RecordAction(base::UserMetricsAction("DevTools_InspectWorker")); |
428 return Create(profile, GURL(), NULL, true, false, false); | 440 return Create(profile, GURL(), NULL, true, false, false, ""); |
429 } | 441 } |
430 | 442 |
431 // static | 443 // static |
432 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( | 444 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( |
433 content::RenderViewHost* inspected_rvh) { | 445 content::RenderViewHost* inspected_rvh) { |
434 return ToggleDevToolsWindow( | 446 return ToggleDevToolsWindow( |
435 inspected_rvh, true, DevToolsToggleAction::Show()); | 447 inspected_rvh, true, DevToolsToggleAction::Show(), ""); |
436 } | 448 } |
437 | 449 |
438 // static | 450 // static |
439 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( | 451 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( |
440 content::RenderViewHost* inspected_rvh, | 452 content::RenderViewHost* inspected_rvh, |
441 const DevToolsToggleAction& action) { | 453 const DevToolsToggleAction& action) { |
442 return ToggleDevToolsWindow( | 454 return ToggleDevToolsWindow(inspected_rvh, true, action, ""); |
443 inspected_rvh, true, action); | |
444 } | 455 } |
445 | 456 |
446 // static | 457 // static |
447 DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForTest( | |
448 content::RenderViewHost* inspected_rvh, | |
449 bool is_docked) { | |
450 DevToolsWindow* window = OpenDevToolsWindow(inspected_rvh); | |
451 window->SetIsDockedAndShowImmediatelyForTest(is_docked); | |
452 return window; | |
453 } | |
454 | |
455 // static | |
456 DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForTest( | |
457 Browser* browser, | |
458 bool is_docked) { | |
459 return OpenDevToolsWindowForTest( | |
460 browser->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), | |
461 is_docked); | |
462 } | |
463 | |
464 // static | |
465 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( | 458 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( |
466 Browser* browser, | 459 Browser* browser, |
467 const DevToolsToggleAction& action) { | 460 const DevToolsToggleAction& action) { |
468 if (action.type() == DevToolsToggleAction::kToggle && | 461 if (action.type() == DevToolsToggleAction::kToggle && |
469 browser->is_devtools()) { | 462 browser->is_devtools()) { |
470 browser->tab_strip_model()->CloseAllTabs(); | 463 browser->tab_strip_model()->CloseAllTabs(); |
471 return NULL; | 464 return NULL; |
472 } | 465 } |
473 | 466 |
474 return ToggleDevToolsWindow( | 467 return ToggleDevToolsWindow( |
475 browser->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), | 468 browser->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), |
476 action.type() == DevToolsToggleAction::kInspect, action); | 469 action.type() == DevToolsToggleAction::kInspect, action, ""); |
477 } | 470 } |
478 | 471 |
479 // static | 472 // static |
480 void DevToolsWindow::OpenExternalFrontend( | 473 void DevToolsWindow::OpenExternalFrontend( |
481 Profile* profile, | 474 Profile* profile, |
482 const std::string& frontend_url, | 475 const std::string& frontend_url, |
483 content::DevToolsAgentHost* agent_host) { | 476 content::DevToolsAgentHost* agent_host) { |
484 DevToolsWindow* window = FindDevToolsWindow(agent_host); | 477 DevToolsWindow* window = FindDevToolsWindow(agent_host); |
485 if (!window) { | 478 if (!window) { |
486 window = Create(profile, DevToolsUI::GetProxyURL(frontend_url), NULL, | 479 window = Create(profile, DevToolsUI::GetProxyURL(frontend_url), NULL, |
487 false, true, false); | 480 false, true, false, ""); |
488 content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( | 481 content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
489 agent_host, window->bindings_->frontend_host()); | 482 agent_host, window->bindings_->frontend_host()); |
490 } | 483 } |
491 window->ScheduleShow(DevToolsToggleAction::Show()); | 484 window->ScheduleShow(DevToolsToggleAction::Show()); |
492 } | 485 } |
493 | 486 |
494 // static | 487 // static |
495 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( | 488 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( |
496 content::RenderViewHost* inspected_rvh, | 489 content::RenderViewHost* inspected_rvh, |
497 bool force_open, | 490 bool force_open, |
498 const DevToolsToggleAction& action) { | 491 const DevToolsToggleAction& action, |
| 492 const std::string& settings) { |
499 scoped_refptr<DevToolsAgentHost> agent( | 493 scoped_refptr<DevToolsAgentHost> agent( |
500 DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); | 494 DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); |
501 content::DevToolsManager* manager = content::DevToolsManager::GetInstance(); | 495 content::DevToolsManager* manager = content::DevToolsManager::GetInstance(); |
502 DevToolsWindow* window = FindDevToolsWindow(agent.get()); | 496 DevToolsWindow* window = FindDevToolsWindow(agent.get()); |
503 bool do_open = force_open; | 497 bool do_open = force_open; |
504 if (!window) { | 498 if (!window) { |
505 Profile* profile = Profile::FromBrowserContext( | 499 Profile* profile = Profile::FromBrowserContext( |
506 inspected_rvh->GetProcess()->GetBrowserContext()); | 500 inspected_rvh->GetProcess()->GetBrowserContext()); |
507 content::RecordAction( | 501 content::RecordAction( |
508 base::UserMetricsAction("DevTools_InspectRenderer")); | 502 base::UserMetricsAction("DevTools_InspectRenderer")); |
509 window = Create(profile, GURL(), inspected_rvh, false, false, true); | 503 window = Create( |
| 504 profile, GURL(), inspected_rvh, false, false, true, settings); |
510 manager->RegisterDevToolsClientHostFor(agent.get(), | 505 manager->RegisterDevToolsClientHostFor(agent.get(), |
511 window->bindings_->frontend_host()); | 506 window->bindings_->frontend_host()); |
512 do_open = true; | 507 do_open = true; |
513 } | 508 } |
514 | 509 |
515 // Update toolbar to reflect DevTools changes. | 510 // Update toolbar to reflect DevTools changes. |
516 window->UpdateBrowserToolbar(); | 511 window->UpdateBrowserToolbar(); |
517 | 512 |
518 // If window is docked and visible, we hide it on toggle. If window is | 513 // If window is docked and visible, we hide it on toggle. If window is |
519 // undocked, we show (activate) it. | 514 // undocked, we show (activate) it. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 toolbox_web_contents_(NULL), | 688 toolbox_web_contents_(NULL), |
694 bindings_(NULL), | 689 bindings_(NULL), |
695 browser_(NULL), | 690 browser_(NULL), |
696 is_docked_(true), | 691 is_docked_(true), |
697 can_dock_(can_dock), | 692 can_dock_(can_dock), |
698 // This initialization allows external front-end to work without changes. | 693 // This initialization allows external front-end to work without changes. |
699 // We don't wait for docking call, but instead immediately show undocked. | 694 // We don't wait for docking call, but instead immediately show undocked. |
700 // Passing "dockSide=undocked" parameter ensures proper UI. | 695 // Passing "dockSide=undocked" parameter ensures proper UI. |
701 life_stage_(can_dock ? kNotLoaded : kIsDockedSet), | 696 life_stage_(can_dock ? kNotLoaded : kIsDockedSet), |
702 action_on_load_(DevToolsToggleAction::NoOp()), | 697 action_on_load_(DevToolsToggleAction::NoOp()), |
703 ignore_set_is_docked_(false), | |
704 intercepted_page_beforeunload_(false) { | 698 intercepted_page_beforeunload_(false) { |
705 // Set up delegate, so we get fully-functional window immediately. | 699 // Set up delegate, so we get fully-functional window immediately. |
706 // It will not appear in UI though until |life_stage_ == kLoadCompleted|. | 700 // It will not appear in UI though until |life_stage_ == kLoadCompleted|. |
707 main_web_contents_->SetDelegate(this); | 701 main_web_contents_->SetDelegate(this); |
708 bindings_ = new DevToolsUIBindings( | 702 bindings_ = new DevToolsUIBindings( |
709 main_web_contents_, | 703 main_web_contents_, |
710 DevToolsUIBindings::ApplyThemeToURL(profile, url)); | 704 DevToolsUIBindings::ApplyThemeToURL(profile, url)); |
711 // Bindings take ownership over devtools as its delegate. | 705 // Bindings take ownership over devtools as its delegate. |
712 bindings_->SetDelegate(this); | 706 bindings_->SetDelegate(this); |
713 // DevTools uses chrome_page_zoom::Zoom(), so main_web_contents_ requires a | 707 // DevTools uses chrome_page_zoom::Zoom(), so main_web_contents_ requires a |
(...skipping 11 matching lines...) Expand all Loading... |
725 event_forwarder_.reset(new DevToolsEventForwarder(this)); | 719 event_forwarder_.reset(new DevToolsEventForwarder(this)); |
726 } | 720 } |
727 | 721 |
728 // static | 722 // static |
729 DevToolsWindow* DevToolsWindow::Create( | 723 DevToolsWindow* DevToolsWindow::Create( |
730 Profile* profile, | 724 Profile* profile, |
731 const GURL& frontend_url, | 725 const GURL& frontend_url, |
732 content::RenderViewHost* inspected_rvh, | 726 content::RenderViewHost* inspected_rvh, |
733 bool shared_worker_frontend, | 727 bool shared_worker_frontend, |
734 bool external_frontend, | 728 bool external_frontend, |
735 bool can_dock) { | 729 bool can_dock, |
| 730 const std::string& settings) { |
736 if (inspected_rvh) { | 731 if (inspected_rvh) { |
737 // Check for a place to dock. | 732 // Check for a place to dock. |
738 Browser* browser = NULL; | 733 Browser* browser = NULL; |
739 int tab; | 734 int tab; |
740 WebContents* inspected_web_contents = | 735 WebContents* inspected_web_contents = |
741 content::WebContents::FromRenderViewHost(inspected_rvh); | 736 content::WebContents::FromRenderViewHost(inspected_rvh); |
742 if (!FindInspectedBrowserAndTabIndex(inspected_web_contents, | 737 if (!FindInspectedBrowserAndTabIndex(inspected_web_contents, |
743 &browser, &tab) || | 738 &browser, &tab) || |
744 inspected_rvh->GetMainFrame()->IsCrossProcessSubframe() || | 739 inspected_rvh->GetMainFrame()->IsCrossProcessSubframe() || |
745 browser->is_type_popup()) { | 740 browser->is_type_popup()) { |
746 can_dock = false; | 741 can_dock = false; |
747 } | 742 } |
748 } | 743 } |
749 | 744 |
750 // Create WebContents with devtools. | 745 // Create WebContents with devtools. |
751 GURL url(GetDevToolsURL(profile, frontend_url, | 746 GURL url(GetDevToolsURL(profile, frontend_url, |
752 shared_worker_frontend, | 747 shared_worker_frontend, |
753 external_frontend, | 748 external_frontend, |
754 can_dock)); | 749 can_dock, settings)); |
755 return new DevToolsWindow(profile, url, inspected_rvh, can_dock); | 750 return new DevToolsWindow(profile, url, inspected_rvh, can_dock); |
756 } | 751 } |
757 | 752 |
758 // static | 753 // static |
759 GURL DevToolsWindow::GetDevToolsURL(Profile* profile, | 754 GURL DevToolsWindow::GetDevToolsURL(Profile* profile, |
760 const GURL& base_url, | 755 const GURL& base_url, |
761 bool shared_worker_frontend, | 756 bool shared_worker_frontend, |
762 bool external_frontend, | 757 bool external_frontend, |
763 bool can_dock) { | 758 bool can_dock, |
| 759 const std::string& settings) { |
764 // Compatibility errors are encoded with data urls, pass them | 760 // Compatibility errors are encoded with data urls, pass them |
765 // through with no decoration. | 761 // through with no decoration. |
766 if (base_url.SchemeIs("data")) | 762 if (base_url.SchemeIs("data")) |
767 return base_url; | 763 return base_url; |
768 | 764 |
769 std::string frontend_url( | 765 std::string frontend_url( |
770 base_url.is_empty() ? chrome::kChromeUIDevToolsURL : base_url.spec()); | 766 base_url.is_empty() ? chrome::kChromeUIDevToolsURL : base_url.spec()); |
771 std::string url_string( | 767 std::string url_string( |
772 frontend_url + | 768 frontend_url + |
773 ((frontend_url.find("?") == std::string::npos) ? "?" : "&")); | 769 ((frontend_url.find("?") == std::string::npos) ? "?" : "&")); |
774 if (shared_worker_frontend) | 770 if (shared_worker_frontend) |
775 url_string += "&isSharedWorker=true"; | 771 url_string += "&isSharedWorker=true"; |
776 if (external_frontend) | 772 if (external_frontend) |
777 url_string += "&remoteFrontend=true"; | 773 url_string += "&remoteFrontend=true"; |
778 if (can_dock) | 774 if (can_dock) |
779 url_string += "&can_dock=true"; | 775 url_string += "&can_dock=true"; |
| 776 if (settings.size()) |
| 777 url_string += "&settings=" + settings; |
780 return GURL(url_string); | 778 return GURL(url_string); |
781 } | 779 } |
782 | 780 |
783 // static | 781 // static |
784 DevToolsWindow* DevToolsWindow::FindDevToolsWindow( | 782 DevToolsWindow* DevToolsWindow::FindDevToolsWindow( |
785 DevToolsAgentHost* agent_host) { | 783 DevToolsAgentHost* agent_host) { |
786 if (!agent_host || g_instances == NULL) | 784 if (!agent_host || g_instances == NULL) |
787 return NULL; | 785 return NULL; |
788 DevToolsWindows* instances = g_instances.Pointer(); | 786 DevToolsWindows* instances = g_instances.Pointer(); |
789 content::DevToolsManager* manager = content::DevToolsManager::GetInstance(); | 787 content::DevToolsManager* manager = content::DevToolsManager::GetInstance(); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 } | 1021 } |
1024 | 1022 |
1025 void DevToolsWindow::MoveWindow(int x, int y) { | 1023 void DevToolsWindow::MoveWindow(int x, int y) { |
1026 if (!is_docked_) { | 1024 if (!is_docked_) { |
1027 gfx::Rect bounds = browser_->window()->GetBounds(); | 1025 gfx::Rect bounds = browser_->window()->GetBounds(); |
1028 bounds.Offset(x, y); | 1026 bounds.Offset(x, y); |
1029 browser_->window()->SetBounds(bounds); | 1027 browser_->window()->SetBounds(bounds); |
1030 } | 1028 } |
1031 } | 1029 } |
1032 | 1030 |
1033 void DevToolsWindow::SetIsDockedAndShowImmediatelyForTest(bool is_docked) { | |
1034 DCHECK(!is_docked || can_dock_); | |
1035 DCHECK(life_stage_ != kClosing); | |
1036 if (life_stage_ == kLoadCompleted) { | |
1037 SetIsDocked(is_docked); | |
1038 } else { | |
1039 is_docked_ = is_docked; | |
1040 // Load is completed when both kIsDockedSet and kOnLoadFired happened. | |
1041 // Note that kIsDockedSet may be already set when can_dock_ is false. | |
1042 life_stage_ = life_stage_ == kOnLoadFired ? kLoadCompleted : kIsDockedSet; | |
1043 // Note that action_on_load_ will be performed after the load is actually | |
1044 // completed. For now, just show the window. | |
1045 Show(DevToolsToggleAction::Show()); | |
1046 if (life_stage_ == kLoadCompleted) | |
1047 LoadCompleted(); | |
1048 } | |
1049 ignore_set_is_docked_ = true; | |
1050 } | |
1051 | |
1052 void DevToolsWindow::SetIsDocked(bool dock_requested) { | 1031 void DevToolsWindow::SetIsDocked(bool dock_requested) { |
1053 if (ignore_set_is_docked_ || life_stage_ == kClosing) | 1032 if (life_stage_ == kClosing) |
1054 return; | 1033 return; |
1055 | 1034 |
1056 DCHECK(can_dock_ || !dock_requested); | 1035 DCHECK(can_dock_ || !dock_requested); |
1057 if (!can_dock_) | 1036 if (!can_dock_) |
1058 dock_requested = false; | 1037 dock_requested = false; |
1059 | 1038 |
1060 bool was_docked = is_docked_; | 1039 bool was_docked = is_docked_; |
1061 is_docked_ = dock_requested; | 1040 is_docked_ = dock_requested; |
1062 | 1041 |
1063 if (life_stage_ != kLoadCompleted) { | 1042 if (life_stage_ != kLoadCompleted) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 void DevToolsWindow::LoadCompleted() { | 1233 void DevToolsWindow::LoadCompleted() { |
1255 Show(action_on_load_); | 1234 Show(action_on_load_); |
1256 action_on_load_ = DevToolsToggleAction::NoOp(); | 1235 action_on_load_ = DevToolsToggleAction::NoOp(); |
1257 if (!load_completed_callback_.is_null()) { | 1236 if (!load_completed_callback_.is_null()) { |
1258 load_completed_callback_.Run(); | 1237 load_completed_callback_.Run(); |
1259 load_completed_callback_ = base::Closure(); | 1238 load_completed_callback_ = base::Closure(); |
1260 } | 1239 } |
1261 } | 1240 } |
1262 | 1241 |
1263 void DevToolsWindow::SetLoadCompletedCallback(const base::Closure& closure) { | 1242 void DevToolsWindow::SetLoadCompletedCallback(const base::Closure& closure) { |
1264 if (life_stage_ == kLoadCompleted) { | 1243 if (life_stage_ == kLoadCompleted || life_stage_ == kClosing) { |
1265 if (!closure.is_null()) | 1244 if (!closure.is_null()) |
1266 closure.Run(); | 1245 closure.Run(); |
1267 return; | 1246 return; |
1268 } | 1247 } |
1269 load_completed_callback_ = closure; | 1248 load_completed_callback_ = closure; |
1270 } | 1249 } |
1271 | 1250 |
1272 bool DevToolsWindow::ForwardKeyboardEvent( | 1251 bool DevToolsWindow::ForwardKeyboardEvent( |
1273 const content::NativeWebKeyboardEvent& event) { | 1252 const content::NativeWebKeyboardEvent& event) { |
1274 return event_forwarder_->ForwardEvent(event); | 1253 return event_forwarder_->ForwardEvent(event); |
1275 } | 1254 } |
OLD | NEW |