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

Unified Diff: chrome/browser/printing/print_preview_dialog_controller.h

Issue 243703004: Revert "Remove notifications from PrintPreviewDialogController." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « no previous file | chrome/browser/printing/print_preview_dialog_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/print_preview_dialog_controller.h
diff --git a/chrome/browser/printing/print_preview_dialog_controller.h b/chrome/browser/printing/print_preview_dialog_controller.h
index 3fc870827a4cb0b426e369c9375c8d170918a71e..e29635f05c224684d772fe5b2cee652feba687c3 100644
--- a/chrome/browser/printing/print_preview_dialog_controller.h
+++ b/chrome/browser/printing/print_preview_dialog_controller.h
@@ -5,12 +5,14 @@
#ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_
#define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_
-#include <vector>
+#include <map>
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/sessions/session_id.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
class GURL;
@@ -29,7 +31,8 @@ namespace printing {
// track of the 1:1 relationship between initiator tabs and print preview
// dialogs.
class PrintPreviewDialogController
- : public base::RefCounted<PrintPreviewDialogController> {
+ : public base::RefCounted<PrintPreviewDialogController>,
+ public content::NotificationObserver {
public:
PrintPreviewDialogController();
@@ -58,6 +61,11 @@ class PrintPreviewDialogController
void ForEachPreviewDialog(
base::Callback<void(content::WebContents*)> callback);
+ // content::NotificationObserver implementation.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
// Returns true if |contents| is a print preview dialog.
static bool IsPrintPreviewDialog(content::WebContents* contents);
@@ -73,15 +81,27 @@ class PrintPreviewDialogController
private:
friend class base::RefCounted<PrintPreviewDialogController>;
- struct Operation;
+
+ // 1:1 relationship between a print preview dialog and its initiator tab.
+ // Key: Print preview dialog.
+ // Value: Initiator.
+ typedef std::map<content::WebContents*, content::WebContents*>
+ PrintPreviewDialogMap;
virtual ~PrintPreviewDialogController();
- // Handlers for observed events.
- void OnRenderProcessExited(content::RenderProcessHost* rph);
+ // Handler for the RENDERER_PROCESS_CLOSED notification. This is observed when
+ // the initiator renderer crashed.
+ void OnRendererProcessClosed(content::RenderProcessHost* rph);
+
+ // Handler for the WEB_CONTENTS_DESTROYED notification. This is observed when
+ // either WebContents is closed.
void OnWebContentsDestroyed(content::WebContents* contents);
- void OnNavigationEntryCommitted(content::WebContents* contents,
- const content::LoadCommittedDetails* details);
+
+ // Handler for the NAV_ENTRY_COMMITTED notification. This is observed when the
+ // renderer is navigated to a different page.
+ void OnNavEntryCommitted(content::WebContents* contents,
+ content::LoadCommittedDetails* details);
// Creates a new print preview dialog.
content::WebContents* CreatePrintPreviewDialog(
@@ -91,12 +111,19 @@ class PrintPreviewDialogController
// |preview_dialog| in |preview_dialog|'s PrintPreviewUI.
void SaveInitiatorTitle(content::WebContents* preview_dialog);
+ // Adds/Removes observers for notifications from |contents|.
+ void AddObservers(content::WebContents* contents);
+ void RemoveObservers(content::WebContents* contents);
+
// Removes WebContents when they close/crash/navigate.
void RemoveInitiator(content::WebContents* initiator);
void RemovePreviewDialog(content::WebContents* preview_dialog);
- // The list of the currently active preview operations.
- std::vector<Operation*> preview_operations_;
+ // Mapping between print preview dialog and the corresponding initiator.
+ PrintPreviewDialogMap preview_dialog_map_;
+
+ // A registrar for listening to notifications.
+ content::NotificationRegistrar registrar_;
// True if the controller is waiting for a new preview dialog via
// content::NAVIGATION_TYPE_NEW_PAGE.
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_dialog_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698