| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/gfx/jpeg_codec.h" | 8 #include "base/gfx/jpeg_codec.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 PrintWebViewHelper::~PrintWebViewHelper() {} | 68 PrintWebViewHelper::~PrintWebViewHelper() {} |
| 69 | 69 |
| 70 void PrintWebViewHelper::DidFinishPrinting(bool success) { | 70 void PrintWebViewHelper::DidFinishPrinting(bool success) { |
| 71 if (!success) { | 71 if (!success) { |
| 72 WebView* web_view = print_web_view_.get(); | 72 WebView* web_view = print_web_view_.get(); |
| 73 if (!web_view) | 73 if (!web_view) |
| 74 web_view = render_view_->webview(); | 74 web_view = render_view_->webview(); |
| 75 | 75 |
| 76 // TODO: Create an async alert (http://crbug.com/14918). | 76 // TODO: Create an async alert (http://crbug.com/14918). |
| 77 render_view_->RunJavaScriptAlert(web_view->GetMainFrame(), | 77 render_view_->runModalAlertDialog( |
| 78 l10n_util::GetString(IDS_PRINT_SPOOL_FAILED_ERROR_TEXT)); | 78 web_view->GetMainFrame(), |
| 79 WideToUTF16Hack( |
| 80 l10n_util::GetString(IDS_PRINT_SPOOL_FAILED_ERROR_TEXT))); |
| 79 } | 81 } |
| 80 | 82 |
| 81 if (print_web_view_.get()) { | 83 if (print_web_view_.get()) { |
| 82 print_web_view_->close(); | 84 print_web_view_->close(); |
| 83 print_web_view_.release(); // Close deletes object. | 85 print_web_view_.release(); // Close deletes object. |
| 84 print_pages_params_.reset(); | 86 print_pages_params_.reset(); |
| 85 } | 87 } |
| 86 } | 88 } |
| 87 | 89 |
| 88 bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, | 90 bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 151 } |
| 150 | 152 |
| 151 bool PrintWebViewHelper::Send(IPC::Message* msg) { | 153 bool PrintWebViewHelper::Send(IPC::Message* msg) { |
| 152 return render_view_->Send(msg); | 154 return render_view_->Send(msg); |
| 153 } | 155 } |
| 154 | 156 |
| 155 int32 PrintWebViewHelper::routing_id() { | 157 int32 PrintWebViewHelper::routing_id() { |
| 156 return render_view_->routing_id(); | 158 return render_view_->routing_id(); |
| 157 } | 159 } |
| 158 | 160 |
| 161 void PrintWebViewHelper::didStopLoading() { |
| 162 DCHECK(print_pages_params_.get() != NULL); |
| 163 PrintPages(*print_pages_params_.get(), print_web_view_->GetMainFrame()); |
| 164 } |
| 165 |
| 159 WebRect PrintWebViewHelper::windowRect() { | 166 WebRect PrintWebViewHelper::windowRect() { |
| 160 NOTREACHED(); | 167 NOTREACHED(); |
| 161 return WebRect(); | 168 return WebRect(); |
| 162 } | 169 } |
| 163 | 170 |
| 164 WebRect PrintWebViewHelper::windowResizerRect() { | 171 WebRect PrintWebViewHelper::windowResizerRect() { |
| 165 NOTREACHED(); | 172 NOTREACHED(); |
| 166 return WebRect(); | 173 return WebRect(); |
| 167 } | 174 } |
| 168 | 175 |
| 169 WebRect PrintWebViewHelper::rootWindowRect() { | 176 WebRect PrintWebViewHelper::rootWindowRect() { |
| 170 NOTREACHED(); | 177 NOTREACHED(); |
| 171 return WebRect(); | 178 return WebRect(); |
| 172 } | 179 } |
| 173 | 180 |
| 174 WebScreenInfo PrintWebViewHelper::screenInfo() { | 181 WebScreenInfo PrintWebViewHelper::screenInfo() { |
| 175 NOTREACHED(); | 182 NOTREACHED(); |
| 176 return WebScreenInfo(); | 183 return WebScreenInfo(); |
| 177 } | 184 } |
| 178 | |
| 179 void PrintWebViewHelper::DidStopLoading(WebView* webview) { | |
| 180 DCHECK(print_pages_params_.get() != NULL); | |
| 181 DCHECK_EQ(webview, print_web_view_.get()); | |
| 182 PrintPages(*print_pages_params_.get(), print_web_view_->GetMainFrame()); | |
| 183 } | |
| OLD | NEW |