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

Unified Diff: extensions/browser/guest_view/guest_view_manager.h

Issue 1096623002: Moved guest_view_registry to GuestViewManager and made it an instance map (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch_to_frombrowsercontextifavailable
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/guest_view/guest_view_manager.h
diff --git a/extensions/browser/guest_view/guest_view_manager.h b/extensions/browser/guest_view/guest_view_manager.h
index f68d3f5c73ec19b4c7849622abfda706e84e5661..034e2357ce8fb40ba20188b8b46bb1122555295f 100644
--- a/extensions/browser/guest_view/guest_view_manager.h
+++ b/extensions/browser/guest_view/guest_view_manager.h
@@ -7,6 +7,7 @@
#include <map>
+#include "base/bind.h"
#include "base/gtest_prod_util.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
@@ -71,6 +72,13 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
int owner_process_id,
int element_instance_id);
+ template <typename T>
+ void RegisterGuestViewType() {
+ auto it = guest_view_registry_.find(T::Type);
+ DCHECK(it == guest_view_registry_.end());
+ guest_view_registry_[T::Type] = base::Bind(&T::Create);
+ }
+
using WebContentsCreatedCallback =
base::Callback<void(content::WebContents*)>;
void CreateGuest(const std::string& view_type,
@@ -104,6 +112,13 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
// Can be overriden in tests.
virtual void RemoveGuest(int guest_instance_id);
+ // Create a guest of the provided |view_type|.
lazyboy 2015/04/20 19:08:57 Creates
Fady Samuel 2015/04/20 20:35:23 Done.
+ GuestViewBase* CreateGuestInternal(content::WebContents* owner_web_contents,
+ const std::string& view_type);
+
+ // Adds GuestView types to the GuestView registry.
+ void RegisterGuestViewTypes();
+
// Indicates whether the provided |guest| can be used in the context it has
// been created.
bool IsGuestAvailableToContext(GuestViewBase* guest,
@@ -150,6 +165,12 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
using GuestInstanceIDReverseMap = std::map<int, ElementInstanceKey>;
GuestInstanceIDReverseMap reverse_instance_id_map_;
+ using GuestCreationCallback =
+ base::Callback<GuestViewBase*(content::WebContents*)>;
+ using GuestViewCreationMap =
+ std::map<std::string, GuestViewManager::GuestCreationCallback>;
+ GuestViewCreationMap guest_view_registry_;
+
int current_instance_id_;
// Any instance ID whose number not greater than this was removed via

Powered by Google App Engine
This is Rietveld 408576698