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

Unified Diff: chrome/browser/printing/print_job_worker.cc

Issue 506273004: Removed redundant PrintingUIWebContentsObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tue Aug 26 14:12:01 PDT 2014 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/printing/print_job_worker.h ('k') | chrome/browser/printing/printer_query.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/print_job_worker.cc
diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc
index 2dcd7887343b3bfdc100bbde7300ca41d314b7ae..ce739a99458f75f4508734108f9647009e697b70 100644
--- a/chrome/browser/printing/print_job_worker.cc
+++ b/chrome/browser/printing/print_job_worker.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job.h"
-#include "chrome/browser/printing/printing_ui_web_contents_observer.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -46,58 +45,33 @@ class PrintingContextDelegate : public PrintingContext::Delegate {
virtual std::string GetAppLocale() OVERRIDE;
private:
- void InitOnUiThread(int render_process_id, int render_view_id);
-
- scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer_;
- base::WeakPtrFactory<PrintingContextDelegate> weak_ptr_factory_;
+ int render_process_id_;
+ int render_view_id_;
};
PrintingContextDelegate::PrintingContextDelegate(int render_process_id,
int render_view_id)
- : weak_ptr_factory_(this) {
- InitOnUiThread(render_process_id, render_view_id);
+ : render_process_id_(render_process_id),
+ render_view_id_(render_view_id) {
}
PrintingContextDelegate::~PrintingContextDelegate() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
gfx::NativeView PrintingContextDelegate::GetParentView() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (!web_contents_observer_)
+ content::RenderViewHost* view =
+ content::RenderViewHost::FromID(render_process_id_, render_view_id_);
+ if (!view)
return NULL;
- return web_contents_observer_->GetParentView();
+ content::WebContents* wc = content::WebContents::FromRenderViewHost(view);
+ return wc ? wc->GetNativeView() : NULL;
}
std::string PrintingContextDelegate::GetAppLocale() {
return g_browser_process->GetApplicationLocale();
}
-void PrintingContextDelegate::InitOnUiThread(int render_process_id,
- int render_view_id) {
- if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- // All data initialized here should be accessed on UI thread. Because object
- // is being constructed now, anything that is going to access
- // PrintingContextDelegate on UI thread would be scheduled after the tasks
- // below.
- BrowserThread::PostTask(BrowserThread::UI,
- FROM_HERE,
- base::Bind(&PrintingContextDelegate::InitOnUiThread,
- weak_ptr_factory_.GetWeakPtr(),
- render_process_id,
- render_view_id));
- return;
- }
- content::RenderViewHost* view =
- content::RenderViewHost::FromID(render_process_id, render_view_id);
- if (!view)
- return;
- content::WebContents* wc = content::WebContents::FromRenderViewHost(view);
- if (!wc)
- return;
- web_contents_observer_.reset(new PrintingUIWebContentsObserver(wc));
-}
-
void NotificationCallback(PrintJobWorkerOwner* print_job,
JobEventDetails::Type detail_type,
PrintedDocument* document,
« no previous file with comments | « chrome/browser/printing/print_job_worker.h ('k') | chrome/browser/printing/printer_query.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698