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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/browser/background/background_contents_service_factory.h" | 14 #include "chrome/browser/background/background_contents_service_factory.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/extensions/extension_host.h" | 16 #include "chrome/browser/extensions/extension_host.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/notifications/desktop_notification_service.h" | 18 #include "chrome/browser/notifications/desktop_notification_service.h" |
18 #include "chrome/browser/notifications/notification.h" | 19 #include "chrome/browser/notifications/notification.h" |
19 #include "chrome/browser/notifications/notification_ui_manager.h" | 20 #include "chrome/browser/notifications/notification_ui_manager.h" |
20 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
21 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 22 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_list.h" | 25 #include "chrome/browser/ui/browser_list.h" |
25 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
28 #include "chrome/common/extensions/extension_constants.h" | 29 #include "chrome/common/extensions/extension_constants.h" |
29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
30 #include "content/browser/site_instance.h" | |
31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/site_instance.h" |
32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
33 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
35 | 36 |
| 37 using content::SiteInstance; |
36 using content::WebContents; | 38 using content::WebContents; |
37 | 39 |
38 namespace { | 40 namespace { |
39 | 41 |
40 const char kNotificationPrefix[] = "app.background.crashed."; | 42 const char kNotificationPrefix[] = "app.background.crashed."; |
41 | 43 |
42 void CloseBalloon(const std::string id) { | 44 void CloseBalloon(const std::string id) { |
43 g_browser_process->notification_ui_manager()->CancelById(id); | 45 g_browser_process->notification_ui_manager()->CancelById(id); |
44 } | 46 } |
45 | 47 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 const string16& application_id) { | 443 const string16& application_id) { |
442 // We are depending on the fact that we will initialize before any user | 444 // We are depending on the fact that we will initialize before any user |
443 // actions or session restore can take place, so no BackgroundContents should | 445 // actions or session restore can take place, so no BackgroundContents should |
444 // be running yet for the passed application_id. | 446 // be running yet for the passed application_id. |
445 DCHECK(!GetAppBackgroundContents(application_id)); | 447 DCHECK(!GetAppBackgroundContents(application_id)); |
446 DCHECK(!application_id.empty()); | 448 DCHECK(!application_id.empty()); |
447 DCHECK(url.is_valid()); | 449 DCHECK(url.is_valid()); |
448 DVLOG(1) << "Loading background content url: " << url; | 450 DVLOG(1) << "Loading background content url: " << url; |
449 | 451 |
450 BackgroundContents* contents = CreateBackgroundContents( | 452 BackgroundContents* contents = CreateBackgroundContents( |
451 SiteInstance::CreateSiteInstanceForURL(profile, url), | 453 SiteInstance::CreateForURL(profile, url), |
452 MSG_ROUTING_NONE, | 454 MSG_ROUTING_NONE, |
453 profile, | 455 profile, |
454 frame_name, | 456 frame_name, |
455 application_id); | 457 application_id); |
456 | 458 |
457 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing | 459 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing |
458 // startup latency (http://crbug.com/47236). | 460 // startup latency (http://crbug.com/47236). |
459 contents->web_contents()->GetController().LoadURL( | 461 contents->web_contents()->GetController().LoadURL( |
460 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 462 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
461 } | 463 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 WebContents* new_contents, | 573 WebContents* new_contents, |
572 WindowOpenDisposition disposition, | 574 WindowOpenDisposition disposition, |
573 const gfx::Rect& initial_pos, | 575 const gfx::Rect& initial_pos, |
574 bool user_gesture) { | 576 bool user_gesture) { |
575 Browser* browser = BrowserList::GetLastActiveWithProfile( | 577 Browser* browser = BrowserList::GetLastActiveWithProfile( |
576 Profile::FromBrowserContext(new_contents->GetBrowserContext())); | 578 Profile::FromBrowserContext(new_contents->GetBrowserContext())); |
577 if (!browser) | 579 if (!browser) |
578 return; | 580 return; |
579 browser->AddWebContents(new_contents, disposition, initial_pos, user_gesture); | 581 browser->AddWebContents(new_contents, disposition, initial_pos, user_gesture); |
580 } | 582 } |
OLD | NEW |