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 23 matching lines...) Expand all Loading... |
737 event_forwarder_.reset(new DevToolsEventForwarder(this)); | 731 event_forwarder_.reset(new DevToolsEventForwarder(this)); |
738 } | 732 } |
739 | 733 |
740 // static | 734 // static |
741 DevToolsWindow* DevToolsWindow::Create( | 735 DevToolsWindow* DevToolsWindow::Create( |
742 Profile* profile, | 736 Profile* profile, |
743 const GURL& frontend_url, | 737 const GURL& frontend_url, |
744 content::RenderViewHost* inspected_rvh, | 738 content::RenderViewHost* inspected_rvh, |
745 bool shared_worker_frontend, | 739 bool shared_worker_frontend, |
746 bool external_frontend, | 740 bool external_frontend, |
747 bool can_dock) { | 741 bool can_dock, |
| 742 const std::string& settings) { |
748 if (inspected_rvh) { | 743 if (inspected_rvh) { |
749 // Check for a place to dock. | 744 // Check for a place to dock. |
750 Browser* browser = NULL; | 745 Browser* browser = NULL; |
751 int tab; | 746 int tab; |
752 WebContents* inspected_web_contents = | 747 WebContents* inspected_web_contents = |
753 content::WebContents::FromRenderViewHost(inspected_rvh); | 748 content::WebContents::FromRenderViewHost(inspected_rvh); |
754 if (!FindInspectedBrowserAndTabIndex(inspected_web_contents, | 749 if (!FindInspectedBrowserAndTabIndex(inspected_web_contents, |
755 &browser, &tab) || | 750 &browser, &tab) || |
756 inspected_rvh->GetMainFrame()->IsCrossProcessSubframe() || | 751 inspected_rvh->GetMainFrame()->IsCrossProcessSubframe() || |
757 browser->is_type_popup()) { | 752 browser->is_type_popup()) { |
758 can_dock = false; | 753 can_dock = false; |
759 } | 754 } |
760 } | 755 } |
761 | 756 |
762 // Create WebContents with devtools. | 757 // Create WebContents with devtools. |
763 GURL url(GetDevToolsURL(profile, frontend_url, | 758 GURL url(GetDevToolsURL(profile, frontend_url, |
764 shared_worker_frontend, | 759 shared_worker_frontend, |
765 external_frontend, | 760 external_frontend, |
766 can_dock)); | 761 can_dock, settings)); |
767 return new DevToolsWindow(profile, url, inspected_rvh, can_dock); | 762 return new DevToolsWindow(profile, url, inspected_rvh, can_dock); |
768 } | 763 } |
769 | 764 |
770 // static | 765 // static |
771 GURL DevToolsWindow::GetDevToolsURL(Profile* profile, | 766 GURL DevToolsWindow::GetDevToolsURL(Profile* profile, |
772 const GURL& base_url, | 767 const GURL& base_url, |
773 bool shared_worker_frontend, | 768 bool shared_worker_frontend, |
774 bool external_frontend, | 769 bool external_frontend, |
775 bool can_dock) { | 770 bool can_dock, |
| 771 const std::string& settings) { |
776 // Compatibility errors are encoded with data urls, pass them | 772 // Compatibility errors are encoded with data urls, pass them |
777 // through with no decoration. | 773 // through with no decoration. |
778 if (base_url.SchemeIs("data")) | 774 if (base_url.SchemeIs("data")) |
779 return base_url; | 775 return base_url; |
780 | 776 |
781 std::string frontend_url( | 777 std::string frontend_url( |
782 base_url.is_empty() ? chrome::kChromeUIDevToolsURL : base_url.spec()); | 778 base_url.is_empty() ? chrome::kChromeUIDevToolsURL : base_url.spec()); |
783 std::string url_string( | 779 std::string url_string( |
784 frontend_url + | 780 frontend_url + |
785 ((frontend_url.find("?") == std::string::npos) ? "?" : "&")); | 781 ((frontend_url.find("?") == std::string::npos) ? "?" : "&")); |
786 if (shared_worker_frontend) | 782 if (shared_worker_frontend) |
787 url_string += "&isSharedWorker=true"; | 783 url_string += "&isSharedWorker=true"; |
788 if (external_frontend) | 784 if (external_frontend) |
789 url_string += "&remoteFrontend=true"; | 785 url_string += "&remoteFrontend=true"; |
790 if (can_dock) | 786 if (can_dock) |
791 url_string += "&can_dock=true"; | 787 url_string += "&can_dock=true"; |
| 788 if (settings.size()) |
| 789 url_string += "&settings=" + settings; |
792 return GURL(url_string); | 790 return GURL(url_string); |
793 } | 791 } |
794 | 792 |
795 // static | 793 // static |
796 DevToolsWindow* DevToolsWindow::FindDevToolsWindow( | 794 DevToolsWindow* DevToolsWindow::FindDevToolsWindow( |
797 DevToolsAgentHost* agent_host) { | 795 DevToolsAgentHost* agent_host) { |
798 if (!agent_host || g_instances == NULL) | 796 if (!agent_host || g_instances == NULL) |
799 return NULL; | 797 return NULL; |
800 DevToolsWindows* instances = g_instances.Pointer(); | 798 DevToolsWindows* instances = g_instances.Pointer(); |
801 content::DevToolsManager* manager = content::DevToolsManager::GetInstance(); | 799 content::DevToolsManager* manager = content::DevToolsManager::GetInstance(); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 1036 } |
1039 | 1037 |
1040 void DevToolsWindow::MoveWindow(int x, int y) { | 1038 void DevToolsWindow::MoveWindow(int x, int y) { |
1041 if (!is_docked_) { | 1039 if (!is_docked_) { |
1042 gfx::Rect bounds = browser_->window()->GetBounds(); | 1040 gfx::Rect bounds = browser_->window()->GetBounds(); |
1043 bounds.Offset(x, y); | 1041 bounds.Offset(x, y); |
1044 browser_->window()->SetBounds(bounds); | 1042 browser_->window()->SetBounds(bounds); |
1045 } | 1043 } |
1046 } | 1044 } |
1047 | 1045 |
1048 void DevToolsWindow::SetIsDockedAndShowImmediatelyForTest(bool is_docked) { | |
1049 DCHECK(!is_docked || can_dock_); | |
1050 DCHECK(life_stage_ != kClosing); | |
1051 if (life_stage_ == kLoadCompleted) { | |
1052 SetIsDocked(is_docked); | |
1053 } else { | |
1054 is_docked_ = is_docked; | |
1055 // Load is completed when both kIsDockedSet and kOnLoadFired happened. | |
1056 // Note that kIsDockedSet may be already set when can_dock_ is false. | |
1057 life_stage_ = life_stage_ == kOnLoadFired ? kLoadCompleted : kIsDockedSet; | |
1058 // Note that action_on_load_ will be performed after the load is actually | |
1059 // completed. For now, just show the window. | |
1060 Show(DevToolsToggleAction::Show()); | |
1061 if (life_stage_ == kLoadCompleted) | |
1062 LoadCompleted(); | |
1063 } | |
1064 ignore_set_is_docked_ = true; | |
1065 } | |
1066 | |
1067 void DevToolsWindow::SetIsDocked(bool dock_requested) { | 1046 void DevToolsWindow::SetIsDocked(bool dock_requested) { |
1068 if (ignore_set_is_docked_ || life_stage_ == kClosing) | 1047 if (life_stage_ == kClosing) |
1069 return; | 1048 return; |
1070 | 1049 |
1071 DCHECK(can_dock_ || !dock_requested); | 1050 DCHECK(can_dock_ || !dock_requested); |
1072 if (!can_dock_) | 1051 if (!can_dock_) |
1073 dock_requested = false; | 1052 dock_requested = false; |
1074 | 1053 |
1075 bool was_docked = is_docked_; | 1054 bool was_docked = is_docked_; |
1076 is_docked_ = dock_requested; | 1055 is_docked_ = dock_requested; |
1077 | 1056 |
1078 if (life_stage_ != kLoadCompleted) { | 1057 if (life_stage_ != kLoadCompleted) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 void DevToolsWindow::LoadCompleted() { | 1248 void DevToolsWindow::LoadCompleted() { |
1270 Show(action_on_load_); | 1249 Show(action_on_load_); |
1271 action_on_load_ = DevToolsToggleAction::NoOp(); | 1250 action_on_load_ = DevToolsToggleAction::NoOp(); |
1272 if (!load_completed_callback_.is_null()) { | 1251 if (!load_completed_callback_.is_null()) { |
1273 load_completed_callback_.Run(); | 1252 load_completed_callback_.Run(); |
1274 load_completed_callback_ = base::Closure(); | 1253 load_completed_callback_ = base::Closure(); |
1275 } | 1254 } |
1276 } | 1255 } |
1277 | 1256 |
1278 void DevToolsWindow::SetLoadCompletedCallback(const base::Closure& closure) { | 1257 void DevToolsWindow::SetLoadCompletedCallback(const base::Closure& closure) { |
1279 if (life_stage_ == kLoadCompleted) { | 1258 if (life_stage_ == kLoadCompleted || life_stage_ == kClosing) { |
1280 if (!closure.is_null()) | 1259 if (!closure.is_null()) |
1281 closure.Run(); | 1260 closure.Run(); |
1282 return; | 1261 return; |
1283 } | 1262 } |
1284 load_completed_callback_ = closure; | 1263 load_completed_callback_ = closure; |
1285 } | 1264 } |
1286 | 1265 |
1287 bool DevToolsWindow::ForwardKeyboardEvent( | 1266 bool DevToolsWindow::ForwardKeyboardEvent( |
1288 const content::NativeWebKeyboardEvent& event) { | 1267 const content::NativeWebKeyboardEvent& event) { |
1289 return event_forwarder_->ForwardEvent(event); | 1268 return event_forwarder_->ForwardEvent(event); |
1290 } | 1269 } |
OLD | NEW |