| OLD | NEW | 
|    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/print_view_manager.h" |    5 #include "chrome/browser/printing/print_view_manager.h" | 
|    6  |    6  | 
|    7 #include <map> |    7 #include <map> | 
|    8  |    8  | 
|    9 #include "base/bind.h" |    9 #include "base/bind.h" | 
|   10 #include "base/command_line.h" |   10 #include "base/command_line.h" | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   73       print_preview_state_(NOT_PREVIEWING), |   73       print_preview_state_(NOT_PREVIEWING), | 
|   74       scripted_print_preview_rph_(NULL), |   74       scripted_print_preview_rph_(NULL), | 
|   75       tab_content_blocked_(false) { |   75       tab_content_blocked_(false) { | 
|   76 #if defined(OS_POSIX) && !defined(OS_MACOSX) |   76 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 
|   77   expecting_first_page_ = true; |   77   expecting_first_page_ = true; | 
|   78 #endif |   78 #endif | 
|   79   registrar_.Add(this, chrome::NOTIFICATION_CONTENT_BLOCKED_STATE_CHANGED, |   79   registrar_.Add(this, chrome::NOTIFICATION_CONTENT_BLOCKED_STATE_CHANGED, | 
|   80                  content::Source<content::WebContents>(web_contents)); |   80                  content::Source<content::WebContents>(web_contents)); | 
|   81   Profile* profile = |   81   Profile* profile = | 
|   82       Profile::FromBrowserContext(web_contents->GetBrowserContext()); |   82       Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 
|   83   printing_enabled_.Init(prefs::kPrintingEnabled, |   83   printing_enabled_.Init( | 
|   84                          profile->GetPrefs(), |   84       prefs::kPrintingEnabled, | 
|   85                          this); |   85       profile->GetPrefs(), | 
 |   86       base::Bind(&PrintViewManager::UpdateScriptedPrintingBlocked, | 
 |   87                  base::Unretained(this))); | 
|   86 } |   88 } | 
|   87  |   89  | 
|   88 PrintViewManager::~PrintViewManager() { |   90 PrintViewManager::~PrintViewManager() { | 
|   89   DCHECK_EQ(NOT_PREVIEWING, print_preview_state_); |   91   DCHECK_EQ(NOT_PREVIEWING, print_preview_state_); | 
|   90   ReleasePrinterQuery(); |   92   ReleasePrinterQuery(); | 
|   91   DisconnectFromCurrentPrintJob(); |   93   DisconnectFromCurrentPrintJob(); | 
|   92 } |   94 } | 
|   93  |   95  | 
|   94 bool PrintViewManager::PrintNow() { |   96 bool PrintViewManager::PrintNow() { | 
|   95   return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); |   97   return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); | 
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  387       UpdateScriptedPrintingBlocked(); |  389       UpdateScriptedPrintingBlocked(); | 
|  388       break; |  390       break; | 
|  389     } |  391     } | 
|  390     default: { |  392     default: { | 
|  391       NOTREACHED(); |  393       NOTREACHED(); | 
|  392       break; |  394       break; | 
|  393     } |  395     } | 
|  394   } |  396   } | 
|  395 } |  397 } | 
|  396  |  398  | 
|  397 void PrintViewManager::OnPreferenceChanged(PrefServiceBase* service, |  | 
|  398                                            const std::string& pref_name) { |  | 
|  399   UpdateScriptedPrintingBlocked(); |  | 
|  400 } |  | 
|  401  |  | 
|  402 void PrintViewManager::OnNotifyPrintJobEvent( |  399 void PrintViewManager::OnNotifyPrintJobEvent( | 
|  403     const JobEventDetails& event_details) { |  400     const JobEventDetails& event_details) { | 
|  404   switch (event_details.type()) { |  401   switch (event_details.type()) { | 
|  405     case JobEventDetails::FAILED: { |  402     case JobEventDetails::FAILED: { | 
|  406       TerminatePrintJob(true); |  403       TerminatePrintJob(true); | 
|  407  |  404  | 
|  408       content::NotificationService::current()->Notify( |  405       content::NotificationService::current()->Notify( | 
|  409           chrome::NOTIFICATION_PRINT_JOB_RELEASED, |  406           chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 
|  410           content::Source<content::WebContents>(web_contents()), |  407           content::Source<content::WebContents>(web_contents()), | 
|  411           content::NotificationService::NoDetails()); |  408           content::NotificationService::NoDetails()); | 
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  677   scoped_refptr<printing::PrinterQuery> printer_query; |  674   scoped_refptr<printing::PrinterQuery> printer_query; | 
|  678   print_job_manager->PopPrinterQuery(cookie, &printer_query); |  675   print_job_manager->PopPrinterQuery(cookie, &printer_query); | 
|  679   if (!printer_query.get()) |  676   if (!printer_query.get()) | 
|  680     return; |  677     return; | 
|  681   BrowserThread::PostTask( |  678   BrowserThread::PostTask( | 
|  682       BrowserThread::IO, FROM_HERE, |  679       BrowserThread::IO, FROM_HERE, | 
|  683       base::Bind(&PrinterQuery::StopWorker, printer_query.get())); |  680       base::Bind(&PrinterQuery::StopWorker, printer_query.get())); | 
|  684 } |  681 } | 
|  685  |  682  | 
|  686 }  // namespace printing |  683 }  // namespace printing | 
| OLD | NEW |