Index: components/html_viewer/html_document_application_delegate.cc |
diff --git a/components/html_viewer/html_document_application_delegate.cc b/components/html_viewer/html_document_application_delegate.cc |
index afb82505ffb22df7f32269dbdbbd9c5cdc3089e4..8638640167463b9cce2f6cacbe8d720b6d9a74d0 100644 |
--- a/components/html_viewer/html_document_application_delegate.cc |
+++ b/components/html_viewer/html_document_application_delegate.cc |
@@ -7,7 +7,6 @@ |
#include "base/bind.h" |
#include "base/command_line.h" |
#include "components/html_viewer/global_state.h" |
-#include "components/html_viewer/html_document.h" |
#include "components/html_viewer/html_document_oopif.h" |
#include "components/html_viewer/html_viewer_switches.h" |
#include "mojo/application/public/cpp/application_connection.h" |
@@ -22,6 +21,10 @@ bool EnableOOPIFs() { |
return base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kOOPIF); |
} |
+HTMLDocument* CreateHTMLDocument(HTMLDocument::CreateParams* params) { |
+ return new HTMLDocument(params); |
+} |
+ |
} // namespace |
// ServiceConnectorQueue records all incoming service requests and processes |
@@ -75,7 +78,8 @@ HTMLDocumentApplicationDelegate::HTMLDocumentApplicationDelegate( |
parent_app_refcount_(parent_app_refcount.Pass()), |
url_(response->url), |
initial_response_(response.Pass()), |
- global_state_(global_state) { |
+ global_state_(global_state), |
+ html_document_creation_callback_(base::Bind(CreateHTMLDocument)) { |
} |
HTMLDocumentApplicationDelegate::~HTMLDocumentApplicationDelegate() { |
@@ -93,6 +97,11 @@ HTMLDocumentApplicationDelegate::~HTMLDocumentApplicationDelegate() { |
DCHECK(documents2_.empty()); |
} |
+void HTMLDocumentApplicationDelegate::SetHTMLDocumentCreationCallback( |
+ const HTMLDocumentCreationCallback& callback) { |
+ html_document_creation_callback_ = callback; |
+} |
+ |
// Callback from the quit closure. We key off this rather than |
// ApplicationDelegate::Quit() as we don't want to shut down the messageloop |
// when we quit (the messageloop is shared among multiple |
@@ -172,7 +181,7 @@ void HTMLDocumentApplicationDelegate::OnResponseReceived( |
&app_, connection, response.Pass(), global_state_, |
base::Bind(&HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted, |
base::Unretained(this))); |
- HTMLDocument* document = new HTMLDocument(¶ms); |
+ HTMLDocument* document = html_document_creation_callback_.Run(¶ms); |
documents_.insert(document); |
} |