| 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/background/background_contents_service.h" | 5 #include "chrome/browser/background/background_contents_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 const base::string16& application_id) { | 712 const base::string16& application_id) { |
| 713 // We are depending on the fact that we will initialize before any user | 713 // We are depending on the fact that we will initialize before any user |
| 714 // actions or session restore can take place, so no BackgroundContents should | 714 // actions or session restore can take place, so no BackgroundContents should |
| 715 // be running yet for the passed application_id. | 715 // be running yet for the passed application_id. |
| 716 DCHECK(!GetAppBackgroundContents(application_id)); | 716 DCHECK(!GetAppBackgroundContents(application_id)); |
| 717 DCHECK(!application_id.empty()); | 717 DCHECK(!application_id.empty()); |
| 718 DCHECK(url.is_valid()); | 718 DCHECK(url.is_valid()); |
| 719 DVLOG(1) << "Loading background content url: " << url; | 719 DVLOG(1) << "Loading background content url: " << url; |
| 720 | 720 |
| 721 BackgroundContents* contents = CreateBackgroundContents( | 721 BackgroundContents* contents = CreateBackgroundContents( |
| 722 SiteInstance::CreateForURL(profile, url), MSG_ROUTING_NONE, | 722 SiteInstance::CreateForURL(profile, url), nullptr, MSG_ROUTING_NONE, |
| 723 MSG_ROUTING_NONE, MSG_ROUTING_NONE, profile, frame_name, application_id, | 723 MSG_ROUTING_NONE, MSG_ROUTING_NONE, profile, frame_name, application_id, |
| 724 std::string(), NULL); | 724 std::string(), NULL); |
| 725 | 725 |
| 726 contents->CreateRenderViewSoon(url); | 726 contents->CreateRenderViewSoon(url); |
| 727 } | 727 } |
| 728 | 728 |
| 729 BackgroundContents* BackgroundContentsService::CreateBackgroundContents( | 729 BackgroundContents* BackgroundContentsService::CreateBackgroundContents( |
| 730 scoped_refptr<SiteInstance> site, | 730 scoped_refptr<SiteInstance> site, |
| 731 content::RenderFrameHost* opener, |
| 731 int32_t routing_id, | 732 int32_t routing_id, |
| 732 int32_t main_frame_route_id, | 733 int32_t main_frame_route_id, |
| 733 int32_t main_frame_widget_route_id, | 734 int32_t main_frame_widget_route_id, |
| 734 Profile* profile, | 735 Profile* profile, |
| 735 const std::string& frame_name, | 736 const std::string& frame_name, |
| 736 const base::string16& application_id, | 737 const base::string16& application_id, |
| 737 const std::string& partition_id, | 738 const std::string& partition_id, |
| 738 content::SessionStorageNamespace* session_storage_namespace) { | 739 content::SessionStorageNamespace* session_storage_namespace) { |
| 739 BackgroundContents* contents = | 740 BackgroundContents* contents = |
| 740 new BackgroundContents(std::move(site), routing_id, main_frame_route_id, | 741 new BackgroundContents(std::move(site), opener, routing_id, |
| 741 main_frame_widget_route_id, this, partition_id, | 742 main_frame_route_id, main_frame_widget_route_id, |
| 742 session_storage_namespace); | 743 this, partition_id, session_storage_namespace); |
| 743 | 744 |
| 744 // Register the BackgroundContents internally, then send out a notification | 745 // Register the BackgroundContents internally, then send out a notification |
| 745 // to external listeners. | 746 // to external listeners. |
| 746 BackgroundContentsOpenedDetails details = {contents, | 747 BackgroundContentsOpenedDetails details = {contents, |
| 747 frame_name, | 748 frame_name, |
| 748 application_id}; | 749 application_id}; |
| 749 BackgroundContentsOpened(&details, profile); | 750 BackgroundContentsOpened(&details, profile); |
| 750 content::NotificationService::current()->Notify( | 751 content::NotificationService::current()->Notify( |
| 751 chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED, | 752 chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED, |
| 752 content::Source<Profile>(profile), | 753 content::Source<Profile>(profile), |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 const gfx::Rect& initial_rect, | 863 const gfx::Rect& initial_rect, |
| 863 bool user_gesture, | 864 bool user_gesture, |
| 864 bool* was_blocked) { | 865 bool* was_blocked) { |
| 865 Browser* browser = chrome::FindLastActiveWithProfile( | 866 Browser* browser = chrome::FindLastActiveWithProfile( |
| 866 Profile::FromBrowserContext(new_contents->GetBrowserContext())); | 867 Profile::FromBrowserContext(new_contents->GetBrowserContext())); |
| 867 if (browser) { | 868 if (browser) { |
| 868 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 869 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 869 initial_rect, user_gesture, was_blocked); | 870 initial_rect, user_gesture, was_blocked); |
| 870 } | 871 } |
| 871 } | 872 } |
| OLD | NEW |