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

Side by Side Diff: chrome/browser/tab_contents/background_contents.cc

Issue 7492051: Revert 94332 - Removal of Profile from content part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 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) 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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Exposed to allow creating mocks. 46 // Exposed to allow creating mocks.
47 BackgroundContents::BackgroundContents() 47 BackgroundContents::BackgroundContents()
48 : delegate_(NULL), 48 : delegate_(NULL),
49 render_view_host_(NULL) { 49 render_view_host_(NULL) {
50 } 50 }
51 51
52 BackgroundContents::~BackgroundContents() { 52 BackgroundContents::~BackgroundContents() {
53 if (!render_view_host_) // Will be null for unit tests. 53 if (!render_view_host_) // Will be null for unit tests.
54 return; 54 return;
55 Profile* profile = Profile::FromBrowserContext( 55 Profile* profile = render_view_host_->process()->profile();
56 render_view_host_->process()->browser_context());
57 NotificationService::current()->Notify( 56 NotificationService::current()->Notify(
58 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, 57 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
59 Source<Profile>(profile), 58 Source<Profile>(profile),
60 Details<BackgroundContents>(this)); 59 Details<BackgroundContents>(this));
61 render_view_host_->Shutdown(); // deletes render_view_host 60 render_view_host_->Shutdown(); // deletes render_view_host
62 } 61 }
63 62
64 BackgroundContents* BackgroundContents::GetAsBackgroundContents() { 63 BackgroundContents* BackgroundContents::GetAsBackgroundContents() {
65 return this; 64 return this;
66 } 65 }
(...skipping 19 matching lines...) Expand all
86 85
87 // Note: because BackgroundContents are only available to extension apps, 86 // Note: because BackgroundContents are only available to extension apps,
88 // navigation is limited to urls within the app's extent. This is enforced in 87 // navigation is limited to urls within the app's extent. This is enforced in
89 // RenderView::decidePolicyForNaviation. If BackgroundContents become 88 // RenderView::decidePolicyForNaviation. If BackgroundContents become
90 // available as a part of the web platform, it probably makes sense to have 89 // available as a part of the web platform, it probably makes sense to have
91 // some way to scope navigation of a background page to its opener's security 90 // some way to scope navigation of a background page to its opener's security
92 // origin. Note: if the first navigation is to a URL outside the app's 91 // origin. Note: if the first navigation is to a URL outside the app's
93 // extent a background page will be opened but will remain at about:blank. 92 // extent a background page will be opened but will remain at about:blank.
94 url_ = params.url; 93 url_ = params.url;
95 94
96 Profile* profile = Profile::FromBrowserContext( 95 Profile* profile = render_view_host->process()->profile();
97 render_view_host->process()->browser_context());
98 NotificationService::current()->Notify( 96 NotificationService::current()->Notify(
99 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, 97 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED,
100 Source<Profile>(profile), 98 Source<Profile>(profile),
101 Details<BackgroundContents>(this)); 99 Details<BackgroundContents>(this));
102 } 100 }
103 101
104 void BackgroundContents::RunJavaScriptMessage( 102 void BackgroundContents::RunJavaScriptMessage(
105 const RenderViewHost* rvh, 103 const RenderViewHost* rvh,
106 const string16& message, 104 const string16& message,
107 const string16& default_prompt, 105 const string16& default_prompt,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 success, 140 success,
143 user_input); 141 user_input);
144 } 142 }
145 143
146 gfx::NativeWindow BackgroundContents::GetDialogRootWindow() { 144 gfx::NativeWindow BackgroundContents::GetDialogRootWindow() {
147 NOTIMPLEMENTED(); 145 NOTIMPLEMENTED();
148 return NULL; 146 return NULL;
149 } 147 }
150 148
151 void BackgroundContents::Close(RenderViewHost* render_view_host) { 149 void BackgroundContents::Close(RenderViewHost* render_view_host) {
152 Profile* profile = Profile::FromBrowserContext( 150 Profile* profile = render_view_host->process()->profile();
153 render_view_host->process()->browser_context());
154 NotificationService::current()->Notify( 151 NotificationService::current()->Notify(
155 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, 152 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED,
156 Source<Profile>(profile), 153 Source<Profile>(profile),
157 Details<BackgroundContents>(this)); 154 Details<BackgroundContents>(this));
158 delete this; 155 delete this;
159 } 156 }
160 157
161 void BackgroundContents::RenderViewGone(RenderViewHost* rvh, 158 void BackgroundContents::RenderViewGone(RenderViewHost* rvh,
162 base::TerminationStatus status, 159 base::TerminationStatus status,
163 int error_code) { 160 int error_code) {
164 Profile* profile = 161 Profile* profile = rvh->process()->profile();
165 Profile::FromBrowserContext(rvh->process()->browser_context());
166 NotificationService::current()->Notify( 162 NotificationService::current()->Notify(
167 chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, 163 chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED,
168 Source<Profile>(profile), 164 Source<Profile>(profile),
169 Details<BackgroundContents>(this)); 165 Details<BackgroundContents>(this));
170 166
171 // 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
172 // via the TaskManager doesn't permanently leave a BackgroundContents hanging 168 // via the TaskManager doesn't permanently leave a BackgroundContents hanging
173 // around the system, blocking future instances from being created 169 // around the system, blocking future instances from being created
174 // (http://crbug.com/65189). 170 // (http://crbug.com/65189).
175 delete this; 171 delete this;
176 } 172 }
177 173
178 RendererPreferences BackgroundContents::GetRendererPrefs( 174 RendererPreferences BackgroundContents::GetRendererPrefs(
179 content::BrowserContext* browser_context) const { 175 content::BrowserContext* browser_context) const {
180 Profile* profile = Profile::FromBrowserContext(browser_context); 176 Profile* profile = Profile::FromBrowserContext(browser_context);
181 RendererPreferences preferences; 177 RendererPreferences preferences;
182 renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile); 178 renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile);
183 return preferences; 179 return preferences;
184 } 180 }
185 181
186 WebPreferences BackgroundContents::GetWebkitPrefs() { 182 WebPreferences BackgroundContents::GetWebkitPrefs() {
187 // TODO(rafaelw): Consider enabling the webkit_prefs.dom_paste_enabled for 183 // TODO(rafaelw): Consider enabling the webkit_prefs.dom_paste_enabled for
188 // apps. 184 // apps.
189 Profile* profile = Profile::FromBrowserContext( 185 Profile* profile = render_view_host_->process()->profile();
190 render_view_host_->process()->browser_context());
191 return RenderViewHostDelegateHelper::GetWebkitPrefs(profile, 186 return RenderViewHostDelegateHelper::GetWebkitPrefs(profile,
192 false); // is_web_ui 187 false); // is_web_ui
193 } 188 }
194 189
195 void BackgroundContents::CreateNewWindow( 190 void BackgroundContents::CreateNewWindow(
196 int route_id, 191 int route_id,
197 const ViewHostMsg_CreateWindow_Params& params) { 192 const ViewHostMsg_CreateWindow_Params& params) {
198 Profile* profile = Profile::FromBrowserContext(
199 render_view_host_->process()->browser_context());
200 delegate_view_helper_.CreateNewWindow( 193 delegate_view_helper_.CreateNewWindow(
201 route_id, 194 route_id,
202 profile, 195 render_view_host_->process()->profile(),
203 render_view_host_->site_instance(), 196 render_view_host_->site_instance(),
204 ChromeWebUIFactory::GetInstance()->GetWebUIType(profile, url_), 197 ChromeWebUIFactory::GetInstance()->GetWebUIType(
198 render_view_host_->process()->profile(), url_),
205 this, 199 this,
206 params.window_container_type, 200 params.window_container_type,
207 params.frame_name); 201 params.frame_name);
208 } 202 }
209 203
210 void BackgroundContents::CreateNewWidget(int route_id, 204 void BackgroundContents::CreateNewWidget(int route_id,
211 WebKit::WebPopupType popup_type) { 205 WebKit::WebPopupType popup_type) {
212 NOTREACHED(); 206 NOTREACHED();
213 } 207 }
214 208
(...skipping 23 matching lines...) Expand all
238 BackgroundContents* 232 BackgroundContents*
239 BackgroundContents::GetBackgroundContentsByID(int render_process_id, 233 BackgroundContents::GetBackgroundContentsByID(int render_process_id,
240 int render_view_id) { 234 int render_view_id) {
241 RenderViewHost* render_view_host = 235 RenderViewHost* render_view_host =
242 RenderViewHost::FromID(render_process_id, render_view_id); 236 RenderViewHost::FromID(render_process_id, render_view_id);
243 if (!render_view_host) 237 if (!render_view_host)
244 return NULL; 238 return NULL;
245 239
246 return render_view_host->delegate()->GetAsBackgroundContents(); 240 return render_view_host->delegate()->GetAsBackgroundContents();
247 } 241 }
OLDNEW
« no previous file with comments | « chrome/browser/spellcheck_message_filter.cc ('k') | chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698