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