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 "content/shell/shell.h" | 5 #include "content/shell/shell.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "content/public/browser/web_contents_view.h" | 24 #include "content/public/browser/web_contents_view.h" |
25 #include "content/shell/shell_browser_main_parts.h" | 25 #include "content/shell/shell_browser_main_parts.h" |
26 #include "content/shell/shell_content_browser_client.h" | 26 #include "content/shell/shell_content_browser_client.h" |
27 #include "content/shell/shell_devtools_delegate.h" | 27 #include "content/shell/shell_devtools_delegate.h" |
28 #include "content/shell/shell_javascript_dialog_creator.h" | 28 #include "content/shell/shell_javascript_dialog_creator.h" |
29 #include "content/shell/shell_messages.h" | 29 #include "content/shell/shell_messages.h" |
30 #include "content/shell/shell_switches.h" | 30 #include "content/shell/shell_switches.h" |
31 #include "content/shell/webkit_test_controller.h" | 31 #include "content/shell/webkit_test_controller.h" |
32 #include "ui/gfx/size.h" | |
33 | 32 |
34 // Content area size for newly created windows. | 33 // Content area size for newly created windows. |
35 static const int kTestWindowWidth = 800; | 34 static const int kTestWindowWidth = 800; |
36 static const int kTestWindowHeight = 600; | 35 static const int kTestWindowHeight = 600; |
37 | 36 |
38 namespace content { | 37 namespace content { |
39 | 38 |
40 std::vector<Shell*> Shell::windows_; | 39 std::vector<Shell*> Shell::windows_; |
41 base::Callback<void(Shell*)> Shell::shell_created_callback_; | 40 base::Callback<void(Shell*)> Shell::shell_created_callback_; |
42 | 41 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return windows_[i]; | 113 return windows_[i]; |
115 } | 114 } |
116 } | 115 } |
117 return NULL; | 116 return NULL; |
118 } | 117 } |
119 | 118 |
120 Shell* Shell::CreateNewWindow(BrowserContext* browser_context, | 119 Shell* Shell::CreateNewWindow(BrowserContext* browser_context, |
121 const GURL& url, | 120 const GURL& url, |
122 SiteInstance* site_instance, | 121 SiteInstance* site_instance, |
123 int routing_id, | 122 int routing_id, |
124 WebContents* base_web_contents) { | 123 const gfx::Size& initial_size) { |
125 WebContents::CreateParams create_params(browser_context, site_instance); | 124 WebContents::CreateParams create_params(browser_context, site_instance); |
126 create_params.routing_id = routing_id; | 125 create_params.routing_id = routing_id; |
127 if (base_web_contents) { | 126 if (!initial_size.IsEmpty()) |
128 create_params.initial_size = | 127 create_params.initial_size = initial_size; |
129 base_web_contents->GetView()->GetContainerSize(); | 128 else |
130 } else { | |
131 create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight); | 129 create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight); |
132 } | |
133 WebContents* web_contents = WebContents::Create(create_params); | 130 WebContents* web_contents = WebContents::Create(create_params); |
134 Shell* shell = CreateShell(web_contents); | 131 Shell* shell = CreateShell(web_contents); |
135 if (!url.is_empty()) | 132 if (!url.is_empty()) |
136 shell->LoadURL(url); | 133 shell->LoadURL(url); |
137 return shell; | 134 return shell; |
138 } | 135 } |
139 | 136 |
140 void Shell::LoadURL(const GURL& url) { | 137 void Shell::LoadURL(const GURL& url) { |
141 web_contents_->GetController().LoadURL( | 138 web_contents_->GetController().LoadURL( |
142 url, | 139 url, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 175 } |
179 ShellContentBrowserClient* browser_client = | 176 ShellContentBrowserClient* browser_client = |
180 static_cast<ShellContentBrowserClient*>( | 177 static_cast<ShellContentBrowserClient*>( |
181 GetContentClient()->browser()); | 178 GetContentClient()->browser()); |
182 ShellDevToolsDelegate* delegate = | 179 ShellDevToolsDelegate* delegate = |
183 browser_client->shell_browser_main_parts()->devtools_delegate(); | 180 browser_client->shell_browser_main_parts()->devtools_delegate(); |
184 GURL url = delegate->devtools_http_handler()->GetFrontendURL( | 181 GURL url = delegate->devtools_http_handler()->GetFrontendURL( |
185 DevToolsAgentHost::GetFor(web_contents()->GetRenderViewHost())); | 182 DevToolsAgentHost::GetFor(web_contents()->GetRenderViewHost())); |
186 dev_tools_ = CreateNewWindow( | 183 dev_tools_ = CreateNewWindow( |
187 web_contents()->GetBrowserContext(), | 184 web_contents()->GetBrowserContext(), |
188 url, NULL, MSG_ROUTING_NONE, NULL); | 185 url, NULL, MSG_ROUTING_NONE, gfx::Size()); |
189 } | 186 } |
190 | 187 |
191 void Shell::CloseDevTools() { | 188 void Shell::CloseDevTools() { |
192 if (!dev_tools_) | 189 if (!dev_tools_) |
193 return; | 190 return; |
194 dev_tools_->Close(); | 191 dev_tools_->Close(); |
195 dev_tools_ = NULL; | 192 dev_tools_ = NULL; |
196 } | 193 } |
197 | 194 |
198 gfx::NativeView Shell::GetContentView() { | 195 gfx::NativeView Shell::GetContentView() { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 Details<std::pair<NavigationEntry*, bool> >(details).ptr(); | 298 Details<std::pair<NavigationEntry*, bool> >(details).ptr(); |
302 | 299 |
303 if (title->first) { | 300 if (title->first) { |
304 string16 text = title->first->GetTitle(); | 301 string16 text = title->first->GetTitle(); |
305 PlatformSetTitle(text); | 302 PlatformSetTitle(text); |
306 } | 303 } |
307 } | 304 } |
308 } | 305 } |
309 | 306 |
310 } // namespace content | 307 } // namespace content |
OLD | NEW |