OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 chrome::ViewSource(this, source, frame_url, frame_page_state); | 1668 chrome::ViewSource(this, source, frame_url, frame_page_state); |
1669 } | 1669 } |
1670 | 1670 |
1671 void Browser::ShowRepostFormWarningDialog(WebContents* source) { | 1671 void Browser::ShowRepostFormWarningDialog(WebContents* source) { |
1672 TabModalConfirmDialog::Create(new RepostFormWarningController(source), | 1672 TabModalConfirmDialog::Create(new RepostFormWarningController(source), |
1673 source); | 1673 source); |
1674 } | 1674 } |
1675 | 1675 |
1676 bool Browser::ShouldCreateWebContents( | 1676 bool Browser::ShouldCreateWebContents( |
1677 content::WebContents* web_contents, | 1677 content::WebContents* web_contents, |
| 1678 content::RenderFrameHost* opener, |
1678 content::SiteInstance* source_site_instance, | 1679 content::SiteInstance* source_site_instance, |
1679 int32_t route_id, | 1680 int32_t route_id, |
1680 int32_t main_frame_route_id, | 1681 int32_t main_frame_route_id, |
1681 int32_t main_frame_widget_route_id, | 1682 int32_t main_frame_widget_route_id, |
1682 content::mojom::WindowContainerType window_container_type, | 1683 content::mojom::WindowContainerType window_container_type, |
1683 const GURL& opener_url, | 1684 const GURL& opener_url, |
1684 const std::string& frame_name, | 1685 const std::string& frame_name, |
1685 const GURL& target_url, | 1686 const GURL& target_url, |
1686 const std::string& partition_id, | 1687 const std::string& partition_id, |
1687 content::SessionStorageNamespace* session_storage_namespace) { | 1688 content::SessionStorageNamespace* session_storage_namespace) { |
1688 if (window_container_type == | 1689 if (window_container_type == |
1689 content::mojom::WindowContainerType::BACKGROUND) { | 1690 content::mojom::WindowContainerType::BACKGROUND) { |
1690 // If a BackgroundContents is created, suppress the normal WebContents. | 1691 // If a BackgroundContents is created, suppress the normal WebContents. |
1691 return !MaybeCreateBackgroundContents( | 1692 return !MaybeCreateBackgroundContents( |
1692 source_site_instance, opener_url, route_id, main_frame_route_id, | 1693 source_site_instance, opener, opener_url, route_id, main_frame_route_id, |
1693 main_frame_widget_route_id, frame_name, target_url, partition_id, | 1694 main_frame_widget_route_id, frame_name, target_url, partition_id, |
1694 session_storage_namespace); | 1695 session_storage_namespace); |
1695 } | 1696 } |
1696 | 1697 |
1697 return true; | 1698 return true; |
1698 } | 1699 } |
1699 | 1700 |
1700 void Browser::WebContentsCreated(WebContents* source_contents, | 1701 void Browser::WebContentsCreated(WebContents* source_contents, |
1701 int opener_render_process_id, | 1702 int opener_render_process_id, |
1702 int opener_render_frame_id, | 1703 int opener_render_frame_id, |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2544 // keep the controls in a slide-down panel. | 2545 // keep the controls in a slide-down panel. |
2545 return window_ && window_->ShouldHideUIForFullscreen(); | 2546 return window_ && window_->ShouldHideUIForFullscreen(); |
2546 } | 2547 } |
2547 | 2548 |
2548 bool Browser::ShouldStartShutdown() const { | 2549 bool Browser::ShouldStartShutdown() const { |
2549 return BrowserList::GetInstance()->size() <= 1; | 2550 return BrowserList::GetInstance()->size() <= 1; |
2550 } | 2551 } |
2551 | 2552 |
2552 bool Browser::MaybeCreateBackgroundContents( | 2553 bool Browser::MaybeCreateBackgroundContents( |
2553 content::SiteInstance* source_site_instance, | 2554 content::SiteInstance* source_site_instance, |
| 2555 content::RenderFrameHost* opener, |
2554 const GURL& opener_url, | 2556 const GURL& opener_url, |
2555 int32_t route_id, | 2557 int32_t route_id, |
2556 int32_t main_frame_route_id, | 2558 int32_t main_frame_route_id, |
2557 int32_t main_frame_widget_route_id, | 2559 int32_t main_frame_widget_route_id, |
2558 const std::string& frame_name, | 2560 const std::string& frame_name, |
2559 const GURL& target_url, | 2561 const GURL& target_url, |
2560 const std::string& partition_id, | 2562 const std::string& partition_id, |
2561 content::SessionStorageNamespace* session_storage_namespace) { | 2563 content::SessionStorageNamespace* session_storage_namespace) { |
2562 ExtensionService* extensions_service = | 2564 ExtensionService* extensions_service = |
2563 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 2565 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2601 return true; | 2603 return true; |
2602 // For scriptable background pages, if one already exists, close it (even | 2604 // For scriptable background pages, if one already exists, close it (even |
2603 // if it was specified in the manifest). | 2605 // if it was specified in the manifest). |
2604 delete existing; | 2606 delete existing; |
2605 } | 2607 } |
2606 | 2608 |
2607 // Passed all the checks, so this should be created as a BackgroundContents. | 2609 // Passed all the checks, so this should be created as a BackgroundContents. |
2608 BackgroundContents* contents = nullptr; | 2610 BackgroundContents* contents = nullptr; |
2609 if (allow_js_access) { | 2611 if (allow_js_access) { |
2610 contents = service->CreateBackgroundContents( | 2612 contents = service->CreateBackgroundContents( |
2611 source_site_instance, route_id, main_frame_route_id, | 2613 source_site_instance, opener, route_id, main_frame_route_id, |
2612 main_frame_widget_route_id, profile_, frame_name, | 2614 main_frame_widget_route_id, profile_, frame_name, |
2613 base::ASCIIToUTF16(extension->id()), partition_id, | 2615 base::ASCIIToUTF16(extension->id()), partition_id, |
2614 session_storage_namespace); | 2616 session_storage_namespace); |
2615 } else { | 2617 } else { |
2616 // If script access is not allowed, create the the background contents in a | 2618 // If script access is not allowed, create the the background contents in a |
2617 // new SiteInstance, so that a separate process is used. We must not use any | 2619 // new SiteInstance, so that a separate process is used. We must not use any |
2618 // of the passed-in routing IDs, as they are objects in the opener's | 2620 // of the passed-in routing IDs, as they are objects in the opener's |
2619 // process. | 2621 // process. |
2620 contents = service->CreateBackgroundContents( | 2622 contents = service->CreateBackgroundContents( |
2621 content::SiteInstance::Create( | 2623 content::SiteInstance::Create( |
2622 source_site_instance->GetBrowserContext()), | 2624 source_site_instance->GetBrowserContext()), |
2623 MSG_ROUTING_NONE, MSG_ROUTING_NONE, MSG_ROUTING_NONE, profile_, | 2625 nullptr, MSG_ROUTING_NONE, MSG_ROUTING_NONE, MSG_ROUTING_NONE, profile_, |
2624 frame_name, base::ASCIIToUTF16(extension->id()), partition_id, | 2626 frame_name, base::ASCIIToUTF16(extension->id()), partition_id, |
2625 session_storage_namespace); | 2627 session_storage_namespace); |
2626 | 2628 |
2627 // When a separate process is used, the original renderer cannot access the | 2629 // When a separate process is used, the original renderer cannot access the |
2628 // new window later, thus we need to navigate the window now. | 2630 // new window later, thus we need to navigate the window now. |
2629 if (contents) { | 2631 if (contents) { |
2630 contents->web_contents()->GetController().LoadURL( | 2632 contents->web_contents()->GetController().LoadURL( |
2631 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2633 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2632 std::string()); // No extra headers. | 2634 std::string()); // No extra headers. |
2633 } | 2635 } |
2634 } | 2636 } |
2635 | 2637 |
2636 return contents != NULL; | 2638 return contents != NULL; |
2637 } | 2639 } |
OLD | NEW |