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