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

Side by Side Diff: chrome/browser/printing/printer_query.cc

Issue 504763002: Revert of Added PrintingContext::Delegate to get parent view handle and application locale. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/printing/printer_query.h" 5 #include "chrome/browser/printing/printer_query.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/printing/print_job_worker.h" 12 #include "chrome/browser/printing/print_job_worker.h"
13 #include "chrome/browser/printing/printing_ui_web_contents_observer.h" 13 #include "chrome/browser/printing/printing_ui_web_contents_observer.h"
14 14
15 namespace printing { 15 namespace printing {
16 16
17 PrinterQuery::PrinterQuery(int render_process_id, int render_view_id) 17 PrinterQuery::PrinterQuery()
18 : worker_(new PrintJobWorker(render_process_id, render_view_id, this)), 18 : worker_(new PrintJobWorker(this)),
19 is_print_dialog_box_shown_(false), 19 is_print_dialog_box_shown_(false),
20 cookie_(PrintSettings::NewCookie()), 20 cookie_(PrintSettings::NewCookie()),
21 last_status_(PrintingContext::FAILED) { 21 last_status_(PrintingContext::FAILED) {
22 DCHECK(base::MessageLoopForIO::IsCurrent()); 22 DCHECK(base::MessageLoopForIO::IsCurrent());
23 } 23 }
24 24
25 PrinterQuery::~PrinterQuery() { 25 PrinterQuery::~PrinterQuery() {
26 // The job should be finished (or at least canceled) when it is destroyed. 26 // The job should be finished (or at least canceled) when it is destroyed.
27 DCHECK(!is_print_dialog_box_shown_); 27 DCHECK(!is_print_dialog_box_shown_);
28 // If this fires, it is that this pending printer context has leaked. 28 // If this fires, it is that this pending printer context has leaked.
(...skipping 30 matching lines...) Expand all
59 const PrintSettings& PrinterQuery::settings() const { 59 const PrintSettings& PrinterQuery::settings() const {
60 return settings_; 60 return settings_;
61 } 61 }
62 62
63 int PrinterQuery::cookie() const { 63 int PrinterQuery::cookie() const {
64 return cookie_; 64 return cookie_;
65 } 65 }
66 66
67 void PrinterQuery::GetSettings( 67 void PrinterQuery::GetSettings(
68 GetSettingsAskParam ask_user_for_settings, 68 GetSettingsAskParam ask_user_for_settings,
69 scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer,
69 int expected_page_count, 70 int expected_page_count,
70 bool has_selection, 71 bool has_selection,
71 MarginType margin_type, 72 MarginType margin_type,
72 const base::Closure& callback) { 73 const base::Closure& callback) {
73 DCHECK(RunsTasksOnCurrentThread()); 74 DCHECK(RunsTasksOnCurrentThread());
74 DCHECK(!is_print_dialog_box_shown_); 75 DCHECK(!is_print_dialog_box_shown_);
75 76
76 StartWorker(callback); 77 StartWorker(callback);
77 78
78 // Real work is done in PrintJobWorker::GetSettings(). 79 // Real work is done in PrintJobWorker::GetSettings().
79 is_print_dialog_box_shown_ = ask_user_for_settings == ASK_USER; 80 is_print_dialog_box_shown_ = ask_user_for_settings == ASK_USER;
80 worker_->PostTask(FROM_HERE, 81 worker_->PostTask(FROM_HERE,
81 base::Bind(&PrintJobWorker::GetSettings, 82 base::Bind(&PrintJobWorker::GetSettings,
82 base::Unretained(worker_.get()), 83 base::Unretained(worker_.get()),
83 is_print_dialog_box_shown_, 84 is_print_dialog_box_shown_,
85 base::Passed(&web_contents_observer),
84 expected_page_count, 86 expected_page_count,
85 has_selection, 87 has_selection,
86 margin_type)); 88 margin_type));
87 } 89 }
88 90
89 void PrinterQuery::SetSettings(scoped_ptr<base::DictionaryValue> new_settings, 91 void PrinterQuery::SetSettings(scoped_ptr<base::DictionaryValue> new_settings,
90 const base::Closure& callback) { 92 const base::Closure& callback) {
91 StartWorker(callback); 93 StartWorker(callback);
92 94
93 worker_->PostTask(FROM_HERE, 95 worker_->PostTask(FROM_HERE,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 127
126 bool PrinterQuery::is_callback_pending() const { 128 bool PrinterQuery::is_callback_pending() const {
127 return !callback_.is_null(); 129 return !callback_.is_null();
128 } 130 }
129 131
130 bool PrinterQuery::is_valid() const { 132 bool PrinterQuery::is_valid() const {
131 return worker_.get() != NULL; 133 return worker_.get() != NULL;
132 } 134 }
133 135
134 } // namespace printing 136 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/printer_query.h ('k') | chrome/browser/printing/printing_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698