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

Side by Side Diff: chrome/browser/guest_view/guest_view_manager.h

Issue 444813002: Remove BrowserPlugin's -internal-attach method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_
6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 // Returns the guest WebContents associated with the given |guest_instance_id| 43 // Returns the guest WebContents associated with the given |guest_instance_id|
44 // if the provided |embedder_render_process_id| is allowed to access it. 44 // if the provided |embedder_render_process_id| is allowed to access it.
45 // If the embedder is not allowed access, the embedder will be killed, and 45 // If the embedder is not allowed access, the embedder will be killed, and
46 // this method will return NULL. If no WebContents exists with the given 46 // this method will return NULL. If no WebContents exists with the given
47 // instance ID, then NULL will also be returned. 47 // instance ID, then NULL will also be returned.
48 content::WebContents* GetGuestByInstanceIDSafely( 48 content::WebContents* GetGuestByInstanceIDSafely(
49 int guest_instance_id, 49 int guest_instance_id,
50 int embedder_render_process_id); 50 int embedder_render_process_id);
51 51
52 // Associates the Browser Plugin with |element_instance_id| to a
53 // guest that has ID of |guest_instance_id| and sets initialization
54 // parameters, |params| for it.
55 void SetAttachParamsForGuest(int embedder_render_process_id,
56 int embedder_routing_id,
57 int element_instance_id,
58 int guest_instance_id,
59 const base::DictionaryValue& params);
60
52 int GetNextInstanceID(); 61 int GetNextInstanceID();
53 62
54 typedef base::Callback<void(content::WebContents*)> 63 typedef base::Callback<void(content::WebContents*)>
55 WebContentsCreatedCallback; 64 WebContentsCreatedCallback;
56 void CreateGuest( 65 void CreateGuest(
57 const std::string& view_type, 66 const std::string& view_type,
58 const std::string& embedder_extension_id, 67 const std::string& embedder_extension_id,
59 int embedder_render_process_id, 68 int embedder_render_process_id,
60 const base::DictionaryValue& create_params, 69 const base::DictionaryValue& create_params,
61 const WebContentsCreatedCallback& callback); 70 const WebContentsCreatedCallback& callback);
62 71
63 content::WebContents* CreateGuestWithWebContentsParams( 72 content::WebContents* CreateGuestWithWebContentsParams(
64 const std::string& view_type, 73 const std::string& view_type,
65 const std::string& embedder_extension_id, 74 const std::string& embedder_extension_id,
66 int embedder_render_process_id, 75 int embedder_render_process_id,
67 const content::WebContents::CreateParams& create_params); 76 const content::WebContents::CreateParams& create_params);
68 77
69 content::SiteInstance* GetGuestSiteInstance( 78 content::SiteInstance* GetGuestSiteInstance(
70 const GURL& guest_site); 79 const GURL& guest_site);
71 80
72 // BrowserPluginGuestManager implementation. 81 // BrowserPluginGuestManager implementation.
73 virtual void MaybeGetGuestByInstanceIDOrKill( 82 virtual void MaybeGetGuestByInstanceIDOrKill(
74 int guest_instance_id, 83 int guest_instance_id,
75 int embedder_render_process_id, 84 int embedder_render_process_id,
76 const GuestByInstanceIDCallback& callback) OVERRIDE; 85 const GuestByInstanceIDCallback& callback) OVERRIDE;
77 virtual bool ForEachGuest(content::WebContents* embedder_web_contents, 86 virtual bool ForEachGuest(content::WebContents* embedder_web_contents,
78 const GuestCallback& callback) OVERRIDE; 87 const GuestCallback& callback) OVERRIDE;
88 virtual int GetGuestInstanceIDForPluginID(
89 content::WebContents* embedder_web_contents,
90 int element_instance_id) OVERRIDE;
79 91
80 protected: 92 protected:
81 friend class AppViewGuest; 93 friend class AppViewGuest;
82 friend class GuestViewBase; 94 friend class GuestViewBase;
83 friend class guestview::TestGuestViewManager; 95 friend class guestview::TestGuestViewManager;
84 FRIEND_TEST_ALL_PREFIXES(GuestViewManagerTest, AddRemove); 96 FRIEND_TEST_ALL_PREFIXES(GuestViewManagerTest, AddRemove);
85 97
86 // Can be overriden in tests. 98 // Can be overriden in tests.
87 virtual void AddGuest(int guest_instance_id, 99 virtual void AddGuest(int guest_instance_id,
88 content::WebContents* guest_web_contents); 100 content::WebContents* guest_web_contents);
(...skipping 15 matching lines...) Expand all
104 // from this manager using RemoveGuest. 116 // from this manager using RemoveGuest.
105 bool CanUseGuestInstanceID(int guest_instance_id); 117 bool CanUseGuestInstanceID(int guest_instance_id);
106 118
107 // Static factory instance (always NULL for non-test). 119 // Static factory instance (always NULL for non-test).
108 static GuestViewManagerFactory* factory_; 120 static GuestViewManagerFactory* factory_;
109 121
110 // Contains guests' WebContents, mapping from their instance ids. 122 // Contains guests' WebContents, mapping from their instance ids.
111 typedef std::map<int, content::WebContents*> GuestInstanceMap; 123 typedef std::map<int, content::WebContents*> GuestInstanceMap;
112 GuestInstanceMap guest_web_contents_by_instance_id_; 124 GuestInstanceMap guest_web_contents_by_instance_id_;
113 125
126 struct ElementInstanceKey {
127 content::WebContents* embedder_web_contents;
128 int element_instance_id;
129 ElementInstanceKey(content::WebContents* embedder_web_contents,
130 int element_instance_id)
131 : embedder_web_contents(embedder_web_contents),
132 element_instance_id(element_instance_id) {}
133 bool operator<(const ElementInstanceKey& other) const {
134 if (embedder_web_contents != other.embedder_web_contents)
135 return embedder_web_contents < other.embedder_web_contents;
136 return element_instance_id < other.element_instance_id;
137 }
138 };
139
140 typedef std::map<ElementInstanceKey, int> GuestInstanceIDMap;
141 GuestInstanceIDMap instance_id_map_;
142 // The reverse map of GuestInstanceIDMap.
143 typedef std::map<int, ElementInstanceKey> GuestInstanceIDReverseMap;
144 GuestInstanceIDReverseMap reverse_instance_id_map_;
145
114 int current_instance_id_; 146 int current_instance_id_;
115 147
116 // Any instance ID whose number not greater than this was removed via 148 // Any instance ID whose number not greater than this was removed via
117 // RemoveGuest. 149 // RemoveGuest.
118 // This is used so that we don't have store all removed instance IDs in 150 // This is used so that we don't have store all removed instance IDs in
119 // |removed_instance_ids_|. 151 // |removed_instance_ids_|.
120 int last_instance_id_removed_; 152 int last_instance_id_removed_;
121 // The remaining instance IDs that are greater than 153 // The remaining instance IDs that are greater than
122 // |last_instance_id_removed_| are kept here. 154 // |last_instance_id_removed_| are kept here.
123 std::set<int> removed_instance_ids_; 155 std::set<int> removed_instance_ids_;
124 156
125 content::BrowserContext* context_; 157 content::BrowserContext* context_;
126 158
127 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); 159 DISALLOW_COPY_AND_ASSIGN(GuestViewManager);
128 }; 160 };
129 161
130 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ 162 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/guest_view_base.cc ('k') | chrome/browser/guest_view/guest_view_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698