summaryrefslogtreecommitdiffstats
path: root/chrome/browser/printing
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/printing')
-rw-r--r--chrome/browser/printing/print_job.cc41
-rw-r--r--chrome/browser/printing/print_job.h2
-rw-r--r--chrome/browser/printing/print_job_manager.cc19
-rw-r--r--chrome/browser/printing/print_job_manager.h12
-rw-r--r--chrome/browser/printing/print_job_unittest.cc7
-rw-r--r--chrome/browser/printing/print_job_worker.cc4
-rw-r--r--chrome/browser/printing/print_view_manager.cc15
-rw-r--r--chrome/browser/printing/print_view_manager.h11
-rw-r--r--chrome/browser/printing/printed_document.cc4
9 files changed, 60 insertions, 55 deletions
diff --git a/chrome/browser/printing/print_job.cc b/chrome/browser/printing/print_job.cc
index 14a487cd..193a3c1 100644
--- a/chrome/browser/printing/print_job.cc
+++ b/chrome/browser/printing/print_job.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/printing/print_job_worker.h"
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/printing/printed_page.h"
+#include "chrome/common/notification_service.h"
#ifdef _MSC_VER
#pragma warning(disable:4355) // 'this' : used in base member initializer list
@@ -67,15 +68,15 @@ void PrintJob::Initialize(PrintJobWorkerOwner* job,
// Don't forget to register to our own messages.
NotificationService::current()->AddObserver(
- this, NOTIFY_PRINT_JOB_EVENT, Source<PrintJob>(this));
+ this, NotificationType::PRINT_JOB_EVENT, Source<PrintJob>(this));
}
void PrintJob::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK_EQ(ui_message_loop_, MessageLoop::current());
- switch (type) {
- case NOTIFY_PRINTED_DOCUMENT_UPDATED: {
+ switch (type.value) {
+ case NotificationType::PRINTED_DOCUMENT_UPDATED: {
DCHECK(Source<PrintedDocument>(source).ptr() ==
document_.get());
@@ -90,7 +91,7 @@ void PrintJob::Observe(NotificationType type,
}
break;
}
- case NOTIFY_PRINT_JOB_EVENT: {
+ case NotificationType::PRINT_JOB_EVENT: {
OnNotifyPrintJobEvent(*Details<JobEventDetails>(details).ptr());
break;
}
@@ -120,8 +121,8 @@ void PrintJob::GetSettingsDone(const PrintSettings& new_settings,
JobEventDetails::Type type;
if (is_print_dialog_box_shown_) {
type = (result == PrintingContext::OK) ?
- JobEventDetails::USER_INIT_DONE :
- JobEventDetails::USER_INIT_CANCELED;
+ JobEventDetails::USER_INIT_DONE :
+ JobEventDetails::USER_INIT_CANCELED;
// Dialog box is not shown anymore.
is_print_dialog_box_shown_ = false;
} else {
@@ -131,7 +132,7 @@ void PrintJob::GetSettingsDone(const PrintSettings& new_settings,
scoped_refptr<JobEventDetails> details(
new JobEventDetails(type, document_.get(), NULL));
NotificationService::current()->Notify(
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
Source<PrintJob>(this),
Details<JobEventDetails>(details.get()));
}
@@ -168,7 +169,7 @@ void PrintJob::GetSettings(GetSettingsAskParam ask_user_for_settings,
// Don't re-register if we were already registered.
NotificationService::current()->AddObserver(
- this, NOTIFY_PRINT_JOB_EVENT, Source<PrintJob>(this));
+ this, NotificationType::PRINT_JOB_EVENT, Source<PrintJob>(this));
}
int page_count = 0;
@@ -201,7 +202,7 @@ void PrintJob::StartPrinting() {
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), NULL));
NotificationService::current()->Notify(
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
Source<PrintJob>(this),
Details<JobEventDetails>(details.get()));
}
@@ -225,7 +226,7 @@ void PrintJob::Stop() {
is_job_pending_ = false;
NotificationService::current()->RemoveObserver(
- this, NOTIFY_PRINT_JOB_EVENT, Source<PrintJob>(this));
+ this, NotificationType::PRINT_JOB_EVENT, Source<PrintJob>(this));
}
// Flush the cached document.
UpdatePrintedDocument(NULL);
@@ -250,7 +251,7 @@ void PrintJob::Cancel() {
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::FAILED, NULL, NULL));
NotificationService::current()->Notify(
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
Source<PrintJob>(this),
Details<JobEventDetails>(details.get()));
Stop();
@@ -320,19 +321,19 @@ void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
return;
// Unregisters.
if (document_.get()) {
- NotificationService::current()->
- RemoveObserver(this,
- NOTIFY_PRINTED_DOCUMENT_UPDATED,
- Source<PrintedDocument>(document_.get()));
+ NotificationService::current()->RemoveObserver(
+ this,
+ NotificationType::PRINTED_DOCUMENT_UPDATED,
+ Source<PrintedDocument>(document_.get()));
}
document_ = new_document;
// Registers.
if (document_.get()) {
- NotificationService::current()->
- AddObserver(this,
- NOTIFY_PRINTED_DOCUMENT_UPDATED,
- Source<PrintedDocument>(document_.get()));
+ NotificationService::current()->AddObserver(
+ this,
+ NotificationType::PRINTED_DOCUMENT_UPDATED,
+ Source<PrintedDocument>(document_.get()));
settings_ = document_->settings();
}
@@ -392,7 +393,7 @@ void PrintJob::OnDocumentDone() {
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), NULL));
NotificationService::current()->Notify(
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
Source<PrintJob>(this),
Details<JobEventDetails>(details.get()));
}
diff --git a/chrome/browser/printing/print_job.h b/chrome/browser/printing/print_job.h
index f67cc7b..dcbe43e 100644
--- a/chrome/browser/printing/print_job.h
+++ b/chrome/browser/printing/print_job.h
@@ -10,7 +10,7 @@
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "chrome/browser/printing/print_job_worker_owner.h"
-#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_observer.h"
class ChromeFont;
class GURL;
diff --git a/chrome/browser/printing/print_job_manager.cc b/chrome/browser/printing/print_job_manager.cc
index 978f889..c2ff3a8 100644
--- a/chrome/browser/printing/print_job_manager.cc
+++ b/chrome/browser/printing/print_job_manager.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/printing/printed_page.h"
#include "chrome/common/gfx/emf.h"
+#include "chrome/common/notification_service.h"
namespace printing {
@@ -18,11 +19,11 @@ PrintJobManager::PrintJobManager()
: debug_dump_path_() {
NotificationService::current()->AddObserver(
this,
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
NotificationService::AllSources());
NotificationService::current()->AddObserver(
this,
- NOTIFY_PRINTED_DOCUMENT_UPDATED,
+ NotificationType::PRINTED_DOCUMENT_UPDATED,
NotificationService::AllSources());
}
@@ -33,11 +34,11 @@ PrintJobManager::~PrintJobManager() {
queued_queries_.clear();
NotificationService::current()->RemoveObserver(
this,
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
NotificationService::AllSources());
NotificationService::current()->RemoveObserver(
this,
- NOTIFY_PRINTED_DOCUMENT_UPDATED,
+ NotificationType::PRINTED_DOCUMENT_UPDATED,
NotificationService::AllSources());
}
@@ -61,11 +62,11 @@ void PrintJobManager::OnQuit() {
current_jobs_.clear();
NotificationService::current()->RemoveObserver(
this,
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
NotificationService::AllSources());
NotificationService::current()->RemoveObserver(
this,
- NOTIFY_PRINTED_DOCUMENT_UPDATED,
+ NotificationType::PRINTED_DOCUMENT_UPDATED,
NotificationService::AllSources());
DCHECK_EQ(current_jobs_.size(), 0);
}
@@ -98,13 +99,13 @@ void PrintJobManager::PopPrinterQuery(int document_cookie,
void PrintJobManager::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- switch (type) {
- case NOTIFY_PRINT_JOB_EVENT: {
+ switch (type.value) {
+ case NotificationType::PRINT_JOB_EVENT: {
OnPrintJobEvent(Source<PrintJob>(source).ptr(),
*Details<JobEventDetails>(details).ptr());
break;
}
- case NOTIFY_PRINTED_DOCUMENT_UPDATED: {
+ case NotificationType::PRINTED_DOCUMENT_UPDATED: {
PrintedPage* printed_page = Details<PrintedPage>(details).ptr();
if (printed_page)
OnPrintedDocumentUpdated(*Source<PrintedDocument>(source).ptr(),
diff --git a/chrome/browser/printing/print_job_manager.h b/chrome/browser/printing/print_job_manager.h
index 20424c1..4286a2d 100644
--- a/chrome/browser/printing/print_job_manager.h
+++ b/chrome/browser/printing/print_job_manager.h
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H__
-#define CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H__
+#ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
+#define CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
+
+#include <string>
+#include <vector>
#include "base/lock.h"
#include "base/ref_counted.h"
-#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_observer.h"
namespace printing {
@@ -83,5 +86,4 @@ class PrintJobManager : public NotificationObserver {
} // namespace printing
-#endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H__
-
+#endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
diff --git a/chrome/browser/printing/print_job_unittest.cc b/chrome/browser/printing/print_job_unittest.cc
index a4b529c..6789dd0 100644
--- a/chrome/browser/printing/print_job_unittest.cc
+++ b/chrome/browser/printing/print_job_unittest.cc
@@ -5,6 +5,7 @@
#include "base/message_loop.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/printed_pages_source.h"
+#include "chrome/common/notification_service.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -43,7 +44,7 @@ class TestPrintNotifObserv : public NotificationObserver {
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- ASSERT_EQ(NOTIFY_PRINT_JOB_EVENT, type);
+ ASSERT_EQ(NotificationType::PRINT_JOB_EVENT, type.value);
printing::JobEventDetails::Type event_type =
Details<printing::JobEventDetails>(details)->type();
EXPECT_NE(printing::JobEventDetails::NEW_DOC, event_type);
@@ -70,7 +71,7 @@ TEST(PrintJobTest, SimplePrint) {
TestPrintNotifObserv observ;
MessageLoop current;
NotificationService::current()->AddObserver(
- &observ, NOTIFY_ALL,
+ &observ, NotificationType::ALL,
NotificationService::AllSources());
TestSource source;
volatile bool check = false;
@@ -82,7 +83,7 @@ TEST(PrintJobTest, SimplePrint) {
job = NULL;
EXPECT_TRUE(check);
NotificationService::current()->RemoveObserver(
- &observ, NOTIFY_ALL,
+ &observ, NotificationType::ALL,
NotificationService::AllSources());
}
diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc
index 69e84f0..5f1621f 100644
--- a/chrome/browser/printing/print_job_worker.cc
+++ b/chrome/browser/printing/print_job_worker.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/printing/printed_page.h"
#include "chrome/common/gfx/emf.h"
+#include "chrome/common/notification_service.h"
namespace printing {
@@ -34,7 +35,7 @@ class PrintJobWorker::NotificationTask : public Task {
virtual void Run() {
// Send the notification in the right thread.
NotificationService::current()->Notify(
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
// We know that is is a PrintJob object in this circumstance.
Source<PrintJob>(static_cast<PrintJob*>(print_job_.get())),
Details<JobEventDetails>(details_));
@@ -43,7 +44,6 @@ class PrintJobWorker::NotificationTask : public Task {
// The job which originates this notification.
scoped_refptr<PrintJobWorkerOwner> print_job_;
scoped_refptr<JobEventDetails> details_;
- NotificationType type_;
};
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc
index 436742a..bdc9da3 100644
--- a/chrome/browser/printing/print_view_manager.cc
+++ b/chrome/browser/printing/print_view_manager.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/gfx/emf.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/common/notification_service.h"
#include "generated_resources.h"
@@ -183,8 +184,8 @@ GURL PrintViewManager::RenderSourceUrl() {
void PrintViewManager::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- switch (type) {
- case NOTIFY_PRINT_JOB_EVENT: {
+ switch (type.value) {
+ case NotificationType::PRINT_JOB_EVENT: {
OnNotifyPrintJobEvent(*Details<JobEventDetails>(details).ptr());
break;
}
@@ -398,10 +399,10 @@ bool PrintViewManager::CreateNewPrintJob(PrintJobWorkerOwner* job) {
} else {
print_job_ = new PrintJob(this);
}
- NotificationService::current()->
- AddObserver(this,
- NOTIFY_PRINT_JOB_EVENT,
- Source<PrintJob>(print_job_.get()));
+ NotificationService::current()->AddObserver(
+ this,
+ NotificationType::PRINT_JOB_EVENT,
+ Source<PrintJob>(print_job_.get()));
return true;
}
@@ -453,7 +454,7 @@ void PrintViewManager::ReleasePrintJob() {
return;
NotificationService::current()->RemoveObserver(
this,
- NOTIFY_PRINT_JOB_EVENT,
+ NotificationType::PRINT_JOB_EVENT,
Source<PrintJob>(print_job_.get()));
print_job_->DisconnectSource();
diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h
index 21226c4..405b180 100644
--- a/chrome/browser/printing/print_view_manager.h
+++ b/chrome/browser/printing/print_view_manager.h
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H__
-#define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H__
+#ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
+#define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
#include "chrome/browser/printing/printed_pages_source.h"
-#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_observer.h"
#include "chrome/common/render_messages.h"
class RenderViewHost;
@@ -160,10 +160,9 @@ class PrintViewManager : public NotificationObserver,
// back reference is kept the the "parent object".
WebContents& owner_;
- DISALLOW_EVIL_CONSTRUCTORS(PrintViewManager);
+ DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
};
} // namespace printing
-#endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H__
-
+#endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
diff --git a/chrome/browser/printing/printed_document.cc b/chrome/browser/printing/printed_document.cc
index 7108f83..bdbdbf0 100644
--- a/chrome/browser/printing/printed_document.cc
+++ b/chrome/browser/printing/printed_document.cc
@@ -60,7 +60,7 @@ void PrintedDocument::SetPage(int page_number, gfx::Emf* emf, double shrink) {
}
}
NotificationService::current()->Notify(
- NOTIFY_PRINTED_DOCUMENT_UPDATED,
+ NotificationType::PRINTED_DOCUMENT_UPDATED,
Source<PrintedDocument>(this),
Details<PrintedPage>(page));
}
@@ -245,7 +245,7 @@ void PrintedDocument::set_page_count(int max_page) {
}
}
NotificationService::current()->Notify(
- NOTIFY_PRINTED_DOCUMENT_UPDATED,
+ NotificationType::PRINTED_DOCUMENT_UPDATED,
Source<PrintedDocument>(this),
NotificationService::NoDetails());
}