| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "content/browser/browser_context.h" | 19 #include "content/browser/browser_context.h" |
| 20 #include "content/browser/browser_message_filter.h" | 20 #include "content/browser/browser_message_filter.h" |
| 21 #include "content/browser/child_process_security_policy.h" | 21 #include "content/browser/child_process_security_policy.h" |
| 22 #include "content/browser/cross_site_request_manager.h" | 22 #include "content/browser/cross_site_request_manager.h" |
| 23 #include "content/browser/host_zoom_map.h" | 23 #include "content/browser/host_zoom_map.h" |
| 24 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 24 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
| 25 #include "content/browser/power_save_blocker.h" | 25 #include "content/browser/power_save_blocker.h" |
| 26 #include "content/browser/renderer_host/render_process_host_impl.h" | 26 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 27 #include "content/browser/renderer_host/render_view_host_delegate.h" | 27 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 28 #include "content/browser/renderer_host/render_view_host_observer.h" | |
| 29 #include "content/browser/renderer_host/render_widget_host.h" | 28 #include "content/browser/renderer_host/render_widget_host.h" |
| 30 #include "content/browser/renderer_host/render_widget_host_view.h" | 29 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 31 #include "content/browser/site_instance.h" | 30 #include "content/browser/site_instance.h" |
| 32 #include "content/browser/user_metrics.h" | 31 #include "content/browser/user_metrics.h" |
| 33 #include "content/common/desktop_notification_messages.h" | 32 #include "content/common/desktop_notification_messages.h" |
| 34 #include "content/common/drag_messages.h" | 33 #include "content/common/drag_messages.h" |
| 35 #include "content/common/speech_input_messages.h" | 34 #include "content/common/speech_input_messages.h" |
| 36 #include "content/common/swapped_out_messages.h" | 35 #include "content/common/swapped_out_messages.h" |
| 37 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
| 38 #include "content/public/browser/content_browser_client.h" | 37 #include "content/public/browser/content_browser_client.h" |
| 39 #include "content/public/browser/native_web_keyboard_event.h" | 38 #include "content/public/browser/native_web_keyboard_event.h" |
| 40 #include "content/public/browser/notification_details.h" | 39 #include "content/public/browser/notification_details.h" |
| 41 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/notification_types.h" | 41 #include "content/public/browser/notification_types.h" |
| 42 #include "content/public/browser/render_view_host_observer.h" |
| 43 #include "content/public/common/bindings_policy.h" | 43 #include "content/public/common/bindings_policy.h" |
| 44 #include "content/public/common/content_constants.h" | 44 #include "content/public/common/content_constants.h" |
| 45 #include "content/public/common/result_codes.h" | 45 #include "content/public/common/result_codes.h" |
| 46 #include "content/public/common/url_constants.h" | 46 #include "content/public/common/url_constants.h" |
| 47 #include "net/base/net_util.h" | 47 #include "net/base/net_util.h" |
| 48 #include "net/url_request/url_request_context_getter.h" | 48 #include "net/url_request/url_request_context_getter.h" |
| 49 #include "third_party/skia/include/core/SkBitmap.h" | 49 #include "third_party/skia/include/core/SkBitmap.h" |
| 50 #include "ui/gfx/native_widget_types.h" | 50 #include "ui/gfx/native_widget_types.h" |
| 51 #include "webkit/glue/context_menu.h" | 51 #include "webkit/glue/context_menu.h" |
| 52 #include "webkit/glue/webaccessibility.h" | 52 #include "webkit/glue/webaccessibility.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 content::GetContentClient()->browser()->RenderViewHostCreated(this); | 134 content::GetContentClient()->browser()->RenderViewHostCreated(this); |
| 135 | 135 |
| 136 content::NotificationService::current()->Notify( | 136 content::NotificationService::current()->Notify( |
| 137 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, | 137 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, |
| 138 content::Source<RenderViewHost>(this), | 138 content::Source<RenderViewHost>(this), |
| 139 content::NotificationService::NoDetails()); | 139 content::NotificationService::NoDetails()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 RenderViewHost::~RenderViewHost() { | 142 RenderViewHost::~RenderViewHost() { |
| 143 FOR_EACH_OBSERVER( | 143 FOR_EACH_OBSERVER( |
| 144 RenderViewHostObserver, observers_, RenderViewHostDestruction()); | 144 content::RenderViewHostObserver, observers_, RenderViewHostDestruction()); |
| 145 | 145 |
| 146 content::NotificationService::current()->Notify( | 146 content::NotificationService::current()->Notify( |
| 147 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, | 147 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, |
| 148 content::Source<RenderViewHost>(this), | 148 content::Source<RenderViewHost>(this), |
| 149 content::NotificationService::NoDetails()); | 149 content::NotificationService::NoDetails()); |
| 150 | 150 |
| 151 ClearPowerSaveBlockers(); | 151 ClearPowerSaveBlockers(); |
| 152 | 152 |
| 153 delegate()->RenderViewDeleted(this); | 153 delegate()->RenderViewDeleted(this); |
| 154 | 154 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 184 params.frame_name = frame_name; | 184 params.frame_name = frame_name; |
| 185 Send(new ViewMsg_New(params)); | 185 Send(new ViewMsg_New(params)); |
| 186 | 186 |
| 187 // If it's enabled, tell the renderer to set up the Javascript bindings for | 187 // If it's enabled, tell the renderer to set up the Javascript bindings for |
| 188 // sending messages back to the browser. | 188 // sending messages back to the browser. |
| 189 Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); | 189 Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); |
| 190 // Let our delegate know that we created a RenderView. | 190 // Let our delegate know that we created a RenderView. |
| 191 delegate_->RenderViewCreated(this); | 191 delegate_->RenderViewCreated(this); |
| 192 | 192 |
| 193 FOR_EACH_OBSERVER( | 193 FOR_EACH_OBSERVER( |
| 194 RenderViewHostObserver, observers_, RenderViewHostInitialized()); | 194 content::RenderViewHostObserver, observers_, RenderViewHostInitialized()); |
| 195 | 195 |
| 196 return true; | 196 return true; |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool RenderViewHost::IsRenderViewLive() const { | 199 bool RenderViewHost::IsRenderViewLive() const { |
| 200 return process()->HasConnection() && renderer_initialized_; | 200 return process()->HasConnection() && renderer_initialized_; |
| 201 } | 201 } |
| 202 | 202 |
| 203 void RenderViewHost::SyncRendererPrefs() { | 203 void RenderViewHost::SyncRendererPrefs() { |
| 204 Send(new ViewMsg_SetRendererPrefs(routing_id(), | 204 Send(new ViewMsg_SetRendererPrefs(routing_id(), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // user naivgates even if the renderer is delayed. There is also an issue | 240 // user naivgates even if the renderer is delayed. There is also an issue |
| 241 // with the throbber starting because the WebUI (which controls whether the | 241 // with the throbber starting because the WebUI (which controls whether the |
| 242 // favicon is displayed) happens synchronously. If the start loading | 242 // favicon is displayed) happens synchronously. If the start loading |
| 243 // messages was asynchronous, then the default favicon would flash in. | 243 // messages was asynchronous, then the default favicon would flash in. |
| 244 // | 244 // |
| 245 // WebKit doesn't send throb notifications for JavaScript URLs, so we | 245 // WebKit doesn't send throb notifications for JavaScript URLs, so we |
| 246 // don't want to either. | 246 // don't want to either. |
| 247 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) | 247 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) |
| 248 delegate_->DidStartLoading(); | 248 delegate_->DidStartLoading(); |
| 249 | 249 |
| 250 FOR_EACH_OBSERVER(RenderViewHostObserver, observers_, Navigate(params.url)); | 250 FOR_EACH_OBSERVER(content::RenderViewHostObserver, |
| 251 observers_, Navigate(params.url)); |
| 251 } | 252 } |
| 252 | 253 |
| 253 void RenderViewHost::NavigateToURL(const GURL& url) { | 254 void RenderViewHost::NavigateToURL(const GURL& url) { |
| 254 ViewMsg_Navigate_Params params; | 255 ViewMsg_Navigate_Params params; |
| 255 params.page_id = -1; | 256 params.page_id = -1; |
| 256 params.pending_history_list_offset = -1; | 257 params.pending_history_list_offset = -1; |
| 257 params.current_history_list_offset = -1; | 258 params.current_history_list_offset = -1; |
| 258 params.current_history_list_length = 0; | 259 params.current_history_list_length = 0; |
| 259 params.url = url; | 260 params.url = url; |
| 260 params.transition = content::PAGE_TRANSITION_LINK; | 261 params.transition = content::PAGE_TRANSITION_LINK; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { | 647 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { |
| 647 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) | 648 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) |
| 648 return true; | 649 return true; |
| 649 | 650 |
| 650 // Filter out most IPC messages if this renderer is swapped out. | 651 // Filter out most IPC messages if this renderer is swapped out. |
| 651 // We still want to certain ACKs to keep our state consistent. | 652 // We still want to certain ACKs to keep our state consistent. |
| 652 if (is_swapped_out_) | 653 if (is_swapped_out_) |
| 653 if (!content::SwappedOutMessages::CanHandleWhileSwappedOut(msg)) | 654 if (!content::SwappedOutMessages::CanHandleWhileSwappedOut(msg)) |
| 654 return true; | 655 return true; |
| 655 | 656 |
| 656 ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); | 657 ObserverListBase<content::RenderViewHostObserver>::Iterator it(observers_); |
| 657 RenderViewHostObserver* observer; | 658 content::RenderViewHostObserver* observer; |
| 658 while ((observer = it.GetNext()) != NULL) { | 659 while ((observer = it.GetNext()) != NULL) { |
| 659 if (observer->OnMessageReceived(msg)) | 660 if (observer->OnMessageReceived(msg)) |
| 660 return true; | 661 return true; |
| 661 } | 662 } |
| 662 | 663 |
| 663 if (delegate_->OnMessageReceived(msg)) | 664 if (delegate_->OnMessageReceived(msg)) |
| 664 return true; | 665 return true; |
| 665 | 666 |
| 666 bool handled = true; | 667 bool handled = true; |
| 667 bool msg_is_ok = true; | 668 bool msg_is_ok = true; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 int32 line_no, | 1131 int32 line_no, |
| 1131 const string16& source_id) { | 1132 const string16& source_id) { |
| 1132 // Pass through log level only on WebUI pages to limit console spew. | 1133 // Pass through log level only on WebUI pages to limit console spew. |
| 1133 int32 resolved_level = | 1134 int32 resolved_level = |
| 1134 (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) ? level : 0; | 1135 (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) ? level : 0; |
| 1135 | 1136 |
| 1136 logging::LogMessage("CONSOLE", line_no, resolved_level).stream() << "\"" << | 1137 logging::LogMessage("CONSOLE", line_no, resolved_level).stream() << "\"" << |
| 1137 message << "\", source: " << source_id << " (" << line_no << ")"; | 1138 message << "\", source: " << source_id << " (" << line_no << ")"; |
| 1138 } | 1139 } |
| 1139 | 1140 |
| 1140 void RenderViewHost::AddObserver(RenderViewHostObserver* observer) { | 1141 void RenderViewHost::AddObserver(content::RenderViewHostObserver* observer) { |
| 1141 observers_.AddObserver(observer); | 1142 observers_.AddObserver(observer); |
| 1142 } | 1143 } |
| 1143 | 1144 |
| 1144 void RenderViewHost::RemoveObserver(RenderViewHostObserver* observer) { | 1145 void RenderViewHost::RemoveObserver(content::RenderViewHostObserver* observer) { |
| 1145 observers_.RemoveObserver(observer); | 1146 observers_.RemoveObserver(observer); |
| 1146 } | 1147 } |
| 1147 | 1148 |
| 1148 bool RenderViewHost::PreHandleKeyboardEvent( | 1149 bool RenderViewHost::PreHandleKeyboardEvent( |
| 1149 const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { | 1150 const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { |
| 1150 return delegate_->PreHandleKeyboardEvent(event, is_keyboard_shortcut); | 1151 return delegate_->PreHandleKeyboardEvent(event, is_keyboard_shortcut); |
| 1151 } | 1152 } |
| 1152 | 1153 |
| 1153 void RenderViewHost::UnhandledKeyboardEvent( | 1154 void RenderViewHost::UnhandledKeyboardEvent( |
| 1154 const NativeWebKeyboardEvent& event) { | 1155 const NativeWebKeyboardEvent& event) { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 | 1502 |
| 1502 void RenderViewHost::OnWebUISend(const GURL& source_url, | 1503 void RenderViewHost::OnWebUISend(const GURL& source_url, |
| 1503 const std::string& name, | 1504 const std::string& name, |
| 1504 const base::ListValue& args) { | 1505 const base::ListValue& args) { |
| 1505 delegate_->WebUISend(this, source_url, name, args); | 1506 delegate_->WebUISend(this, source_url, name, args); |
| 1506 } | 1507 } |
| 1507 | 1508 |
| 1508 void RenderViewHost::ClearPowerSaveBlockers() { | 1509 void RenderViewHost::ClearPowerSaveBlockers() { |
| 1509 STLDeleteValues(&power_save_blockers_); | 1510 STLDeleteValues(&power_save_blockers_); |
| 1510 } | 1511 } |
| OLD | NEW |