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

Side by Side Diff: content/renderer/manifest/manifest_manager.h

Issue 1932623003: DevTools: Introduce Page.getManifest remote debugging protocol method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: browser test updated Created 4 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 unified diff | Download patch
OLDNEW
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
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "content/public/common/manifest.h" 13 #include "content/public/common/manifest.h"
14 #include "content/public/renderer/render_frame_observer.h" 14 #include "content/public/renderer/render_frame_observer.h"
15 #include "content/renderer/manifest/manifest_debug_info.h"
15 16
16 class GURL; 17 class GURL;
17 18
18 namespace blink { 19 namespace blink {
19 class WebURLResponse; 20 class WebURLResponse;
20 } 21 }
21 22
22 namespace content { 23 namespace content {
23 24
24 class ManifestFetcher; 25 class ManifestFetcher;
25 26
26 // 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
27 // the Manifest of the associated RenderFrame. It uses the ManifestFetcher and 28 // the Manifest of the associated RenderFrame. It uses the ManifestFetcher and
28 // the ManifestParser in order to do so. 29 // the ManifestParser in order to do so.
29 // There are two expected consumers of this helper: ManifestManagerHost, via IPC 30 // There are two expected consumers of this helper: ManifestManagerHost, via IPC
30 // messages and callers inside the renderer process. The latter should use 31 // messages and callers inside the renderer process. The latter should use
31 // GetManifest(). 32 // GetManifest().
32 class ManifestManager : public RenderFrameObserver { 33 class ManifestManager : public RenderFrameObserver {
33 public: 34 public:
34 typedef base::Callback<void(const Manifest&)> GetManifestCallback; 35 typedef base::Callback<void(const Manifest&,
36 const ManifestDebugInfo&)> GetManifestCallback;
35 37
36 explicit ManifestManager(RenderFrame* render_frame); 38 explicit ManifestManager(RenderFrame* render_frame);
37 ~ManifestManager() override; 39 ~ManifestManager() override;
38 40
39 // Will call the given |callback| with the Manifest associated with the 41 // Will call the given |callback| with the Manifest associated with the
40 // RenderFrame if any. Will pass an empty Manifest in case of error. 42 // RenderFrame if any. Will pass an empty Manifest in case of error.
41 void GetManifest(const GetManifestCallback& callback); 43 void GetManifest(const GetManifestCallback& callback);
42 44
43 // RenderFrameObserver implementation. 45 // RenderFrameObserver implementation.
44 bool OnMessageReceived(const IPC::Message& message) override; 46 bool OnMessageReceived(const IPC::Message& message) override;
45 void DidChangeManifest() override; 47 void DidChangeManifest() override;
46 void DidCommitProvisionalLoad(bool is_new_navigation, 48 void DidCommitProvisionalLoad(bool is_new_navigation,
47 bool is_same_page_navigation) override; 49 bool is_same_page_navigation) override;
48 50
49 private: 51 private:
50 enum ResolveState { 52 enum ResolveState {
51 ResolveStateSuccess, 53 ResolveStateSuccess,
52 ResolveStateFailure 54 ResolveStateFailure
53 }; 55 };
54 56
55 // Called when receiving a ManifestManagerMsg_RequestManifest from the browser 57 // Called when receiving a ManifestManagerMsg_RequestManifest from the browser
56 // process. 58 // process.
57 void OnHasManifest(int request_id); 59 void OnHasManifest(int request_id);
58 void OnRequestManifest(int request_id); 60 void OnRequestManifest(int request_id);
59 void OnRequestManifestComplete(int request_id, const Manifest&); 61 void OnRequestManifestComplete(int request_id,
62 const Manifest&,
63 const ManifestDebugInfo&);
60 64
61 void FetchManifest(); 65 void FetchManifest();
62 void OnManifestFetchComplete(const GURL& document_url, 66 void OnManifestFetchComplete(const GURL& document_url,
63 const blink::WebURLResponse& response, 67 const blink::WebURLResponse& response,
64 const std::string& data); 68 const std::string& data);
65 void ResolveCallbacks(ResolveState state); 69 void ResolveCallbacks(ResolveState state);
66 70
67 std::unique_ptr<ManifestFetcher> fetcher_; 71 std::unique_ptr<ManifestFetcher> fetcher_;
68 72
69 // Whether the RenderFrame may have an associated Manifest. If true, the frame 73 // Whether the RenderFrame may have an associated Manifest. If true, the frame
70 // may have a manifest, if false, it can't have one. This boolean is true when 74 // may have a manifest, if false, it can't have one. This boolean is true when
71 // DidChangeManifest() is called, if it is never called, it means that the 75 // DidChangeManifest() is called, if it is never called, it means that the
72 // associated document has no <link rel='manifest'>. 76 // associated document has no <link rel='manifest'>.
73 bool may_have_manifest_; 77 bool may_have_manifest_;
74 78
75 // Whether the current Manifest is dirty. 79 // Whether the current Manifest is dirty.
76 bool manifest_dirty_; 80 bool manifest_dirty_;
77 81
78 // Current Manifest. Might be outdated if manifest_dirty_ is true. 82 // Current Manifest. Might be outdated if manifest_dirty_ is true.
79 Manifest manifest_; 83 Manifest manifest_;
80 84
85 // Current Manifest debug information.
86 ManifestDebugInfo manifest_debug_info_;
87
81 std::list<GetManifestCallback> pending_callbacks_; 88 std::list<GetManifestCallback> pending_callbacks_;
82 89
83 DISALLOW_COPY_AND_ASSIGN(ManifestManager); 90 DISALLOW_COPY_AND_ASSIGN(ManifestManager);
84 }; 91 };
85 92
86 } // namespace content 93 } // namespace content
87 94
88 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ 95 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_debug_info.cc ('k') | content/renderer/manifest/manifest_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698