Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: chrome/browser/background/background_contents_service.cc

Issue 9146028: Define the public interface for content browser SiteInstance. This interface is implemented by th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
36 using content::WebContents; 37 using content::WebContents;
37 38
38 namespace { 39 namespace {
39 40
40 const char kNotificationPrefix[] = "app.background.crashed."; 41 const char kNotificationPrefix[] = "app.background.crashed.";
41 42
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 const string16& application_id) { 442 const string16& application_id) {
442 // We are depending on the fact that we will initialize before any user 443 // 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 444 // actions or session restore can take place, so no BackgroundContents should
444 // be running yet for the passed application_id. 445 // be running yet for the passed application_id.
445 DCHECK(!GetAppBackgroundContents(application_id)); 446 DCHECK(!GetAppBackgroundContents(application_id));
446 DCHECK(!application_id.empty()); 447 DCHECK(!application_id.empty());
447 DCHECK(url.is_valid()); 448 DCHECK(url.is_valid());
448 DVLOG(1) << "Loading background content url: " << url; 449 DVLOG(1) << "Loading background content url: " << url;
449 450
450 BackgroundContents* contents = CreateBackgroundContents( 451 BackgroundContents* contents = CreateBackgroundContents(
451 SiteInstance::CreateSiteInstanceForURL(profile, url), 452 content::SiteInstance::CreateSiteInstanceForURL(profile, url),
452 MSG_ROUTING_NONE, 453 MSG_ROUTING_NONE,
453 profile, 454 profile,
454 frame_name, 455 frame_name,
455 application_id); 456 application_id);
456 457
457 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing 458 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing
458 // startup latency (http://crbug.com/47236). 459 // startup latency (http://crbug.com/47236).
459 contents->web_contents()->GetController().LoadURL( 460 contents->web_contents()->GetController().LoadURL(
460 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); 461 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string());
461 } 462 }
462 463
463 BackgroundContents* BackgroundContentsService::CreateBackgroundContents( 464 BackgroundContents* BackgroundContentsService::CreateBackgroundContents(
464 SiteInstance* site, 465 content::SiteInstance* site,
465 int routing_id, 466 int routing_id,
466 Profile* profile, 467 Profile* profile,
467 const string16& frame_name, 468 const string16& frame_name,
468 const string16& application_id) { 469 const string16& application_id) {
469 BackgroundContents* contents = new BackgroundContents(site, routing_id, this); 470 BackgroundContents* contents = new BackgroundContents(site, routing_id, this);
470 471
471 // Register the BackgroundContents internally, then send out a notification 472 // Register the BackgroundContents internally, then send out a notification
472 // to external listeners. 473 // to external listeners.
473 BackgroundContentsOpenedDetails details = {contents, 474 BackgroundContentsOpenedDetails details = {contents,
474 frame_name, 475 frame_name,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 WebContents* new_contents, 572 WebContents* new_contents,
572 WindowOpenDisposition disposition, 573 WindowOpenDisposition disposition,
573 const gfx::Rect& initial_pos, 574 const gfx::Rect& initial_pos,
574 bool user_gesture) { 575 bool user_gesture) {
575 Browser* browser = BrowserList::GetLastActiveWithProfile( 576 Browser* browser = BrowserList::GetLastActiveWithProfile(
576 Profile::FromBrowserContext(new_contents->GetBrowserContext())); 577 Profile::FromBrowserContext(new_contents->GetBrowserContext()));
577 if (!browser) 578 if (!browser)
578 return; 579 return;
579 browser->AddWebContents(new_contents, disposition, initial_pos, user_gesture); 580 browser->AddWebContents(new_contents, disposition, initial_pos, user_gesture);
580 } 581 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698