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

Unified Diff: chrome/browser/ui/webui/print_preview_ui.cc

Issue 7063030: PrintPreview: Print Preview is not staying associated with initiator renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 7 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/ui/webui/print_preview_ui.cc
diff --git a/chrome/browser/ui/webui/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview_ui.cc
index 29253d45b2dc4db0be6c6c84ef34bccf1acde94f..980888870ce8dde70f8b34a67e6d1c3e1bdc9cec 100644
--- a/chrome/browser/ui/webui/print_preview_ui.cc
+++ b/chrome/browser/ui/webui/print_preview_ui.cc
@@ -4,29 +4,44 @@
#include "chrome/browser/ui/webui/print_preview_ui.h"
+#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/printing/print_preview_data_service_factory.h"
+#include "chrome/browser/printing/print_preview_data_service.h"
+#include "chrome/browser/ui/webui/print_preview_data_source.h"
#include "chrome/browser/ui/webui/print_preview_handler.h"
-#include "chrome/browser/ui/webui/print_preview_ui_html_source.h"
-#include "content/browser/browser_thread.h"
#include "content/browser/tab_contents/tab_contents.h"
-PrintPreviewUI::PrintPreviewUI(TabContents* contents)
- : WebUI(contents),
- html_source_(new PrintPreviewUIHTMLSource()) {
+PrintPreviewUI::PrintPreviewUI(TabContents* contents) : WebUI(contents) {
// PrintPreviewUI owns |handler|.
PrintPreviewHandler* handler = new PrintPreviewHandler();
AddMessageHandler(handler->Attach(this));
- // Set up the chrome://print/ source.
- contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source_);
+ // Set up the chrome://print/ data source.
+ PrintPreviewDataSource* data_source =
+ new PrintPreviewDataSource(contents->profile());
+ contents->profile()->GetChromeURLDataManager()->AddDataSource(data_source);
+
+ // Store the PrintPreviewUIAddress as a string.
+ char preview_ui_addr[(2 * sizeof(this)) + 3];
Lei Zhang 2011/05/27 17:26:53 add a comment to explain the math here.
kmadhusu 2011/05/27 23:44:42 Done.
+ base::snprintf(preview_ui_addr, sizeof(preview_ui_addr), "%p", this);
+ preview_ui_addr_str_ = preview_ui_addr;
}
PrintPreviewUI::~PrintPreviewUI() {
+ PrintPreviewDataServiceFactory::GetForProfile(tab_contents()->profile())->
+ RemoveEntry(preview_ui_addr_str_);
+}
+
+void PrintPreviewUI::GetPrintPreviewData(scoped_refptr<RefCountedBytes>* data) {
+ PrintPreviewDataServiceFactory::GetForProfile(tab_contents()->profile())->
Lei Zhang 2011/05/27 17:26:53 You call PrintPreviewDataServiceFactory::GetForPro
Elliot Glaysher 2011/05/27 17:45:50 I'd prefer not to cache that value now that there'
kmadhusu 2011/05/27 23:44:42 Created a helper function.
+ GetDataEntry(preview_ui_addr_str_, data);
}
-PrintPreviewUIHTMLSource* PrintPreviewUI::html_source() {
- return html_source_.get();
+void PrintPreviewUI::SetPrintPreviewData(const RefCountedBytes* data) {
+ PrintPreviewDataServiceFactory::GetForProfile(tab_contents()->profile())->
+ SetDataEntry(preview_ui_addr_str_, data);
}
void PrintPreviewUI::OnInitiatorTabClosed(
@@ -43,6 +58,7 @@ void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count,
FundamentalValue pages_count(expected_pages_count);
StringValue title(job_title);
FundamentalValue is_preview_modifiable(modifiable);
+ StringValue ui_identifier(preview_ui_addr_str_);
CallJavascriptFunction("updatePrintPreview", pages_count, title,
- is_preview_modifiable);
+ is_preview_modifiable, ui_identifier);
}

Powered by Google App Engine
This is Rietveld 408576698