OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/view_type_utils.h" |
| 6 |
| 7 #include "base/lazy_instance.h" |
| 8 #include "base/property_bag.h" |
| 9 #include "content/public/browser/web_contents.h" |
| 10 |
| 11 using content::WebContents; |
| 12 |
| 13 namespace chrome { |
| 14 |
| 15 static base::LazyInstance<base::PropertyAccessor<ViewType> > |
| 16 g_view_type_property_accessor = LAZY_INSTANCE_INITIALIZER; |
| 17 |
| 18 base::PropertyAccessor<ViewType>* GetPropertyAccessor() { |
| 19 return g_view_type_property_accessor.Pointer(); |
| 20 } |
| 21 |
| 22 ViewType GetViewType(WebContents* tab) { |
| 23 if (!tab) |
| 24 return VIEW_TYPE_INVALID; |
| 25 ViewType* type = GetPropertyAccessor()->GetProperty(tab->GetPropertyBag()); |
| 26 if (type) |
| 27 return *type; |
| 28 return VIEW_TYPE_INVALID; |
| 29 } |
| 30 |
| 31 void SetViewType(WebContents* tab, ViewType type) { |
| 32 GetPropertyAccessor()->SetProperty(tab->GetPropertyBag(), type); |
| 33 } |
| 34 |
| 35 } // namespace chrome |
OLD | NEW |