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 "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 // actions or session restore can take place, so no BackgroundContents should | 615 // actions or session restore can take place, so no BackgroundContents should |
616 // be running yet for the passed application_id. | 616 // be running yet for the passed application_id. |
617 DCHECK(!GetAppBackgroundContents(application_id)); | 617 DCHECK(!GetAppBackgroundContents(application_id)); |
618 DCHECK(!application_id.empty()); | 618 DCHECK(!application_id.empty()); |
619 DCHECK(url.is_valid()); | 619 DCHECK(url.is_valid()); |
620 DVLOG(1) << "Loading background content url: " << url; | 620 DVLOG(1) << "Loading background content url: " << url; |
621 | 621 |
622 BackgroundContents* contents = CreateBackgroundContents( | 622 BackgroundContents* contents = CreateBackgroundContents( |
623 SiteInstance::CreateForURL(profile, url), | 623 SiteInstance::CreateForURL(profile, url), |
624 MSG_ROUTING_NONE, | 624 MSG_ROUTING_NONE, |
| 625 MSG_ROUTING_NONE, |
625 profile, | 626 profile, |
626 frame_name, | 627 frame_name, |
627 application_id, | 628 application_id, |
628 std::string(), | 629 std::string(), |
629 NULL); | 630 NULL); |
630 | 631 |
631 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing | 632 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing |
632 // startup latency (http://crbug.com/47236). | 633 // startup latency (http://crbug.com/47236). |
633 contents->web_contents()->GetController().LoadURL( | 634 contents->web_contents()->GetController().LoadURL( |
634 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 635 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
635 } | 636 } |
636 | 637 |
637 BackgroundContents* BackgroundContentsService::CreateBackgroundContents( | 638 BackgroundContents* BackgroundContentsService::CreateBackgroundContents( |
638 SiteInstance* site, | 639 SiteInstance* site, |
639 int routing_id, | 640 int routing_id, |
| 641 int main_frame_route_id, |
640 Profile* profile, | 642 Profile* profile, |
641 const base::string16& frame_name, | 643 const base::string16& frame_name, |
642 const base::string16& application_id, | 644 const base::string16& application_id, |
643 const std::string& partition_id, | 645 const std::string& partition_id, |
644 content::SessionStorageNamespace* session_storage_namespace) { | 646 content::SessionStorageNamespace* session_storage_namespace) { |
645 BackgroundContents* contents = new BackgroundContents( | 647 BackgroundContents* contents = new BackgroundContents( |
646 site, routing_id, this, partition_id, session_storage_namespace); | 648 site, routing_id, main_frame_route_id, this, partition_id, |
| 649 session_storage_namespace); |
647 | 650 |
648 // Register the BackgroundContents internally, then send out a notification | 651 // Register the BackgroundContents internally, then send out a notification |
649 // to external listeners. | 652 // to external listeners. |
650 BackgroundContentsOpenedDetails details = {contents, | 653 BackgroundContentsOpenedDetails details = {contents, |
651 frame_name, | 654 frame_name, |
652 application_id}; | 655 application_id}; |
653 BackgroundContentsOpened(&details, profile); | 656 BackgroundContentsOpened(&details, profile); |
654 content::NotificationService::current()->Notify( | 657 content::NotificationService::current()->Notify( |
655 chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED, | 658 chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED, |
656 content::Source<Profile>(profile), | 659 content::Source<Profile>(profile), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 bool user_gesture, | 770 bool user_gesture, |
768 bool* was_blocked) { | 771 bool* was_blocked) { |
769 Browser* browser = chrome::FindLastActiveWithProfile( | 772 Browser* browser = chrome::FindLastActiveWithProfile( |
770 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 773 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
771 chrome::GetActiveDesktop()); | 774 chrome::GetActiveDesktop()); |
772 if (browser) { | 775 if (browser) { |
773 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 776 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
774 initial_pos, user_gesture, was_blocked); | 777 initial_pos, user_gesture, was_blocked); |
775 } | 778 } |
776 } | 779 } |
OLD | NEW |