Index: chrome/common/chrome_view_type.cc |
=================================================================== |
--- chrome/common/chrome_view_type.cc (revision 138369) |
+++ chrome/common/chrome_view_type.cc (working copy) |
@@ -4,7 +4,34 @@ |
#include "chrome/common/chrome_view_type.h" |
+#include "base/lazy_instance.h" |
+#include "base/property_bag.h" |
+#include "content/public/browser/web_contents.h" |
Avi (use Gerrit)
2012/05/23 03:22:52
Besides the fact that this breaks check_deps, it f
jam
2012/05/23 04:18:38
yeah that's totally not allowed :) I wasn't paying
|
+ |
+using content::WebContents; |
+ |
namespace chrome { |
+ |
+static base::LazyInstance<base::PropertyAccessor<ViewType> > |
+ g_view_type_property_accessor = LAZY_INSTANCE_INITIALIZER; |
+ |
+base::PropertyAccessor<ViewType>* GetPropertyAccessor() { |
+ return g_view_type_property_accessor.Pointer(); |
+} |
+ |
+ViewType GetViewType(WebContents* tab) { |
+ if (!tab) |
+ return VIEW_TYPE_INVALID; |
+ ViewType* type = GetPropertyAccessor()->GetProperty(tab->GetPropertyBag()); |
+ if (type) |
+ return *type; |
+ return VIEW_TYPE_INVALID; |
+} |
+ |
+void SetViewType(WebContents* tab, ViewType type) { |
+ GetPropertyAccessor()->SetProperty(tab->GetPropertyBag(), type); |
+} |
+ |
const char kViewTypeTabContents[] = "TAB"; |
const char kViewTypeBackgroundPage[] = "BACKGROUND"; |
const char kViewTypePopup[] = "POPUP"; |
@@ -14,4 +41,5 @@ |
const char kViewTypeExtensionDialog[] = "EXTENSION_DIALOG"; |
const char kViewTypeAppShell[] = "SHELL"; |
const char kViewTypeAll[] = "ALL"; |
+ |
} // namespace chrome |