OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/common/gfx/color_utils.h" | 24 #include "chrome/common/gfx/color_utils.h" |
25 #include "chrome/common/jstemplate_builder.h" | 25 #include "chrome/common/jstemplate_builder.h" |
26 #include "chrome/common/l10n_util.h" | 26 #include "chrome/common/l10n_util.h" |
27 #include "chrome/common/page_zoom.h" | 27 #include "chrome/common/page_zoom.h" |
28 #include "chrome/common/resource_bundle.h" | 28 #include "chrome/common/resource_bundle.h" |
29 #include "chrome/common/thumbnail_score.h" | 29 #include "chrome/common/thumbnail_score.h" |
30 #include "chrome/common/chrome_plugin_lib.h" | 30 #include "chrome/common/chrome_plugin_lib.h" |
31 #include "chrome/renderer/about_handler.h" | 31 #include "chrome/renderer/about_handler.h" |
32 #include "chrome/renderer/chrome_plugin_host.h" | 32 #include "chrome/renderer/chrome_plugin_host.h" |
33 #include "chrome/renderer/debug_message_handler.h" | 33 #include "chrome/renderer/debug_message_handler.h" |
| 34 #include "chrome/renderer/greasemonkey_slave.h" |
34 #include "chrome/renderer/localized_error.h" | 35 #include "chrome/renderer/localized_error.h" |
35 #include "chrome/renderer/renderer_resources.h" | 36 #include "chrome/renderer/renderer_resources.h" |
36 #include "chrome/renderer/visitedlink_slave.h" | 37 #include "chrome/renderer/visitedlink_slave.h" |
37 #include "chrome/renderer/webplugin_delegate_proxy.h" | 38 #include "chrome/renderer/webplugin_delegate_proxy.h" |
38 #include "chrome/views/message_box_view.h" | 39 #include "chrome/views/message_box_view.h" |
39 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
40 #include "net/base/net_errors.h" | 41 #include "net/base/net_errors.h" |
41 #include "webkit/default_plugin/default_plugin_shared.h" | 42 #include "webkit/default_plugin/default_plugin_shared.h" |
42 #include "webkit/glue/dom_operations.h" | 43 #include "webkit/glue/dom_operations.h" |
43 #include "webkit/glue/dom_serializer.h" | 44 #include "webkit/glue/dom_serializer.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 opened_by_user_gesture_(true), | 144 opened_by_user_gesture_(true), |
144 enable_dom_automation_(false), | 145 enable_dom_automation_(false), |
145 enable_dom_ui_bindings_(false), | 146 enable_dom_ui_bindings_(false), |
146 target_url_status_(TARGET_NONE), | 147 target_url_status_(TARGET_NONE), |
147 printed_document_width_(0), | 148 printed_document_width_(0), |
148 first_default_plugin_(NULL), | 149 first_default_plugin_(NULL), |
149 navigation_gesture_(NavigationGestureUnknown), | 150 navigation_gesture_(NavigationGestureUnknown), |
150 history_back_list_count_(0), | 151 history_back_list_count_(0), |
151 history_forward_list_count_(0), | 152 history_forward_list_count_(0), |
152 disable_popup_blocking_(false), | 153 disable_popup_blocking_(false), |
153 has_unload_listener_(false) { | 154 has_unload_listener_(false), |
| 155 greasemonkey_enabled_(false) { |
154 resource_dispatcher_ = new ResourceDispatcher(this); | 156 resource_dispatcher_ = new ResourceDispatcher(this); |
155 #ifdef CHROME_PERSONALIZATION | 157 #ifdef CHROME_PERSONALIZATION |
156 personalization_ = Personalization::CreateRendererPersonalization(); | 158 personalization_ = Personalization::CreateRendererPersonalization(); |
157 #endif | 159 #endif |
158 } | 160 } |
159 | 161 |
160 RenderView::~RenderView() { | 162 RenderView::~RenderView() { |
161 resource_dispatcher_->ClearMessageSender(); | 163 resource_dispatcher_->ClearMessageSender(); |
162 // Clear any back-pointers that might still be held by plugins. | 164 // Clear any back-pointers that might still be held by plugins. |
163 PluginDelegateList::iterator it = plugin_delegates_.begin(); | 165 PluginDelegateList::iterator it = plugin_delegates_.begin(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 256 } |
255 | 257 |
256 host_window_ = parent_hwnd; | 258 host_window_ = parent_hwnd; |
257 modal_dialog_event_.Set(modal_dialog_event); | 259 modal_dialog_event_.Set(modal_dialog_event); |
258 | 260 |
259 CommandLine command_line; | 261 CommandLine command_line; |
260 enable_dom_automation_ = | 262 enable_dom_automation_ = |
261 command_line.HasSwitch(switches::kDomAutomationController); | 263 command_line.HasSwitch(switches::kDomAutomationController); |
262 disable_popup_blocking_ = | 264 disable_popup_blocking_ = |
263 command_line.HasSwitch(switches::kDisablePopupBlocking); | 265 command_line.HasSwitch(switches::kDisablePopupBlocking); |
| 266 greasemonkey_enabled_ = |
| 267 command_line.HasSwitch(switches::kEnableGreasemonkey); |
264 | 268 |
265 debug_message_handler_ = new DebugMessageHandler(this); | 269 debug_message_handler_ = new DebugMessageHandler(this); |
266 RenderThread::current()->AddFilter(debug_message_handler_); | 270 RenderThread::current()->AddFilter(debug_message_handler_); |
267 } | 271 } |
268 | 272 |
269 void RenderView::OnMessageReceived(const IPC::Message& message) { | 273 void RenderView::OnMessageReceived(const IPC::Message& message) { |
270 // Let the resource dispatcher intercept resource messages first. | 274 // Let the resource dispatcher intercept resource messages first. |
271 if (resource_dispatcher_->OnMessageReceived(message)) | 275 if (resource_dispatcher_->OnMessageReceived(message)) |
272 return; | 276 return; |
273 IPC_BEGIN_MESSAGE_MAP(RenderView, message) | 277 IPC_BEGIN_MESSAGE_MAP(RenderView, message) |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 | 1366 |
1363 void RenderView::DidFailLoadWithError(WebView* webview, | 1367 void RenderView::DidFailLoadWithError(WebView* webview, |
1364 const WebError& error, | 1368 const WebError& error, |
1365 WebFrame* frame) { | 1369 WebFrame* frame) { |
1366 } | 1370 } |
1367 | 1371 |
1368 void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, | 1372 void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, |
1369 WebFrame* frame) { | 1373 WebFrame* frame) { |
1370 // Check whether we have new encoding name. | 1374 // Check whether we have new encoding name. |
1371 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); | 1375 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); |
| 1376 |
| 1377 // Inject any Greasemonkey scripts. Do not inject into chrome UI pages, but |
| 1378 // do inject into any other document. |
| 1379 if (greasemonkey_enabled_) { |
| 1380 const GURL &gurl = frame->GetURL(); |
| 1381 if (gurl.SchemeIs("file") || |
| 1382 gurl.SchemeIs("http") || |
| 1383 gurl.SchemeIs("https")) { |
| 1384 RenderThread::current()->greasemonkey_slave()->InjectScripts(frame); |
| 1385 } |
| 1386 } |
1372 } | 1387 } |
1373 | 1388 |
1374 void RenderView::DidHandleOnloadEventsForFrame(WebView* webview, | 1389 void RenderView::DidHandleOnloadEventsForFrame(WebView* webview, |
1375 WebFrame* frame) { | 1390 WebFrame* frame) { |
1376 } | 1391 } |
1377 | 1392 |
1378 void RenderView::DidChangeLocationWithinPageForFrame(WebView* webview, | 1393 void RenderView::DidChangeLocationWithinPageForFrame(WebView* webview, |
1379 WebFrame* frame, | 1394 WebFrame* frame, |
1380 bool is_new_navigation) { | 1395 bool is_new_navigation) { |
1381 DidCommitLoadForFrame(webview, frame, is_new_navigation); | 1396 DidCommitLoadForFrame(webview, frame, is_new_navigation); |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2588 | 2603 |
2589 if (template_html.empty()) { | 2604 if (template_html.empty()) { |
2590 NOTREACHED() << "unable to load template. ID: " << template_resource_id; | 2605 NOTREACHED() << "unable to load template. ID: " << template_resource_id; |
2591 return ""; | 2606 return ""; |
2592 } | 2607 } |
2593 // "t" is the id of the templates root node. | 2608 // "t" is the id of the templates root node. |
2594 return jstemplate_builder::GetTemplateHtml( | 2609 return jstemplate_builder::GetTemplateHtml( |
2595 template_html, &error_strings, "t"); | 2610 template_html, &error_strings, "t"); |
2596 } | 2611 } |
2597 | 2612 |
OLD | NEW |