Chromium Code Reviews| 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/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 error = true; | 1137 error = true; |
| 1138 | 1138 |
| 1139 DCHECK(error == snapshot.empty()) << | 1139 DCHECK(error == snapshot.empty()) << |
| 1140 "Snapshot should be empty on error, non-empty otherwise."; | 1140 "Snapshot should be empty on error, non-empty otherwise."; |
| 1141 | 1141 |
| 1142 // Send the snapshot to the browser process. | 1142 // Send the snapshot to the browser process. |
| 1143 Send(new ViewHostMsg_Snapshot(routing_id_, snapshot)); | 1143 Send(new ViewHostMsg_Snapshot(routing_id_, snapshot)); |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 void RenderView::OnPrintPages() { | 1146 void RenderView::OnPrintPages() { |
| 1147 DCHECK(webview()); | 1147 OnPrint(false); |
| 1148 if (webview()) { | |
| 1149 // If the user has selected text in the currently focused frame we print | |
| 1150 // only that frame (this makes print selection work for multiple frames). | |
| 1151 if (webview()->focusedFrame()->hasSelection()) | |
| 1152 Print(webview()->focusedFrame(), false, false); | |
| 1153 else | |
| 1154 Print(webview()->mainFrame(), false, false); | |
| 1155 } | |
| 1156 } | 1148 } |
| 1157 | 1149 |
| 1158 void RenderView::OnPrintingDone(int document_cookie, bool success) { | 1150 void RenderView::OnPrintingDone(int document_cookie, bool success) { |
| 1159 // Ignoring document cookie here since only one print job can be outstanding | 1151 // Ignoring document cookie here since only one print job can be outstanding |
| 1160 // per renderer and document_cookie is 0 when printing is successful. | 1152 // per renderer and document_cookie is 0 when printing is successful. |
| 1161 DCHECK(print_helper_.get()); | 1153 DCHECK(print_helper_.get()); |
| 1162 if (print_helper_.get() != NULL) { | 1154 if (print_helper_.get() != NULL) { |
| 1163 print_helper_->DidFinishPrinting(success); | 1155 print_helper_->DidFinishPrinting(success); |
| 1164 } | 1156 } |
| 1165 } | 1157 } |
| 1166 | 1158 |
| 1167 void RenderView::OnPrintPreview() { | 1159 void RenderView::OnPrintPreview() { |
| 1168 DCHECK(webview()); | 1160 OnPrint(true); |
| 1169 if (webview()) { | |
| 1170 // If the user has selected text in the currently focused frame we print | |
| 1171 // only that frame (this makes print selection work for multiple frames). | |
| 1172 if (webview()->focusedFrame()->hasSelection()) | |
| 1173 Print(webview()->focusedFrame(), false, true); | |
| 1174 else | |
| 1175 Print(webview()->focusedFrame(), false, true); | |
|
Lei Zhang
2011/01/20 05:47:03
Was this a copy+paste mistake or was this intentio
kmadhusu
2011/01/20 17:17:23
It is a mistake. Thanks for fixing it.
| |
| 1176 } | |
| 1177 } | 1161 } |
| 1178 | 1162 |
| 1179 void RenderView::OnPrintNodeUnderContextMenu() { | 1163 void RenderView::OnPrintNodeUnderContextMenu() { |
| 1180 if (context_menu_node_.isNull()) { | 1164 if (context_menu_node_.isNull()) { |
| 1181 NOTREACHED(); | 1165 NOTREACHED(); |
| 1182 return; | 1166 return; |
| 1183 } | 1167 } |
| 1184 | 1168 |
| 1185 // Make a copy of the node, since we will do a sync call to the browser and | 1169 // Make a copy of the node, since we will do a sync call to the browser and |
| 1186 // during that time OnContextMenuClosed might reset context_menu_node_. | 1170 // during that time OnContextMenuClosed might reset context_menu_node_. |
| (...skipping 4094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5281 // When no accessibility notifications are in-flight post a task to send | 5265 // When no accessibility notifications are in-flight post a task to send |
| 5282 // the notifications to the browser. We use PostTask so that we can queue | 5266 // the notifications to the browser. We use PostTask so that we can queue |
| 5283 // up additional notifications. | 5267 // up additional notifications. |
| 5284 MessageLoop::current()->PostTask( | 5268 MessageLoop::current()->PostTask( |
| 5285 FROM_HERE, | 5269 FROM_HERE, |
| 5286 accessibility_method_factory_.NewRunnableMethod( | 5270 accessibility_method_factory_.NewRunnableMethod( |
| 5287 &RenderView::SendPendingAccessibilityNotifications)); | 5271 &RenderView::SendPendingAccessibilityNotifications)); |
| 5288 } | 5272 } |
| 5289 } | 5273 } |
| 5290 | 5274 |
| 5275 void RenderView::OnPrint(bool is_preview) { | |
| 5276 DCHECK(webview()); | |
| 5277 if (webview()) { | |
| 5278 // If the user has selected text in the currently focused frame we print | |
| 5279 // only that frame (this makes print selection work for multiple frames). | |
| 5280 if (webview()->focusedFrame()->hasSelection()) | |
| 5281 Print(webview()->focusedFrame(), false, is_preview); | |
| 5282 else | |
| 5283 Print(webview()->mainFrame(), false, is_preview); | |
| 5284 } | |
| 5285 } | |
| 5286 | |
| 5291 void RenderView::Print(WebFrame* frame, | 5287 void RenderView::Print(WebFrame* frame, |
| 5292 bool script_initiated, | 5288 bool script_initiated, |
| 5293 bool is_preview) { | 5289 bool is_preview) { |
| 5294 DCHECK(frame); | 5290 DCHECK(frame); |
| 5295 GetPrintWebViewHelper()->PrintFrame(frame, script_initiated, is_preview); | 5291 GetPrintWebViewHelper()->PrintFrame(frame, script_initiated, is_preview); |
| 5296 } | 5292 } |
| 5297 | 5293 |
| 5298 PrintWebViewHelper* RenderView::GetPrintWebViewHelper() { | 5294 PrintWebViewHelper* RenderView::GetPrintWebViewHelper() { |
| 5299 if (print_helper_.get() == NULL) | 5295 if (print_helper_.get() == NULL) |
| 5300 print_helper_.reset(new PrintWebViewHelper(this)); | 5296 print_helper_.reset(new PrintWebViewHelper(this)); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5684 if (cmd == kJavaScriptStressTestSetStressRunType) { | 5680 if (cmd == kJavaScriptStressTestSetStressRunType) { |
| 5685 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); | 5681 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); |
| 5686 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { | 5682 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { |
| 5687 v8::Testing::PrepareStressRun(param); | 5683 v8::Testing::PrepareStressRun(param); |
| 5688 } | 5684 } |
| 5689 } | 5685 } |
| 5690 | 5686 |
| 5691 void RenderView::OnContextMenuClosed() { | 5687 void RenderView::OnContextMenuClosed() { |
| 5692 context_menu_node_.reset(); | 5688 context_menu_node_.reset(); |
| 5693 } | 5689 } |
| OLD | NEW |