| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ |
| 6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ | 6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class ManifestFetcher; | 25 class ManifestFetcher; |
| 26 | 26 |
| 27 // The ManifestManager is a helper class that takes care of fetching and parsing | 27 // The ManifestManager is a helper class that takes care of fetching and parsing |
| 28 // the Manifest of the associated RenderFrame. It uses the ManifestFetcher and | 28 // the Manifest of the associated RenderFrame. It uses the ManifestFetcher and |
| 29 // the ManifestParser in order to do so. | 29 // the ManifestParser in order to do so. |
| 30 // There are two expected consumers of this helper: ManifestManagerHost, via IPC | 30 // There are two expected consumers of this helper: ManifestManagerHost, via IPC |
| 31 // messages and callers inside the renderer process. The latter should use | 31 // messages and callers inside the renderer process. The latter should use |
| 32 // GetManifest(). | 32 // GetManifest(). |
| 33 class ManifestManager : public RenderFrameObserver { | 33 class ManifestManager : public RenderFrameObserver { |
| 34 public: | 34 public: |
| 35 typedef base::Callback<void(const Manifest&, | 35 typedef base::Callback<void(const GURL&, |
| 36 const Manifest&, |
| 36 const ManifestDebugInfo&)> GetManifestCallback; | 37 const ManifestDebugInfo&)> GetManifestCallback; |
| 37 | 38 |
| 38 explicit ManifestManager(RenderFrame* render_frame); | 39 explicit ManifestManager(RenderFrame* render_frame); |
| 39 ~ManifestManager() override; | 40 ~ManifestManager() override; |
| 40 | 41 |
| 41 // Will call the given |callback| with the Manifest associated with the | 42 // Will call the given |callback| with the Manifest associated with the |
| 42 // RenderFrame if any. Will pass an empty Manifest in case of error. | 43 // RenderFrame if any. Will pass an empty Manifest in case of error. |
| 43 void GetManifest(const GetManifestCallback& callback); | 44 void GetManifest(const GetManifestCallback& callback); |
| 44 | 45 |
| 45 // RenderFrameObserver implementation. | 46 // RenderFrameObserver implementation. |
| 46 bool OnMessageReceived(const IPC::Message& message) override; | 47 bool OnMessageReceived(const IPC::Message& message) override; |
| 47 void DidChangeManifest() override; | 48 void DidChangeManifest() override; |
| 48 void DidCommitProvisionalLoad(bool is_new_navigation, | 49 void DidCommitProvisionalLoad(bool is_new_navigation, |
| 49 bool is_same_page_navigation) override; | 50 bool is_same_page_navigation) override; |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 enum ResolveState { | 53 enum ResolveState { |
| 53 ResolveStateSuccess, | 54 ResolveStateSuccess, |
| 54 ResolveStateFailure | 55 ResolveStateFailure |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 // RenderFrameObserver implementation. | 58 // RenderFrameObserver implementation. |
| 58 void OnDestruct() override; | 59 void OnDestruct() override; |
| 59 | 60 |
| 60 // Called when receiving a ManifestManagerMsg_RequestManifest from the browser | 61 // Called when receiving a ManifestManagerMsg_RequestManifest from the browser |
| 61 // process. | 62 // process. |
| 62 void OnHasManifest(int request_id); | 63 void OnHasManifest(int request_id); |
| 63 void OnRequestManifest(int request_id); | 64 void OnRequestManifest(int request_id); |
| 64 void OnRequestManifestComplete(int request_id, | 65 void OnRequestManifestComplete(int request_id, |
| 66 const GURL&, |
| 65 const Manifest&, | 67 const Manifest&, |
| 66 const ManifestDebugInfo&); | 68 const ManifestDebugInfo&); |
| 67 | 69 |
| 68 void FetchManifest(); | 70 void FetchManifest(); |
| 69 void OnManifestFetchComplete(const GURL& document_url, | 71 void OnManifestFetchComplete(const GURL& document_url, |
| 70 const blink::WebURLResponse& response, | 72 const blink::WebURLResponse& response, |
| 71 const std::string& data); | 73 const std::string& data); |
| 72 void ResolveCallbacks(ResolveState state); | 74 void ResolveCallbacks(ResolveState state); |
| 73 | 75 |
| 74 std::unique_ptr<ManifestFetcher> fetcher_; | 76 std::unique_ptr<ManifestFetcher> fetcher_; |
| 75 | 77 |
| 76 // Whether the RenderFrame may have an associated Manifest. If true, the frame | 78 // Whether the RenderFrame may have an associated Manifest. If true, the frame |
| 77 // may have a manifest, if false, it can't have one. This boolean is true when | 79 // may have a manifest, if false, it can't have one. This boolean is true when |
| 78 // DidChangeManifest() is called, if it is never called, it means that the | 80 // DidChangeManifest() is called, if it is never called, it means that the |
| 79 // associated document has no <link rel='manifest'>. | 81 // associated document has no <link rel='manifest'>. |
| 80 bool may_have_manifest_; | 82 bool may_have_manifest_; |
| 81 | 83 |
| 82 // Whether the current Manifest is dirty. | 84 // Whether the current Manifest is dirty. |
| 83 bool manifest_dirty_; | 85 bool manifest_dirty_; |
| 84 | 86 |
| 85 // Current Manifest. Might be outdated if manifest_dirty_ is true. | 87 // Current Manifest. Might be outdated if manifest_dirty_ is true. |
| 86 Manifest manifest_; | 88 Manifest manifest_; |
| 87 | 89 |
| 90 // The URL of the current manifest. |
| 91 GURL manifest_url_; |
| 92 |
| 88 // Current Manifest debug information. | 93 // Current Manifest debug information. |
| 89 ManifestDebugInfo manifest_debug_info_; | 94 ManifestDebugInfo manifest_debug_info_; |
| 90 | 95 |
| 91 std::list<GetManifestCallback> pending_callbacks_; | 96 std::list<GetManifestCallback> pending_callbacks_; |
| 92 | 97 |
| 93 DISALLOW_COPY_AND_ASSIGN(ManifestManager); | 98 DISALLOW_COPY_AND_ASSIGN(ManifestManager); |
| 94 }; | 99 }; |
| 95 | 100 |
| 96 } // namespace content | 101 } // namespace content |
| 97 | 102 |
| 98 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ | 103 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ |
| OLD | NEW |