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

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

Issue 7202012: Print Preview: Display a throbber when the user requests the system print (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 years, 5 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
« no previous file with comments | « chrome/browser/ui/webui/print_preview_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/webui/print_preview_data_source.h" 12 #include "chrome/browser/ui/webui/print_preview_data_source.h"
13 #include "chrome/browser/ui/webui/print_preview_handler.h" 13 #include "chrome/browser/ui/webui/print_preview_handler.h"
14 #include "content/browser/tab_contents/tab_contents.h" 14 #include "content/browser/tab_contents/tab_contents.h"
15 15
16 PrintPreviewUI::PrintPreviewUI(TabContents* contents) 16 PrintPreviewUI::PrintPreviewUI(TabContents* contents)
17 : ChromeWebUI(contents), 17 : ChromeWebUI(contents),
18 initial_preview_start_time_(base::TimeTicks::Now()) { 18 initial_preview_start_time_(base::TimeTicks::Now()) {
19 // PrintPreviewUI owns |handler|. 19 // WebUI owns |handler_|.
20 PrintPreviewHandler* handler = new PrintPreviewHandler(); 20 handler_ = new PrintPreviewHandler();
21 AddMessageHandler(handler->Attach(this)); 21 AddMessageHandler(handler_->Attach(this));
22 22
23 // Set up the chrome://print/ data source. 23 // Set up the chrome://print/ data source.
24 contents->profile()->GetChromeURLDataManager()->AddDataSource( 24 contents->profile()->GetChromeURLDataManager()->AddDataSource(
25 new PrintPreviewDataSource()); 25 new PrintPreviewDataSource());
26 26
27 // Store the PrintPreviewUIAddress as a string. 27 // Store the PrintPreviewUIAddress as a string.
28 // "0x" + deadc0de + '\0' = 2 + 2 * sizeof(this) + 1; 28 // "0x" + deadc0de + '\0' = 2 + 2 * sizeof(this) + 1;
29 char preview_ui_addr[2 + (2 * sizeof(this)) + 1]; 29 char preview_ui_addr[2 + (2 * sizeof(this)) + 1];
30 base::snprintf(preview_ui_addr, sizeof(preview_ui_addr), "%p", this); 30 base::snprintf(preview_ui_addr, sizeof(preview_ui_addr), "%p", this);
31 preview_ui_addr_str_ = preview_ui_addr; 31 preview_ui_addr_str_ = preview_ui_addr;
(...skipping 30 matching lines...) Expand all
62 initial_preview_start_time_ = base::TimeTicks(); 62 initial_preview_start_time_ = base::TimeTicks();
63 } 63 }
64 FundamentalValue pages_count(expected_pages_count); 64 FundamentalValue pages_count(expected_pages_count);
65 StringValue title(job_title); 65 StringValue title(job_title);
66 FundamentalValue is_preview_modifiable(modifiable); 66 FundamentalValue is_preview_modifiable(modifiable);
67 StringValue ui_identifier(preview_ui_addr_str_); 67 StringValue ui_identifier(preview_ui_addr_str_);
68 CallJavascriptFunction("updatePrintPreview", pages_count, title, 68 CallJavascriptFunction("updatePrintPreview", pages_count, title,
69 is_preview_modifiable, ui_identifier); 69 is_preview_modifiable, ui_identifier);
70 } 70 }
71 71
72 void PrintPreviewUI::OnNavigation() {
73 handler_->OnNavigation();
74 }
75
72 void PrintPreviewUI::OnFileSelectionCancelled() { 76 void PrintPreviewUI::OnFileSelectionCancelled() {
73 CallJavascriptFunction("fileSelectionCancelled"); 77 CallJavascriptFunction("fileSelectionCancelled");
74 } 78 }
75 79
76 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { 80 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() {
77 return PrintPreviewDataService::GetInstance(); 81 return PrintPreviewDataService::GetInstance();
78 } 82 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698