| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/background/background_contents_service_factory.h" | 13 #include "chrome/browser/background/background_contents_service_factory.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/extensions/extension_host.h" | 15 #include "chrome/browser/extensions/extension_host.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/notifications/desktop_notification_service.h" | 17 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 18 #include "chrome/browser/notifications/notification.h" | 18 #include "chrome/browser/notifications/notification.h" |
| 19 #include "chrome/browser/notifications/notification_ui_manager.h" | 19 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
| 28 #include "chrome/common/extensions/extension_constants.h" | 28 #include "chrome/common/extensions/extension_constants.h" |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "content/browser/renderer_host/render_view_host.h" | |
| 31 #include "content/browser/site_instance.h" | 30 #include "content/browser/site_instance.h" |
| 32 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
| 33 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 34 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 36 | 35 |
| 37 namespace { | 36 namespace { |
| 38 | 37 |
| 39 const char kNotificationPrefix[] = "app.background.crashed."; | 38 const char kNotificationPrefix[] = "app.background.crashed."; |
| 40 | 39 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 DCHECK(url.is_valid()); | 446 DCHECK(url.is_valid()); |
| 448 DVLOG(1) << "Loading background content url: " << url; | 447 DVLOG(1) << "Loading background content url: " << url; |
| 449 | 448 |
| 450 BackgroundContents* contents = CreateBackgroundContents( | 449 BackgroundContents* contents = CreateBackgroundContents( |
| 451 SiteInstance::CreateSiteInstanceForURL(profile, url), | 450 SiteInstance::CreateSiteInstanceForURL(profile, url), |
| 452 MSG_ROUTING_NONE, | 451 MSG_ROUTING_NONE, |
| 453 profile, | 452 profile, |
| 454 frame_name, | 453 frame_name, |
| 455 application_id); | 454 application_id); |
| 456 | 455 |
| 457 RenderViewHost* render_view_host = contents->render_view_host(); | |
| 458 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing | 456 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing |
| 459 // startup latency (http://crbug.com/47236). | 457 // startup latency (http://crbug.com/47236). |
| 460 render_view_host->CreateRenderView(frame_name); | 458 contents->tab_contents()->controller().LoadURL( |
| 461 render_view_host->NavigateToURL(url); | 459 url, GURL(), content::PAGE_TRANSITION_LINK, std::string()); |
| 462 } | 460 } |
| 463 | 461 |
| 464 BackgroundContents* BackgroundContentsService::CreateBackgroundContents( | 462 BackgroundContents* BackgroundContentsService::CreateBackgroundContents( |
| 465 SiteInstance* site, | 463 SiteInstance* site, |
| 466 int routing_id, | 464 int routing_id, |
| 467 Profile* profile, | 465 Profile* profile, |
| 468 const string16& frame_name, | 466 const string16& frame_name, |
| 469 const string16& application_id) { | 467 const string16& application_id) { |
| 470 BackgroundContents* contents = new BackgroundContents(site, routing_id, this); | 468 BackgroundContents* contents = new BackgroundContents(site, routing_id, this); |
| 471 | 469 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 TabContents* new_contents, | 572 TabContents* new_contents, |
| 575 WindowOpenDisposition disposition, | 573 WindowOpenDisposition disposition, |
| 576 const gfx::Rect& initial_pos, | 574 const gfx::Rect& initial_pos, |
| 577 bool user_gesture) { | 575 bool user_gesture) { |
| 578 Browser* browser = BrowserList::GetLastActiveWithProfile( | 576 Browser* browser = BrowserList::GetLastActiveWithProfile( |
| 579 Profile::FromBrowserContext(new_contents->browser_context())); | 577 Profile::FromBrowserContext(new_contents->browser_context())); |
| 580 if (!browser) | 578 if (!browser) |
| 581 return; | 579 return; |
| 582 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); | 580 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); |
| 583 } | 581 } |
| OLD | NEW |