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/ui/browser_navigator.h" | 5 #include "chrome/browser/ui/browser_navigator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 #include "chrome/browser/ui/singleton_tabs.h" | 30 #include "chrome/browser/ui/singleton_tabs.h" |
31 #include "chrome/browser/ui/status_bubble.h" | 31 #include "chrome/browser/ui/status_bubble.h" |
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
33 #include "chrome/browser/web_applications/web_app.h" | 33 #include "chrome/browser/web_applications/web_app.h" |
34 #include "chrome/common/extensions/extension.h" | 34 #include "chrome/common/extensions/extension.h" |
35 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
36 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
37 #include "content/public/browser/browser_url_handler.h" | 37 #include "content/public/browser/browser_url_handler.h" |
38 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
40 #include "content/public/browser/session_storage_namespace.h" | |
41 #include "content/public/browser/site_instance.h" | |
42 #include "content/public/browser/storage_partition.h" | |
40 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
41 #include "content/public/browser/web_contents_view.h" | 44 #include "content/public/browser/web_contents_view.h" |
42 | 45 |
43 #if defined(USE_AURA) | 46 #if defined(USE_AURA) |
44 #include "ui/aura/window.h" | 47 #include "ui/aura/window.h" |
45 #endif | 48 #endif |
46 | 49 |
47 using content::GlobalRequestID; | 50 using content::GlobalRequestID; |
48 using content::WebContents; | 51 using content::WebContents; |
49 | 52 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 params.source_contents->GetView()->GetContainerSize(); | 325 params.source_contents->GetView()->GetContainerSize(); |
323 } | 326 } |
324 #if defined(USE_AURA) | 327 #if defined(USE_AURA) |
325 if (params.browser->window() && | 328 if (params.browser->window() && |
326 params.browser->window()->GetNativeWindow()) { | 329 params.browser->window()->GetNativeWindow()) { |
327 create_params.context = | 330 create_params.context = |
328 params.browser->window()->GetNativeWindow(); | 331 params.browser->window()->GetNativeWindow(); |
329 } | 332 } |
330 #endif | 333 #endif |
331 | 334 |
332 content::WebContents* target_contents = WebContents::Create(create_params); | 335 content::SessionStorageNamespaceMap namespace_map; |
336 if (params.source_contents && params.should_copy_session_storage_namespace) { | |
337 Profile* source_profile = Profile::FromBrowserContext( | |
338 params.source_contents->GetBrowserContext()); | |
339 // TODO(jochen): once we use more than two storage partitions in chrome, we | |
340 // will need to revise this logic to clone the session storage namespace in | |
341 // the correct partition. For now, using the opener site instance to | |
342 // determine the storage partition is always ok. | |
awong
2013/07/31 18:58:59
This can never happen now. Each RenderViewHost sho
| |
343 content::SiteInstance* site_instance = | |
344 params.source_contents->GetSiteInstance(); | |
345 | |
346 // Compare to RenderMessageFilter::OnCreateWindow() and | |
347 // WebContentsImpl::CreateNewWindow(). | |
348 std::string partition_id = source_profile->GetStoragePartitionIdForSite( | |
349 site_instance->GetSiteURL()); | |
350 content::StoragePartition* partition = | |
351 content::BrowserContext::GetStoragePartition(source_profile, | |
352 site_instance); | |
353 content::SessionStorageNamespaceMap::const_iterator old_namespace = | |
354 params.source_contents->GetController().GetSessionStorageNamespaceMap() | |
355 .find(partition_id); | |
356 scoped_refptr<content::SessionStorageNamespace> cloned_namespace = | |
357 content::SessionStorageNamespace::Clone( | |
358 partition->GetDOMStorageContext(), old_namespace->second.get()); | |
359 namespace_map.insert(make_pair(partition_id, cloned_namespace)); | |
awong
2013/07/31 18:58:59
We should remove the SessionStorageNamespaceMap, w
| |
360 } | |
361 WebContents* target_contents = WebContents::CreateWithSessionStorage( | |
362 create_params, | |
363 namespace_map, | |
364 params.should_set_opener ? params.source_contents : NULL); | |
365 | |
333 // New tabs can have WebUI URLs that will make calls back to arbitrary | 366 // New tabs can have WebUI URLs that will make calls back to arbitrary |
334 // tab helpers, so the entire set of tab helpers needs to be set up | 367 // tab helpers, so the entire set of tab helpers needs to be set up |
335 // immediately. | 368 // immediately. |
336 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); | 369 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); |
337 extensions::TabHelper::FromWebContents(target_contents)-> | 370 extensions::TabHelper::FromWebContents(target_contents)-> |
338 SetExtensionAppById(params.extension_app_id); | 371 SetExtensionAppById(params.extension_app_id); |
339 // TODO(sky): Figure out why this is needed. Without it we seem to get | 372 // TODO(sky): Figure out why this is needed. Without it we seem to get |
340 // failures in startup tests. | 373 // failures in startup tests. |
341 // By default, content believes it is not hidden. When adding contents | 374 // By default, content believes it is not hidden. When adding contents |
342 // in the background, tell it that it's hidden. | 375 // in the background, tell it that it's hidden. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 is_renderer_initiated(false), | 419 is_renderer_initiated(false), |
387 tabstrip_index(-1), | 420 tabstrip_index(-1), |
388 tabstrip_add_types(TabStripModel::ADD_ACTIVE), | 421 tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
389 window_action(NO_ACTION), | 422 window_action(NO_ACTION), |
390 user_gesture(true), | 423 user_gesture(true), |
391 path_behavior(RESPECT), | 424 path_behavior(RESPECT), |
392 ref_behavior(IGNORE_REF), | 425 ref_behavior(IGNORE_REF), |
393 browser(a_browser), | 426 browser(a_browser), |
394 initiating_profile(NULL), | 427 initiating_profile(NULL), |
395 host_desktop_type(GetHostDesktop(a_browser)), | 428 host_desktop_type(GetHostDesktop(a_browser)), |
396 should_replace_current_entry(false) { | 429 should_replace_current_entry(false), |
430 should_copy_session_storage_namespace(false), | |
431 should_set_opener(false) { | |
397 } | 432 } |
398 | 433 |
399 NavigateParams::NavigateParams(Browser* a_browser, | 434 NavigateParams::NavigateParams(Browser* a_browser, |
400 WebContents* a_target_contents) | 435 WebContents* a_target_contents) |
401 : target_contents(a_target_contents), | 436 : target_contents(a_target_contents), |
402 source_contents(NULL), | 437 source_contents(NULL), |
403 disposition(CURRENT_TAB), | 438 disposition(CURRENT_TAB), |
404 transition(content::PAGE_TRANSITION_LINK), | 439 transition(content::PAGE_TRANSITION_LINK), |
405 is_renderer_initiated(false), | 440 is_renderer_initiated(false), |
406 tabstrip_index(-1), | 441 tabstrip_index(-1), |
407 tabstrip_add_types(TabStripModel::ADD_ACTIVE), | 442 tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
408 window_action(NO_ACTION), | 443 window_action(NO_ACTION), |
409 user_gesture(true), | 444 user_gesture(true), |
410 path_behavior(RESPECT), | 445 path_behavior(RESPECT), |
411 ref_behavior(IGNORE_REF), | 446 ref_behavior(IGNORE_REF), |
412 browser(a_browser), | 447 browser(a_browser), |
413 initiating_profile(NULL), | 448 initiating_profile(NULL), |
414 host_desktop_type(GetHostDesktop(a_browser)), | 449 host_desktop_type(GetHostDesktop(a_browser)), |
415 should_replace_current_entry(false) { | 450 should_replace_current_entry(false), |
451 should_copy_session_storage_namespace(false), | |
452 should_set_opener(false) { | |
416 } | 453 } |
417 | 454 |
418 NavigateParams::NavigateParams(Profile* a_profile, | 455 NavigateParams::NavigateParams(Profile* a_profile, |
419 const GURL& a_url, | 456 const GURL& a_url, |
420 content::PageTransition a_transition) | 457 content::PageTransition a_transition) |
421 : url(a_url), | 458 : url(a_url), |
422 target_contents(NULL), | 459 target_contents(NULL), |
423 source_contents(NULL), | 460 source_contents(NULL), |
424 disposition(NEW_FOREGROUND_TAB), | 461 disposition(NEW_FOREGROUND_TAB), |
425 transition(a_transition), | 462 transition(a_transition), |
426 is_renderer_initiated(false), | 463 is_renderer_initiated(false), |
427 tabstrip_index(-1), | 464 tabstrip_index(-1), |
428 tabstrip_add_types(TabStripModel::ADD_ACTIVE), | 465 tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
429 window_action(SHOW_WINDOW), | 466 window_action(SHOW_WINDOW), |
430 user_gesture(true), | 467 user_gesture(true), |
431 path_behavior(RESPECT), | 468 path_behavior(RESPECT), |
432 ref_behavior(IGNORE_REF), | 469 ref_behavior(IGNORE_REF), |
433 browser(NULL), | 470 browser(NULL), |
434 initiating_profile(a_profile), | 471 initiating_profile(a_profile), |
435 host_desktop_type(chrome::GetActiveDesktop()), | 472 host_desktop_type(chrome::GetActiveDesktop()), |
436 should_replace_current_entry(false) { | 473 should_replace_current_entry(false), |
474 should_copy_session_storage_namespace(false), | |
475 should_set_opener(false) { | |
437 } | 476 } |
438 | 477 |
439 NavigateParams::~NavigateParams() {} | 478 NavigateParams::~NavigateParams() {} |
440 | 479 |
441 void FillNavigateParamsFromOpenURLParams(chrome::NavigateParams* nav_params, | 480 void FillNavigateParamsFromOpenURLParams(chrome::NavigateParams* nav_params, |
442 const content::OpenURLParams& params) { | 481 const content::OpenURLParams& params) { |
443 nav_params->referrer = params.referrer; | 482 nav_params->referrer = params.referrer; |
444 nav_params->extra_headers = params.extra_headers; | 483 nav_params->extra_headers = params.extra_headers; |
445 nav_params->disposition = params.disposition; | 484 nav_params->disposition = params.disposition; |
446 nav_params->override_encoding = params.override_encoding; | 485 nav_params->override_encoding = params.override_encoding; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 bool reverse_on_redirect = false; | 709 bool reverse_on_redirect = false; |
671 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 710 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
672 &rewritten_url, browser_context, &reverse_on_redirect); | 711 &rewritten_url, browser_context, &reverse_on_redirect); |
673 | 712 |
674 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 713 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
675 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && | 714 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && |
676 rewritten_url.host() == chrome::kChromeUIUberHost); | 715 rewritten_url.host() == chrome::kChromeUIUberHost); |
677 } | 716 } |
678 | 717 |
679 } // namespace chrome | 718 } // namespace chrome |
OLD | NEW |