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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 ZoomController::CreateForWebContents(main_web_contents_); | 715 ZoomController::CreateForWebContents(main_web_contents_); |
716 ZoomController::FromWebContents(main_web_contents_) | 716 ZoomController::FromWebContents(main_web_contents_) |
717 ->SetShowsNotificationBubble(false); | 717 ->SetShowsNotificationBubble(false); |
718 | 718 |
719 g_instances.Get().push_back(this); | 719 g_instances.Get().push_back(this); |
720 | 720 |
721 // There is no inspected_rvh in case of shared workers. | 721 // There is no inspected_rvh in case of shared workers. |
722 if (inspected_rvh) | 722 if (inspected_rvh) |
723 inspected_contents_observer_.reset(new ObserverWithAccessor( | 723 inspected_contents_observer_.reset(new ObserverWithAccessor( |
724 content::WebContents::FromRenderViewHost(inspected_rvh))); | 724 content::WebContents::FromRenderViewHost(inspected_rvh))); |
| 725 |
| 726 // Initialize docked page to be of the right size. |
| 727 WebContents* inspected_web_contents = GetInspectedWebContents(); |
| 728 if (can_dock_ && inspected_web_contents) { |
| 729 content::RenderWidgetHostView* inspected_view = |
| 730 inspected_web_contents->GetRenderWidgetHostView(); |
| 731 if (inspected_view && main_web_contents_->GetRenderWidgetHostView()) { |
| 732 gfx::Size size = inspected_view->GetViewBounds().size(); |
| 733 main_web_contents_->GetRenderWidgetHostView()->SetSize(size); |
| 734 } |
| 735 } |
| 736 |
725 event_forwarder_.reset(new DevToolsEventForwarder(this)); | 737 event_forwarder_.reset(new DevToolsEventForwarder(this)); |
726 } | 738 } |
727 | 739 |
728 // static | 740 // static |
729 DevToolsWindow* DevToolsWindow::Create( | 741 DevToolsWindow* DevToolsWindow::Create( |
730 Profile* profile, | 742 Profile* profile, |
731 const GURL& frontend_url, | 743 const GURL& frontend_url, |
732 content::RenderViewHost* inspected_rvh, | 744 content::RenderViewHost* inspected_rvh, |
733 bool shared_worker_frontend, | 745 bool shared_worker_frontend, |
734 bool external_frontend, | 746 bool external_frontend, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 void DevToolsWindow::AddNewContents(WebContents* source, | 858 void DevToolsWindow::AddNewContents(WebContents* source, |
847 WebContents* new_contents, | 859 WebContents* new_contents, |
848 WindowOpenDisposition disposition, | 860 WindowOpenDisposition disposition, |
849 const gfx::Rect& initial_pos, | 861 const gfx::Rect& initial_pos, |
850 bool user_gesture, | 862 bool user_gesture, |
851 bool* was_blocked) { | 863 bool* was_blocked) { |
852 if (new_contents == toolbox_web_contents_) { | 864 if (new_contents == toolbox_web_contents_) { |
853 toolbox_web_contents_->SetDelegate( | 865 toolbox_web_contents_->SetDelegate( |
854 new DevToolsToolboxDelegate(toolbox_web_contents_, | 866 new DevToolsToolboxDelegate(toolbox_web_contents_, |
855 inspected_contents_observer_.get())); | 867 inspected_contents_observer_.get())); |
856 gfx::Size size = main_web_contents_->GetViewBounds().size(); | 868 if (main_web_contents_->GetRenderWidgetHostView() && |
857 if (toolbox_web_contents_->GetRenderWidgetHostView()) | 869 toolbox_web_contents_->GetRenderWidgetHostView()) { |
| 870 gfx::Size size = |
| 871 main_web_contents_->GetRenderWidgetHostView()->GetViewBounds().size(); |
858 toolbox_web_contents_->GetRenderWidgetHostView()->SetSize(size); | 872 toolbox_web_contents_->GetRenderWidgetHostView()->SetSize(size); |
| 873 } |
859 UpdateBrowserWindow(); | 874 UpdateBrowserWindow(); |
860 return; | 875 return; |
861 } | 876 } |
862 | 877 |
863 WebContents* inspected_web_contents = GetInspectedWebContents(); | 878 WebContents* inspected_web_contents = GetInspectedWebContents(); |
864 if (inspected_web_contents) { | 879 if (inspected_web_contents) { |
865 inspected_web_contents->GetDelegate()->AddNewContents( | 880 inspected_web_contents->GetDelegate()->AddNewContents( |
866 source, new_contents, disposition, initial_pos, user_gesture, | 881 source, new_contents, disposition, initial_pos, user_gesture, |
867 was_blocked); | 882 was_blocked); |
868 } | 883 } |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 closure.Run(); | 1281 closure.Run(); |
1267 return; | 1282 return; |
1268 } | 1283 } |
1269 load_completed_callback_ = closure; | 1284 load_completed_callback_ = closure; |
1270 } | 1285 } |
1271 | 1286 |
1272 bool DevToolsWindow::ForwardKeyboardEvent( | 1287 bool DevToolsWindow::ForwardKeyboardEvent( |
1273 const content::NativeWebKeyboardEvent& event) { | 1288 const content::NativeWebKeyboardEvent& event) { |
1274 return event_forwarder_->ForwardEvent(event); | 1289 return event_forwarder_->ForwardEvent(event); |
1275 } | 1290 } |
OLD | NEW |