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 "content/browser/renderer_host/render_view_host.h" | 5 #include "content/browser/renderer_host/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 run_modal_reply_msg_(NULL), | 97 run_modal_reply_msg_(NULL), |
98 is_waiting_for_beforeunload_ack_(false), | 98 is_waiting_for_beforeunload_ack_(false), |
99 is_waiting_for_unload_ack_(false), | 99 is_waiting_for_unload_ack_(false), |
100 unload_ack_is_for_cross_site_transition_(false), | 100 unload_ack_is_for_cross_site_transition_(false), |
101 are_javascript_messages_suppressed_(false), | 101 are_javascript_messages_suppressed_(false), |
102 sudden_termination_allowed_(false), | 102 sudden_termination_allowed_(false), |
103 session_storage_namespace_(session_storage), | 103 session_storage_namespace_(session_storage), |
104 save_accessibility_tree_for_testing_(false), | 104 save_accessibility_tree_for_testing_(false), |
105 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { | 105 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { |
106 if (!session_storage_namespace_) { | 106 if (!session_storage_namespace_) { |
107 session_storage_namespace_ = new SessionStorageNamespace( | 107 session_storage_namespace_ = |
108 process()->browser_context()->GetWebKitContext()); | 108 new SessionStorageNamespace(process()->profile()->GetWebKitContext()); |
109 } | 109 } |
110 | 110 |
111 DCHECK(instance_); | 111 DCHECK(instance_); |
112 CHECK(delegate_); // http://crbug.com/82827 | 112 CHECK(delegate_); // http://crbug.com/82827 |
113 | 113 |
114 process()->EnableSendQueue(); | 114 process()->EnableSendQueue(); |
115 | 115 |
116 content::GetContentClient()->browser()->RenderViewHostCreated(this); | 116 content::GetContentClient()->browser()->RenderViewHostCreated(this); |
117 | 117 |
118 NotificationService::current()->Notify( | 118 NotificationService::current()->Notify( |
(...skipping 21 matching lines...) Expand all Loading... |
140 bool RenderViewHost::CreateRenderView(const string16& frame_name) { | 140 bool RenderViewHost::CreateRenderView(const string16& frame_name) { |
141 DCHECK(!IsRenderViewLive()) << "Creating view twice"; | 141 DCHECK(!IsRenderViewLive()) << "Creating view twice"; |
142 | 142 |
143 // The process may (if we're sharing a process with another host that already | 143 // The process may (if we're sharing a process with another host that already |
144 // initialized it) or may not (we have our own process or the old process | 144 // initialized it) or may not (we have our own process or the old process |
145 // crashed) have been initialized. Calling Init multiple times will be | 145 // crashed) have been initialized. Calling Init multiple times will be |
146 // ignored, so this is safe. | 146 // ignored, so this is safe. |
147 if (!process()->Init(renderer_accessible())) | 147 if (!process()->Init(renderer_accessible())) |
148 return false; | 148 return false; |
149 DCHECK(process()->HasConnection()); | 149 DCHECK(process()->HasConnection()); |
150 DCHECK(process()->browser_context()); | 150 DCHECK(process()->profile()); |
151 | 151 |
152 if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_)) { | 152 if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_)) { |
153 ChildProcessSecurityPolicy::GetInstance()->GrantWebUIBindings( | 153 ChildProcessSecurityPolicy::GetInstance()->GrantWebUIBindings( |
154 process()->id()); | 154 process()->id()); |
155 } | 155 } |
156 | 156 |
157 if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) { | 157 if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) { |
158 ChildProcessSecurityPolicy::GetInstance()->GrantExtensionBindings( | 158 ChildProcessSecurityPolicy::GetInstance()->GrantExtensionBindings( |
159 process()->id()); | 159 process()->id()); |
160 } | 160 } |
161 | 161 |
162 renderer_initialized_ = true; | 162 renderer_initialized_ = true; |
163 | 163 |
164 process()->SetCompositingSurface(routing_id(), | 164 process()->SetCompositingSurface(routing_id(), |
165 GetCompositingSurface()); | 165 GetCompositingSurface()); |
166 | 166 |
167 ViewMsg_New_Params params; | 167 ViewMsg_New_Params params; |
168 params.parent_window = GetNativeViewId(); | 168 params.parent_window = GetNativeViewId(); |
169 params.renderer_preferences = | 169 params.renderer_preferences = |
170 delegate_->GetRendererPrefs(process()->browser_context()); | 170 delegate_->GetRendererPrefs(process()->profile()); |
171 params.web_preferences = delegate_->GetWebkitPrefs(); | 171 params.web_preferences = delegate_->GetWebkitPrefs(); |
172 params.view_id = routing_id(); | 172 params.view_id = routing_id(); |
173 params.session_storage_namespace_id = session_storage_namespace_->id(); | 173 params.session_storage_namespace_id = session_storage_namespace_->id(); |
174 params.frame_name = frame_name; | 174 params.frame_name = frame_name; |
175 Send(new ViewMsg_New(params)); | 175 Send(new ViewMsg_New(params)); |
176 | 176 |
177 // If it's enabled, tell the renderer to set up the Javascript bindings for | 177 // If it's enabled, tell the renderer to set up the Javascript bindings for |
178 // sending messages back to the browser. | 178 // sending messages back to the browser. |
179 Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); | 179 Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); |
180 // Let our delegate know that we created a RenderView. | 180 // Let our delegate know that we created a RenderView. |
181 delegate_->RenderViewCreated(this); | 181 delegate_->RenderViewCreated(this); |
182 | 182 |
183 FOR_EACH_OBSERVER( | 183 FOR_EACH_OBSERVER( |
184 RenderViewHostObserver, observers_, RenderViewHostInitialized()); | 184 RenderViewHostObserver, observers_, RenderViewHostInitialized()); |
185 | 185 |
186 return true; | 186 return true; |
187 } | 187 } |
188 | 188 |
189 bool RenderViewHost::IsRenderViewLive() const { | 189 bool RenderViewHost::IsRenderViewLive() const { |
190 return process()->HasConnection() && renderer_initialized_; | 190 return process()->HasConnection() && renderer_initialized_; |
191 } | 191 } |
192 | 192 |
193 void RenderViewHost::SyncRendererPrefs() { | 193 void RenderViewHost::SyncRendererPrefs() { |
194 Send(new ViewMsg_SetRendererPrefs(routing_id(), | 194 Send(new ViewMsg_SetRendererPrefs(routing_id(), |
195 delegate_->GetRendererPrefs( | 195 delegate_->GetRendererPrefs( |
196 process()->browser_context()))); | 196 process()->profile()))); |
197 } | 197 } |
198 | 198 |
199 void RenderViewHost::Navigate(const ViewMsg_Navigate_Params& params) { | 199 void RenderViewHost::Navigate(const ViewMsg_Navigate_Params& params) { |
200 ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( | 200 ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( |
201 process()->id(), params.url); | 201 process()->id(), params.url); |
202 | 202 |
203 ViewMsg_Navigate* nav_message = new ViewMsg_Navigate(routing_id(), params); | 203 ViewMsg_Navigate* nav_message = new ViewMsg_Navigate(routing_id(), params); |
204 | 204 |
205 // Only send the message if we aren't suspended at the start of a cross-site | 205 // Only send the message if we aren't suspended at the start of a cross-site |
206 // request. | 206 // request. |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 NotificationService::current()->Notify( | 1253 NotificationService::current()->Notify( |
1254 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, | 1254 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, |
1255 Source<RenderViewHost>(this), | 1255 Source<RenderViewHost>(this), |
1256 Details<std::pair<int, Value*> >(&details)); | 1256 Details<std::pair<int, Value*> >(&details)); |
1257 } | 1257 } |
1258 | 1258 |
1259 void RenderViewHost::OnDidZoomURL(double zoom_level, | 1259 void RenderViewHost::OnDidZoomURL(double zoom_level, |
1260 bool remember, | 1260 bool remember, |
1261 const GURL& url) { | 1261 const GURL& url) { |
1262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1263 HostZoomMap* host_zoom_map = process()->browser_context()->GetHostZoomMap(); | 1263 HostZoomMap* host_zoom_map = process()->profile()->GetHostZoomMap(); |
1264 if (remember) { | 1264 if (remember) { |
1265 host_zoom_map->SetZoomLevel(net::GetHostOrSpecFromURL(url), zoom_level); | 1265 host_zoom_map->SetZoomLevel(net::GetHostOrSpecFromURL(url), zoom_level); |
1266 // Notify renderers from this profile. | 1266 // Notify renderers from this profile. |
1267 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 1267 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
1268 !i.IsAtEnd(); i.Advance()) { | 1268 !i.IsAtEnd(); i.Advance()) { |
1269 RenderProcessHost* render_process_host = i.GetCurrentValue(); | 1269 RenderProcessHost* render_process_host = i.GetCurrentValue(); |
1270 if (render_process_host->browser_context() == | 1270 if (render_process_host->profile() == process()->profile()) { |
1271 process()->browser_context()) { | |
1272 render_process_host->Send( | 1271 render_process_host->Send( |
1273 new ViewMsg_SetZoomLevelForCurrentURL(url, zoom_level)); | 1272 new ViewMsg_SetZoomLevelForCurrentURL(url, zoom_level)); |
1274 } | 1273 } |
1275 } | 1274 } |
1276 } else { | 1275 } else { |
1277 host_zoom_map->SetTemporaryZoomLevel( | 1276 host_zoom_map->SetTemporaryZoomLevel( |
1278 process()->id(), routing_id(), zoom_level); | 1277 process()->id(), routing_id(), zoom_level); |
1279 } | 1278 } |
1280 } | 1279 } |
1281 | 1280 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 if (view) { | 1313 if (view) { |
1315 view->ShowPopupMenu(params.bounds, | 1314 view->ShowPopupMenu(params.bounds, |
1316 params.item_height, | 1315 params.item_height, |
1317 params.item_font_size, | 1316 params.item_font_size, |
1318 params.selected_item, | 1317 params.selected_item, |
1319 params.popup_items, | 1318 params.popup_items, |
1320 params.right_aligned); | 1319 params.right_aligned); |
1321 } | 1320 } |
1322 } | 1321 } |
1323 #endif | 1322 #endif |
OLD | NEW |