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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 chrome::ViewSource(this, source, frame_url, frame_page_state); | 1649 chrome::ViewSource(this, source, frame_url, frame_page_state); |
1650 } | 1650 } |
1651 | 1651 |
1652 void Browser::ShowRepostFormWarningDialog(WebContents* source) { | 1652 void Browser::ShowRepostFormWarningDialog(WebContents* source) { |
1653 TabModalConfirmDialog::Create(new RepostFormWarningController(source), | 1653 TabModalConfirmDialog::Create(new RepostFormWarningController(source), |
1654 source); | 1654 source); |
1655 } | 1655 } |
1656 | 1656 |
1657 bool Browser::ShouldCreateWebContents( | 1657 bool Browser::ShouldCreateWebContents( |
1658 WebContents* web_contents, | 1658 WebContents* web_contents, |
1659 int route_id, | 1659 int32_t route_id, |
1660 int main_frame_route_id, | 1660 int32_t main_frame_route_id, |
| 1661 int32_t main_frame_widget_route_id, |
1661 WindowContainerType window_container_type, | 1662 WindowContainerType window_container_type, |
1662 const std::string& frame_name, | 1663 const std::string& frame_name, |
1663 const GURL& target_url, | 1664 const GURL& target_url, |
1664 const std::string& partition_id, | 1665 const std::string& partition_id, |
1665 content::SessionStorageNamespace* session_storage_namespace) { | 1666 content::SessionStorageNamespace* session_storage_namespace) { |
1666 if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { | 1667 if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
1667 // If a BackgroundContents is created, suppress the normal WebContents. | 1668 // If a BackgroundContents is created, suppress the normal WebContents. |
1668 return !MaybeCreateBackgroundContents(route_id, | 1669 return !MaybeCreateBackgroundContents( |
1669 main_frame_route_id, | 1670 route_id, main_frame_route_id, main_frame_widget_route_id, web_contents, |
1670 web_contents, | 1671 frame_name, target_url, partition_id, session_storage_namespace); |
1671 frame_name, | |
1672 target_url, | |
1673 partition_id, | |
1674 session_storage_namespace); | |
1675 } | 1672 } |
1676 | 1673 |
1677 return true; | 1674 return true; |
1678 } | 1675 } |
1679 | 1676 |
1680 void Browser::WebContentsCreated(WebContents* source_contents, | 1677 void Browser::WebContentsCreated(WebContents* source_contents, |
1681 int opener_render_frame_id, | 1678 int opener_render_frame_id, |
1682 const std::string& frame_name, | 1679 const std::string& frame_name, |
1683 const GURL& target_url, | 1680 const GURL& target_url, |
1684 WebContents* new_contents) { | 1681 WebContents* new_contents) { |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 // environment is still active. | 2610 // environment is still active. |
2614 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) | 2611 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) |
2615 return !ash::Shell::HasInstance(); | 2612 return !ash::Shell::HasInstance(); |
2616 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 2613 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
2617 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); | 2614 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); |
2618 #endif | 2615 #endif |
2619 return true; | 2616 return true; |
2620 } | 2617 } |
2621 | 2618 |
2622 bool Browser::MaybeCreateBackgroundContents( | 2619 bool Browser::MaybeCreateBackgroundContents( |
2623 int route_id, | 2620 int32_t route_id, |
2624 int main_frame_route_id, | 2621 int32_t main_frame_route_id, |
| 2622 int32_t main_frame_widget_route_id, |
2625 WebContents* opener_web_contents, | 2623 WebContents* opener_web_contents, |
2626 const std::string& frame_name, | 2624 const std::string& frame_name, |
2627 const GURL& target_url, | 2625 const GURL& target_url, |
2628 const std::string& partition_id, | 2626 const std::string& partition_id, |
2629 content::SessionStorageNamespace* session_storage_namespace) { | 2627 content::SessionStorageNamespace* session_storage_namespace) { |
2630 GURL opener_url = opener_web_contents->GetURL(); | 2628 GURL opener_url = opener_web_contents->GetURL(); |
2631 ExtensionService* extensions_service = | 2629 ExtensionService* extensions_service = |
2632 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 2630 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
2633 | 2631 |
2634 if (!opener_url.is_valid() || | 2632 if (!opener_url.is_valid() || |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2677 } | 2675 } |
2678 | 2676 |
2679 // If script access is not allowed, create the the background contents in a | 2677 // If script access is not allowed, create the the background contents in a |
2680 // new SiteInstance, so that a separate process is used. | 2678 // new SiteInstance, so that a separate process is used. |
2681 scoped_refptr<content::SiteInstance> site_instance = | 2679 scoped_refptr<content::SiteInstance> site_instance = |
2682 allow_js_access ? | 2680 allow_js_access ? |
2683 opener_site_instance : | 2681 opener_site_instance : |
2684 content::SiteInstance::Create(opener_web_contents->GetBrowserContext()); | 2682 content::SiteInstance::Create(opener_web_contents->GetBrowserContext()); |
2685 | 2683 |
2686 // Passed all the checks, so this should be created as a BackgroundContents. | 2684 // Passed all the checks, so this should be created as a BackgroundContents. |
2687 BackgroundContents* contents = | 2685 BackgroundContents* contents = service->CreateBackgroundContents( |
2688 service->CreateBackgroundContents(site_instance.get(), | 2686 site_instance.get(), route_id, main_frame_route_id, |
2689 route_id, | 2687 main_frame_widget_route_id, profile_, frame_name, |
2690 main_frame_route_id, | 2688 base::ASCIIToUTF16(extension->id()), partition_id, |
2691 profile_, | 2689 session_storage_namespace); |
2692 frame_name, | |
2693 base::ASCIIToUTF16(extension->id()), | |
2694 partition_id, | |
2695 session_storage_namespace); | |
2696 | 2690 |
2697 // When a separate process is used, the original renderer cannot access the | 2691 // When a separate process is used, the original renderer cannot access the |
2698 // new window later, thus we need to navigate the window now. | 2692 // new window later, thus we need to navigate the window now. |
2699 if (contents && !allow_js_access) { | 2693 if (contents && !allow_js_access) { |
2700 contents->web_contents()->GetController().LoadURL( | 2694 contents->web_contents()->GetController().LoadURL( |
2701 target_url, | 2695 target_url, |
2702 content::Referrer(), | 2696 content::Referrer(), |
2703 ui::PAGE_TRANSITION_LINK, | 2697 ui::PAGE_TRANSITION_LINK, |
2704 std::string()); // No extra headers. | 2698 std::string()); // No extra headers. |
2705 } | 2699 } |
2706 | 2700 |
2707 return contents != NULL; | 2701 return contents != NULL; |
2708 } | 2702 } |
OLD | NEW |