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

Side by Side Diff: content/browser/manifest/manifest_manager_host.h

Issue 2140463002: Remove WebContents::HasManifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explanatory comment for manifest_url_ resetting Created 4 years, 5 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_BROWSER_MANIFEST_MANIFEST_MANAGER_HOST_H_ 5 #ifndef CONTENT_BROWSER_MANIFEST_MANIFEST_MANAGER_HOST_H_
6 #define CONTENT_BROWSER_MANIFEST_MANIFEST_MANAGER_HOST_H_ 6 #define CONTENT_BROWSER_MANIFEST_MANIFEST_MANAGER_HOST_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/id_map.h" 9 #include "base/id_map.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/web_contents_observer.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class RenderFrameHost; 15 class RenderFrameHost;
16 class WebContents; 16 class WebContents;
17 struct Manifest; 17 struct Manifest;
18 18
19 // ManifestManagerHost is a helper class that allows callers to get the Manifest 19 // ManifestManagerHost is a helper class that allows callers to get the Manifest
20 // associated with a frame. It handles the IPC messaging with the child process. 20 // associated with a frame. It handles the IPC messaging with the child process.
21 // TODO(mlamouri): keep a cached version and a dirty bit here. 21 // TODO(mlamouri): keep a cached version and a dirty bit here.
22 class ManifestManagerHost : public WebContentsObserver { 22 class ManifestManagerHost : public WebContentsObserver {
23 public: 23 public:
24 explicit ManifestManagerHost(WebContents* web_contents); 24 explicit ManifestManagerHost(WebContents* web_contents);
25 ~ManifestManagerHost() override; 25 ~ManifestManagerHost() override;
26 26
27 using GetManifestCallback = 27 using GetManifestCallback =
28 base::Callback<void(const GURL&, const Manifest&)>; 28 base::Callback<void(const GURL&, const Manifest&)>;
29 using HasManifestCallback = base::Callback<void(bool)>;
30 29
31 // Calls the given callback with the manifest associated with the 30 // Calls the given callback with the manifest associated with the
32 // given RenderFrameHost. If the frame has no manifest or if getting it failed 31 // given RenderFrameHost. If the frame has no manifest or if getting it failed
33 // the callback will have an empty manifest. 32 // the callback will have an empty manifest.
34 void GetManifest(RenderFrameHost*, const GetManifestCallback&); 33 void GetManifest(RenderFrameHost*, const GetManifestCallback&);
35 34
36 // Calls the given callback with a bool indicating whether or not the document
37 // associated with the given RenderFrameHost has a manifest.
38 void HasManifest(RenderFrameHost*, const HasManifestCallback&);
39
40 // WebContentsObserver 35 // WebContentsObserver
41 bool OnMessageReceived(const IPC::Message&, RenderFrameHost*) override; 36 bool OnMessageReceived(const IPC::Message&, RenderFrameHost*) override;
42 void RenderFrameDeleted(RenderFrameHost*) override; 37 void RenderFrameDeleted(RenderFrameHost*) override;
43 38
44 private: 39 private:
45 using GetCallbackMap = IDMap<GetManifestCallback, IDMapOwnPointer>; 40 using GetCallbackMap = IDMap<GetManifestCallback, IDMapOwnPointer>;
46 using HasCallbackMap = IDMap<HasManifestCallback, IDMapOwnPointer>;
47 using FrameGetCallbackMap = base::hash_map<RenderFrameHost*, GetCallbackMap*>; 41 using FrameGetCallbackMap = base::hash_map<RenderFrameHost*, GetCallbackMap*>;
48 using FrameHasCallbackMap = base::hash_map<RenderFrameHost*, HasCallbackMap*>;
49 42
50 void OnRequestManifestResponse( 43 void OnRequestManifestResponse(
51 RenderFrameHost*, int request_id, const GURL&, const Manifest&); 44 RenderFrameHost*, int request_id, const GURL&, const Manifest&);
52 void OnHasManifestResponse(
53 RenderFrameHost*, int request_id, bool);
54 45
55 // Returns the CallbackMap associated with the given RenderFrameHost, or null. 46 // Returns the CallbackMap associated with the given RenderFrameHost, or null.
56 GetCallbackMap* GetCallbackMapForFrame(RenderFrameHost*); 47 GetCallbackMap* GetCallbackMapForFrame(RenderFrameHost*);
57 HasCallbackMap* HasCallbackMapForFrame(RenderFrameHost*);
58 48
59 FrameGetCallbackMap pending_get_callbacks_; 49 FrameGetCallbackMap pending_get_callbacks_;
60 FrameHasCallbackMap pending_has_callbacks_;
61 50
62 DISALLOW_COPY_AND_ASSIGN(ManifestManagerHost); 51 DISALLOW_COPY_AND_ASSIGN(ManifestManagerHost);
63 }; 52 };
64 53
65 } // namespace content 54 } // namespace content
66 55
67 #endif // CONTENT_BROWSER_MANIFEST_MANIFEST_MANAGER_HOST_H_ 56 #endif // CONTENT_BROWSER_MANIFEST_MANIFEST_MANAGER_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/manifest/manifest_browsertest.cc ('k') | content/browser/manifest/manifest_manager_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698