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/tab_contents/background_contents.h" | 5 #include "chrome/browser/tab_contents/background_contents.h" |
6 | 6 |
7 #include "chrome/browser/background/background_contents_service.h" | 7 #include "chrome/browser/background/background_contents_service.h" |
8 #include "chrome/browser/extensions/extension_message_service.h" | 8 #include "chrome/browser/extensions/extension_message_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/renderer_preferences_util.h" | 10 #include "chrome/browser/renderer_preferences_util.h" |
11 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" | 11 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" |
12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "content/browser/browsing_instance.h" | 15 #include "content/browser/browsing_instance.h" |
16 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
17 #include "content/browser/site_instance.h" | 17 #include "content/browser/site_instance.h" |
18 #include "content/common/notification_service.h" | 18 #include "content/common/notification_service.h" |
19 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
21 | 21 |
22 //////////////// | 22 //////////////// |
23 // BackgroundContents | 23 // BackgroundContents |
24 | 24 |
25 BackgroundContents::BackgroundContents(SiteInstance* site_instance, | 25 BackgroundContents::BackgroundContents(SiteInstance* site_instance, |
26 int routing_id, | 26 int routing_id, |
27 Delegate* delegate) | 27 Delegate* delegate) |
28 : delegate_(delegate) { | 28 : delegate_(delegate) { |
29 Profile* profile = site_instance->browsing_instance()->profile(); | 29 Profile* profile = Profile::FromBrowserContext( |
| 30 site_instance->browsing_instance()->browser_context()); |
30 | 31 |
31 // TODO(rafaelw): Implement correct session storage. | 32 // TODO(rafaelw): Implement correct session storage. |
32 render_view_host_ = new RenderViewHost(site_instance, this, routing_id, NULL); | 33 render_view_host_ = new RenderViewHost(site_instance, this, routing_id, NULL); |
33 | 34 |
34 // Close ourselves when the application is shutting down. | 35 // Close ourselves when the application is shutting down. |
35 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, | 36 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, |
36 NotificationService::AllSources()); | 37 NotificationService::AllSources()); |
37 | 38 |
38 // Register for our parent profile to shutdown, so we can shut ourselves down | 39 // Register for our parent profile to shutdown, so we can shut ourselves down |
39 // as well (should only be called for OTR profiles, as we should receive | 40 // as well (should only be called for OTR profiles, as we should receive |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 Details<BackgroundContents>(this)); | 165 Details<BackgroundContents>(this)); |
165 | 166 |
166 // Our RenderView went away, so we should go away also, so killing the process | 167 // Our RenderView went away, so we should go away also, so killing the process |
167 // via the TaskManager doesn't permanently leave a BackgroundContents hanging | 168 // via the TaskManager doesn't permanently leave a BackgroundContents hanging |
168 // around the system, blocking future instances from being created | 169 // around the system, blocking future instances from being created |
169 // (http://crbug.com/65189). | 170 // (http://crbug.com/65189). |
170 delete this; | 171 delete this; |
171 } | 172 } |
172 | 173 |
173 RendererPreferences BackgroundContents::GetRendererPrefs( | 174 RendererPreferences BackgroundContents::GetRendererPrefs( |
174 Profile* profile) const { | 175 content::BrowserContext* browser_context) const { |
| 176 Profile* profile = Profile::FromBrowserContext(browser_context); |
175 RendererPreferences preferences; | 177 RendererPreferences preferences; |
176 renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile); | 178 renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile); |
177 return preferences; | 179 return preferences; |
178 } | 180 } |
179 | 181 |
180 WebPreferences BackgroundContents::GetWebkitPrefs() { | 182 WebPreferences BackgroundContents::GetWebkitPrefs() { |
181 // TODO(rafaelw): Consider enabling the webkit_prefs.dom_paste_enabled for | 183 // TODO(rafaelw): Consider enabling the webkit_prefs.dom_paste_enabled for |
182 // apps. | 184 // apps. |
183 Profile* profile = render_view_host_->process()->profile(); | 185 Profile* profile = render_view_host_->process()->profile(); |
184 return RenderViewHostDelegateHelper::GetWebkitPrefs(profile, | 186 return RenderViewHostDelegateHelper::GetWebkitPrefs(profile, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 BackgroundContents* | 232 BackgroundContents* |
231 BackgroundContents::GetBackgroundContentsByID(int render_process_id, | 233 BackgroundContents::GetBackgroundContentsByID(int render_process_id, |
232 int render_view_id) { | 234 int render_view_id) { |
233 RenderViewHost* render_view_host = | 235 RenderViewHost* render_view_host = |
234 RenderViewHost::FromID(render_process_id, render_view_id); | 236 RenderViewHost::FromID(render_process_id, render_view_id); |
235 if (!render_view_host) | 237 if (!render_view_host) |
236 return NULL; | 238 return NULL; |
237 | 239 |
238 return render_view_host->delegate()->GetAsBackgroundContents(); | 240 return render_view_host->delegate()->GetAsBackgroundContents(); |
239 } | 241 } |
OLD | NEW |