Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / components / html_viewer / html_document_application_delegate.h
blob91acbf2c519b15b31a75c04e09c42b773bce6194
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_
6 #define COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_
8 #include <set>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "components/html_viewer/html_frame.h"
15 #include "mojo/application/public/cpp/application_delegate.h"
16 #include "mojo/application/public/cpp/application_impl.h"
17 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
18 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
20 namespace html_viewer {
22 class GlobalState;
23 class HTMLDocumentOOPIF;
25 // ApplicationDelegate created by the content handler for a specific url.
26 class HTMLDocumentApplicationDelegate : public mojo::ApplicationDelegate {
27 public:
28 HTMLDocumentApplicationDelegate(
29 mojo::InterfaceRequest<mojo::Application> request,
30 mojo::URLResponsePtr response,
31 GlobalState* global_state,
32 scoped_ptr<mojo::AppRefCount> parent_app_refcount);
34 using HTMLFrameCreationCallback =
35 base::Callback<HTMLFrame*(HTMLFrame::CreateParams*)>;
37 void SetHTMLFrameCreationCallback(const HTMLFrameCreationCallback& callback);
39 private:
40 class ServiceConnectorQueue;
42 ~HTMLDocumentApplicationDelegate() override;
44 // Callback from the quit closure. We key off this rather than
45 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop
46 // when we quit (the messageloop is shared among multiple
47 // HTMLDocumentApplicationDelegates).
48 void OnTerminate();
50 // ApplicationDelegate:
51 void Initialize(mojo::ApplicationImpl* app) override;
52 bool ConfigureIncomingConnection(
53 mojo::ApplicationConnection* connection) override;
55 void OnHTMLDocumentDeleted2(HTMLDocumentOOPIF* document);
56 void OnResponseReceived(mojo::URLLoaderPtr loader,
57 mojo::ApplicationConnection* connection,
58 scoped_ptr<ServiceConnectorQueue> connector_queue,
59 mojo::URLResponsePtr response);
61 mojo::ApplicationImpl app_;
62 // AppRefCount of the parent (HTMLViewer).
63 scoped_ptr<mojo::AppRefCount> parent_app_refcount_;
64 const mojo::String url_;
65 mojo::URLLoaderFactoryPtr url_loader_factory_;
66 mojo::URLResponsePtr initial_response_;
67 GlobalState* global_state_;
69 // As we create HTMLDocuments they are added here. They are removed when the
70 // HTMLDocument is deleted.
71 std::set<HTMLDocumentOOPIF*> documents2_;
73 HTMLFrameCreationCallback html_frame_creation_callback_;
75 base::WeakPtrFactory<HTMLDocumentApplicationDelegate> weak_factory_;
77 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentApplicationDelegate);
80 } // namespace html_viewer
82 #endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_