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 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 chrome::ViewSource(this, source, frame_url, frame_page_state); | 1623 chrome::ViewSource(this, source, frame_url, frame_page_state); |
1624 } | 1624 } |
1625 | 1625 |
1626 void Browser::ShowRepostFormWarningDialog(WebContents* source) { | 1626 void Browser::ShowRepostFormWarningDialog(WebContents* source) { |
1627 TabModalConfirmDialog::Create(new RepostFormWarningController(source), | 1627 TabModalConfirmDialog::Create(new RepostFormWarningController(source), |
1628 source); | 1628 source); |
1629 } | 1629 } |
1630 | 1630 |
1631 bool Browser::ShouldCreateWebContents( | 1631 bool Browser::ShouldCreateWebContents( |
1632 WebContents* web_contents, | 1632 WebContents* web_contents, |
1633 int route_id, | 1633 int32 route_id, |
1634 int main_frame_route_id, | 1634 int32 main_frame_route_id, |
| 1635 int32 main_frame_widget_route_id, |
| 1636 int32 surface_id, |
1635 WindowContainerType window_container_type, | 1637 WindowContainerType window_container_type, |
1636 const std::string& frame_name, | 1638 const std::string& frame_name, |
1637 const GURL& target_url, | 1639 const GURL& target_url, |
1638 const std::string& partition_id, | 1640 const std::string& partition_id, |
1639 content::SessionStorageNamespace* session_storage_namespace) { | 1641 content::SessionStorageNamespace* session_storage_namespace) { |
1640 if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { | 1642 if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
1641 // If a BackgroundContents is created, suppress the normal WebContents. | 1643 // If a BackgroundContents is created, suppress the normal WebContents. |
1642 return !MaybeCreateBackgroundContents(route_id, | 1644 return !MaybeCreateBackgroundContents( |
1643 main_frame_route_id, | 1645 route_id, main_frame_route_id, main_frame_widget_route_id, surface_id, |
1644 web_contents, | 1646 web_contents, frame_name, target_url, partition_id, |
1645 frame_name, | 1647 session_storage_namespace); |
1646 target_url, | |
1647 partition_id, | |
1648 session_storage_namespace); | |
1649 } | 1648 } |
1650 | 1649 |
1651 return true; | 1650 return true; |
1652 } | 1651 } |
1653 | 1652 |
1654 void Browser::WebContentsCreated(WebContents* source_contents, | 1653 void Browser::WebContentsCreated(WebContents* source_contents, |
1655 int opener_render_frame_id, | 1654 int opener_render_frame_id, |
1656 const std::string& frame_name, | 1655 const std::string& frame_name, |
1657 const GURL& target_url, | 1656 const GURL& target_url, |
1658 WebContents* new_contents) { | 1657 WebContents* new_contents) { |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2559 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
2561 } | 2560 } |
2562 | 2561 |
2563 bool Browser::ShouldHideUIForFullscreen() const { | 2562 bool Browser::ShouldHideUIForFullscreen() const { |
2564 // Windows and GTK remove the top controls in fullscreen, but Mac and Ash | 2563 // Windows and GTK remove the top controls in fullscreen, but Mac and Ash |
2565 // keep the controls in a slide-down panel. | 2564 // keep the controls in a slide-down panel. |
2566 return window_ && window_->ShouldHideUIForFullscreen(); | 2565 return window_ && window_->ShouldHideUIForFullscreen(); |
2567 } | 2566 } |
2568 | 2567 |
2569 bool Browser::MaybeCreateBackgroundContents( | 2568 bool Browser::MaybeCreateBackgroundContents( |
2570 int route_id, | 2569 int32 route_id, |
2571 int main_frame_route_id, | 2570 int32 main_frame_route_id, |
| 2571 int32 main_frame_widget_route_id, |
| 2572 int32 surface_id, |
2572 WebContents* opener_web_contents, | 2573 WebContents* opener_web_contents, |
2573 const std::string& frame_name, | 2574 const std::string& frame_name, |
2574 const GURL& target_url, | 2575 const GURL& target_url, |
2575 const std::string& partition_id, | 2576 const std::string& partition_id, |
2576 content::SessionStorageNamespace* session_storage_namespace) { | 2577 content::SessionStorageNamespace* session_storage_namespace) { |
2577 GURL opener_url = opener_web_contents->GetURL(); | 2578 GURL opener_url = opener_web_contents->GetURL(); |
2578 ExtensionService* extensions_service = | 2579 ExtensionService* extensions_service = |
2579 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 2580 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
2580 | 2581 |
2581 if (!opener_url.is_valid() || | 2582 if (!opener_url.is_valid() || |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2624 } | 2625 } |
2625 | 2626 |
2626 // If script access is not allowed, create the the background contents in a | 2627 // If script access is not allowed, create the the background contents in a |
2627 // new SiteInstance, so that a separate process is used. | 2628 // new SiteInstance, so that a separate process is used. |
2628 scoped_refptr<content::SiteInstance> site_instance = | 2629 scoped_refptr<content::SiteInstance> site_instance = |
2629 allow_js_access ? | 2630 allow_js_access ? |
2630 opener_site_instance : | 2631 opener_site_instance : |
2631 content::SiteInstance::Create(opener_web_contents->GetBrowserContext()); | 2632 content::SiteInstance::Create(opener_web_contents->GetBrowserContext()); |
2632 | 2633 |
2633 // Passed all the checks, so this should be created as a BackgroundContents. | 2634 // Passed all the checks, so this should be created as a BackgroundContents. |
2634 BackgroundContents* contents = | 2635 BackgroundContents* contents = service->CreateBackgroundContents( |
2635 service->CreateBackgroundContents(site_instance.get(), | 2636 site_instance.get(), route_id, main_frame_route_id, |
2636 route_id, | 2637 main_frame_widget_route_id, surface_id, profile_, frame_name, |
2637 main_frame_route_id, | 2638 base::ASCIIToUTF16(extension->id()), partition_id, |
2638 profile_, | 2639 session_storage_namespace); |
2639 frame_name, | |
2640 base::ASCIIToUTF16(extension->id()), | |
2641 partition_id, | |
2642 session_storage_namespace); | |
2643 | 2640 |
2644 // When a separate process is used, the original renderer cannot access the | 2641 // When a separate process is used, the original renderer cannot access the |
2645 // new window later, thus we need to navigate the window now. | 2642 // new window later, thus we need to navigate the window now. |
2646 if (contents && !allow_js_access) { | 2643 if (contents && !allow_js_access) { |
2647 contents->web_contents()->GetController().LoadURL( | 2644 contents->web_contents()->GetController().LoadURL( |
2648 target_url, | 2645 target_url, |
2649 content::Referrer(), | 2646 content::Referrer(), |
2650 ui::PAGE_TRANSITION_LINK, | 2647 ui::PAGE_TRANSITION_LINK, |
2651 std::string()); // No extra headers. | 2648 std::string()); // No extra headers. |
2652 } | 2649 } |
2653 | 2650 |
2654 return contents != NULL; | 2651 return contents != NULL; |
2655 } | 2652 } |
OLD | NEW |