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

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

Issue 6221005: Print Preview: Store preview data in the print preview controller.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
Index: chrome/browser/printing/print_preview_tab_controller.h
===================================================================
--- chrome/browser/printing/print_preview_tab_controller.h (revision 71104)
+++ chrome/browser/printing/print_preview_tab_controller.h (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,7 +7,7 @@
// printing operation while the first print preview tab is still open, that PP
// tab is focused/activated. There may be more than one PP tab open. There is a
// 1:1 relationship between PP tabs and initiating tabs. This class manages PP
-// tabs and initiator tabs.
+// tabs, and the associated initiator tabs and print preview data.
James Hawkins 2011/01/13 06:43:27 This really feels shoe-horned in here. The name o
#ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_
#define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_
@@ -22,36 +22,58 @@
class Browser;
class TabContents;
+namespace base {
+class SharedMemory;
+}
+
namespace printing {
class PrintPreviewTabController
: public base::RefCounted<PrintPreviewTabController>,
public NotificationObserver {
public:
+ typedef std::pair<base::SharedMemory*, uint32> PrintPreviewData;
+
PrintPreviewTabController();
virtual ~PrintPreviewTabController();
static PrintPreviewTabController* GetInstance();
+ // Returns true if |tab| is a print preview tab.
+ static bool IsPrintPreviewTab(TabContents* tab);
+
// Get/Create the print preview tab for |initiator_tab|.
// |browser_window_id| is the browser window containing |initiator_tab|.
TabContents* GetOrCreatePreviewTab(
TabContents* initiator_tab, int browser_window_id);
+ // Get the print preview |data| for |preview_tab|. The data is valid as long
+ // as |preview_tab| is valid and SetPrintPreviewData() does not get called.
+ bool GetPrintPreviewData(TabContents* preview_tab, PrintPreviewData* data);
+
+ // Save the print preview |data| for |preview_tab|. PrintPreviewTabController
+ // owns the data and is responsible for freeing it when either:
+ // a) there is new data.
+ // b) when |preview_tab| goes away.
+ bool SetPrintPreviewData(TabContents* preview_tab,
+ const PrintPreviewData& data);
+
// Notification observer implementation.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
- // Returns true if |tab| is a print preview tab.
- static bool IsPrintPreviewTab(TabContents* tab);
-
private:
friend class base::RefCounted<PrintPreviewTabController>;
+ // 1:1 relationship between print preview tab and its print preview data.
+ // Key: Print preview tab.
+ // Value: Print preview data.
+ typedef std::map<TabContents*, PrintPreviewData> PrintPreviewDataMap;
+
// 1:1 relationship between initiator tab and print preview tab.
- // Key: Preview tab.
+ // Key: Print preview tab.
// Value: Initiator tab.
typedef std::map<TabContents*, TabContents*> PrintPreviewTabMap;
@@ -72,6 +94,7 @@
void AddObservers(TabContents* tab);
void RemoveObservers(TabContents* tab);
+ PrintPreviewDataMap preview_data_map_;
PrintPreviewTabMap preview_tab_map_;
// A registrar for listening notifications.

Powered by Google App Engine
This is Rietveld 408576698