OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/shell.h" | 5 #include "content/shell/browser/shell.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 } | 169 } |
170 | 170 |
171 gfx::Size Shell::AdjustWindowSize(const gfx::Size& initial_size) { | 171 gfx::Size Shell::AdjustWindowSize(const gfx::Size& initial_size) { |
172 if (!initial_size.IsEmpty()) | 172 if (!initial_size.IsEmpty()) |
173 return initial_size; | 173 return initial_size; |
174 return GetShellDefaultSize(); | 174 return GetShellDefaultSize(); |
175 } | 175 } |
176 | 176 |
177 Shell* Shell::CreateNewWindow(BrowserContext* browser_context, | 177 Shell* Shell::CreateNewWindow(BrowserContext* browser_context, |
178 const GURL& url, | 178 const GURL& url, |
179 SiteInstance* site_instance, | 179 const scoped_refptr<SiteInstance>& site_instance, |
180 const gfx::Size& initial_size) { | 180 const gfx::Size& initial_size) { |
181 WebContents::CreateParams create_params(browser_context, site_instance); | 181 WebContents::CreateParams create_params(browser_context, site_instance); |
182 create_params.initial_size = AdjustWindowSize(initial_size); | 182 create_params.initial_size = AdjustWindowSize(initial_size); |
183 WebContents* web_contents = WebContents::Create(create_params); | 183 WebContents* web_contents = WebContents::Create(create_params); |
184 Shell* shell = CreateShell(web_contents, create_params.initial_size); | 184 Shell* shell = CreateShell(web_contents, create_params.initial_size); |
185 if (!url.is_empty()) | 185 if (!url.is_empty()) |
186 shell->LoadURL(url); | 186 shell->LoadURL(url); |
187 return shell; | 187 return shell; |
188 } | 188 } |
189 | 189 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 } | 305 } |
306 | 306 |
307 gfx::NativeView Shell::GetContentView() { | 307 gfx::NativeView Shell::GetContentView() { |
308 if (!web_contents_) | 308 if (!web_contents_) |
309 return NULL; | 309 return NULL; |
310 return web_contents_->GetNativeView(); | 310 return web_contents_->GetNativeView(); |
311 } | 311 } |
312 | 312 |
313 WebContents* Shell::OpenURLFromTab(WebContents* source, | 313 WebContents* Shell::OpenURLFromTab(WebContents* source, |
314 const OpenURLParams& params) { | 314 const OpenURLParams& params) { |
315 // This implementation only handles CURRENT_TAB. | 315 WebContents* target = nullptr; |
316 if (params.disposition != WindowOpenDisposition::CURRENT_TAB) | 316 switch (params.disposition) { |
317 return nullptr; | 317 case WindowOpenDisposition::CURRENT_TAB: |
318 target = source; | |
319 break; | |
320 | |
321 // Normally, the difference between NEW_POPUP and NEW_WINDOW is that a popup | |
322 // should have no toolbar, no status bar, no menu bar, no scrollbars and be | |
323 // not resizable. For simplicity and to enable new testing scenarios in | |
324 // content shell and layout tests, popups don't get special treatment below | |
325 // (i.e. they will have a toolbar and other things described here). | |
326 case WindowOpenDisposition::NEW_POPUP: | |
327 case WindowOpenDisposition::NEW_WINDOW: { | |
328 Shell* new_window = | |
329 Shell::CreateNewWindow(source->GetBrowserContext(), | |
330 GURL(), // Don't load anything just yet. | |
331 params.source_site_instance, | |
Łukasz Anforowicz
2016/10/20 22:56:42
Using |params.source_site_instance| is consistent
nasko
2016/10/21 16:32:47
Acknowledged.
| |
332 gfx::Size()); // Use default size. | |
333 target = new_window->web_contents(); | |
334 if (switches::IsRunLayoutTestSwitchPresent()) | |
335 SecondaryTestWindowObserver::CreateForWebContents(target); | |
336 break; | |
337 } | |
338 | |
339 // No tabs in content_shell: | |
340 case WindowOpenDisposition::SINGLETON_TAB: | |
341 case WindowOpenDisposition::NEW_FOREGROUND_TAB: | |
342 case WindowOpenDisposition::NEW_BACKGROUND_TAB: | |
343 // No incognito mode in content_shell: | |
344 case WindowOpenDisposition::OFF_THE_RECORD: | |
345 // TODO(lukasza): Investigate if some layout tests might need support for | |
346 // SAVE_TO_DISK disposition. This would probably require that | |
347 // BlinkTestController always sets up and cleans up a temporary directory | |
348 // as the default downloads destinations for the duration of a test. | |
349 case WindowOpenDisposition::SAVE_TO_DISK: | |
350 // Ignoring requests with disposition == IGNORE_ACTION... | |
351 case WindowOpenDisposition::IGNORE_ACTION: | |
352 default: | |
353 return nullptr; | |
354 } | |
318 | 355 |
319 NavigationController::LoadURLParams load_url_params(params.url); | 356 NavigationController::LoadURLParams load_url_params(params.url); |
320 load_url_params.source_site_instance = params.source_site_instance; | 357 load_url_params.source_site_instance = params.source_site_instance; |
321 load_url_params.transition_type = params.transition; | 358 load_url_params.transition_type = params.transition; |
322 load_url_params.frame_tree_node_id = params.frame_tree_node_id; | 359 load_url_params.frame_tree_node_id = params.frame_tree_node_id; |
323 load_url_params.referrer = params.referrer; | 360 load_url_params.referrer = params.referrer; |
324 load_url_params.redirect_chain = params.redirect_chain; | 361 load_url_params.redirect_chain = params.redirect_chain; |
325 load_url_params.extra_headers = params.extra_headers; | 362 load_url_params.extra_headers = params.extra_headers; |
326 load_url_params.is_renderer_initiated = params.is_renderer_initiated; | 363 load_url_params.is_renderer_initiated = params.is_renderer_initiated; |
327 load_url_params.should_replace_current_entry = | 364 load_url_params.should_replace_current_entry = |
328 params.should_replace_current_entry; | 365 params.should_replace_current_entry; |
329 | 366 |
330 if (params.uses_post) { | 367 if (params.uses_post) { |
331 load_url_params.load_type = NavigationController::LOAD_TYPE_HTTP_POST; | 368 load_url_params.load_type = NavigationController::LOAD_TYPE_HTTP_POST; |
332 load_url_params.post_data = params.post_data; | 369 load_url_params.post_data = params.post_data; |
333 } | 370 } |
334 | 371 |
335 source->GetController().LoadURLWithParams(load_url_params); | 372 target->GetController().LoadURLWithParams(load_url_params); |
336 return source; | 373 return target; |
337 } | 374 } |
338 | 375 |
339 void Shell::LoadingStateChanged(WebContents* source, | 376 void Shell::LoadingStateChanged(WebContents* source, |
340 bool to_different_document) { | 377 bool to_different_document) { |
341 UpdateNavigationControls(to_different_document); | 378 UpdateNavigationControls(to_different_document); |
342 PlatformSetIsLoading(source->IsLoading()); | 379 PlatformSetIsLoading(source->IsLoading()); |
343 } | 380 } |
344 | 381 |
345 void Shell::EnterFullscreenModeForTab(WebContents* web_contents, | 382 void Shell::EnterFullscreenModeForTab(WebContents* web_contents, |
346 const GURL& origin) { | 383 const GURL& origin) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 if (entry) | 499 if (entry) |
463 PlatformSetTitle(entry->GetTitle()); | 500 PlatformSetTitle(entry->GetTitle()); |
464 } | 501 } |
465 | 502 |
466 void Shell::OnDevToolsWebContentsDestroyed() { | 503 void Shell::OnDevToolsWebContentsDestroyed() { |
467 devtools_observer_.reset(); | 504 devtools_observer_.reset(); |
468 devtools_frontend_ = NULL; | 505 devtools_frontend_ = NULL; |
469 } | 506 } |
470 | 507 |
471 } // namespace content | 508 } // namespace content |
OLD | NEW |