Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/ui/webui/print_preview_ui.cc

Issue 7550063: Print Preview: Handle a crashed initiator tab by showing a message in PP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/ui/webui/print_preview_ui.h" 5 #include "chrome/browser/ui/webui/print_preview_ui.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/printing/print_preview_data_service.h" 10 #include "chrome/browser/printing/print_preview_data_service.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 void PrintPreviewUI::SetPrintPreviewDataForIndex(int index, 48 void PrintPreviewUI::SetPrintPreviewDataForIndex(int index,
49 const RefCountedBytes* data) { 49 const RefCountedBytes* data) {
50 print_preview_data_service()->SetDataEntry(preview_ui_addr_str_, index, data); 50 print_preview_data_service()->SetDataEntry(preview_ui_addr_str_, index, data);
51 } 51 }
52 52
53 void PrintPreviewUI::ClearAllPreviewData() { 53 void PrintPreviewUI::ClearAllPreviewData() {
54 print_preview_data_service()->RemoveEntry(preview_ui_addr_str_); 54 print_preview_data_service()->RemoveEntry(preview_ui_addr_str_);
55 } 55 }
56 56
57 void PrintPreviewUI::OnInitiatorTabClosed( 57 void PrintPreviewUI::SetInitiatorTabURL(const std::string& initiator_url) {
58 const std::string& initiator_url) { 58 initiator_url_ = initiator_url;
59 StringValue initiator_tab_url(initiator_url); 59 }
60
61 void PrintPreviewUI::OnInitiatorTabCrashed() {
62 StringValue initiator_tab_url(initiator_url_);
63 CallJavascriptFunction("onInitiatorTabCrashed", initiator_tab_url);
64 }
65
66 void PrintPreviewUI::OnInitiatorTabClosed() {
67 StringValue initiator_tab_url(initiator_url_);
60 CallJavascriptFunction("onInitiatorTabClosed", initiator_tab_url); 68 CallJavascriptFunction("onInitiatorTabClosed", initiator_tab_url);
61 } 69 }
62 70
63 void PrintPreviewUI::OnPrintPreviewRequest() { 71 void PrintPreviewUI::OnPrintPreviewRequest() {
64 request_count_++; 72 request_count_++;
65 } 73 }
66 74
67 void PrintPreviewUI::OnDidGetPreviewPageCount( 75 void PrintPreviewUI::OnDidGetPreviewPageCount(
68 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { 76 const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
69 DCHECK_GT(params.page_count, 0); 77 DCHECK_GT(params.page_count, 0);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 expected_pages_count); 115 expected_pages_count);
108 initial_preview_start_time_ = base::TimeTicks(); 116 initial_preview_start_time_ = base::TimeTicks();
109 } 117 }
110 base::StringValue title(job_title); 118 base::StringValue title(job_title);
111 base::StringValue ui_identifier(preview_ui_addr_str_); 119 base::StringValue ui_identifier(preview_ui_addr_str_);
112 base::FundamentalValue ui_preview_request_id(preview_request_id); 120 base::FundamentalValue ui_preview_request_id(preview_request_id);
113 CallJavascriptFunction("updatePrintPreview", title, ui_identifier, 121 CallJavascriptFunction("updatePrintPreview", title, ui_identifier,
114 ui_preview_request_id); 122 ui_preview_request_id);
115 } 123 }
116 124
117 void PrintPreviewUI::OnNavigation() { 125 void PrintPreviewUI::OnTabDestroyed() {
118 handler_->OnNavigation(); 126 handler_->OnTabDestroyed();
119 } 127 }
120 128
121 void PrintPreviewUI::OnFileSelectionCancelled() { 129 void PrintPreviewUI::OnFileSelectionCancelled() {
122 CallJavascriptFunction("fileSelectionCancelled"); 130 CallJavascriptFunction("fileSelectionCancelled");
123 } 131 }
124 132
125 void PrintPreviewUI::OnPrintPreviewFailed() { 133 void PrintPreviewUI::OnPrintPreviewFailed() {
126 DecrementRequestCount(); 134 DecrementRequestCount();
127 CallJavascriptFunction("printPreviewFailed"); 135 CallJavascriptFunction("printPreviewFailed");
128 } 136 }
(...skipping 11 matching lines...) Expand all
140 } 148 }
141 149
142 void PrintPreviewUI::DecrementRequestCount() { 150 void PrintPreviewUI::DecrementRequestCount() {
143 if (request_count_ > 0) 151 if (request_count_ > 0)
144 request_count_--; 152 request_count_--;
145 } 153 }
146 154
147 int PrintPreviewUI::document_cookie() { 155 int PrintPreviewUI::document_cookie() {
148 return document_cookie_; 156 return document_cookie_;
149 } 157 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698