OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/view_type_utils.h" | 5 #include "chrome/browser/view_type_utils.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
9 | 9 |
10 using content::WebContents; | 10 using content::WebContents; |
11 | 11 |
12 namespace chrome { | 12 namespace chrome { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 const char kViewTypeUserDataKey[] = "ViewTypeUserData"; | 16 const char kViewTypeUserDataKey[] = "ViewTypeUserData"; |
17 | 17 |
18 class ViewTypeUserData : public base::SupportsUserData::Data { | 18 class ViewTypeUserData : public base::SupportsUserData::Data { |
19 public: | 19 public: |
20 explicit ViewTypeUserData(ViewType type) : type_(type) {} | 20 explicit ViewTypeUserData(extensions::ViewType type) : type_(type) {} |
21 virtual ~ViewTypeUserData() {} | 21 virtual ~ViewTypeUserData() {} |
22 ViewType type() { return type_; } | 22 extensions::ViewType type() { return type_; } |
23 | 23 |
24 private: | 24 private: |
25 ViewType type_; | 25 extensions::ViewType type_; |
26 }; | 26 }; |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 ViewType GetViewType(WebContents* tab) { | 30 extensions::ViewType GetViewType(WebContents* tab) { |
31 if (!tab) | 31 if (!tab) |
32 return VIEW_TYPE_INVALID; | 32 return extensions::VIEW_TYPE_INVALID; |
33 | 33 |
34 ViewTypeUserData* user_data = static_cast<ViewTypeUserData*>( | 34 ViewTypeUserData* user_data = static_cast<ViewTypeUserData*>( |
35 tab->GetUserData(&kViewTypeUserDataKey)); | 35 tab->GetUserData(&kViewTypeUserDataKey)); |
36 | 36 |
37 return user_data ? user_data->type() : VIEW_TYPE_INVALID; | 37 return user_data ? user_data->type() : extensions::VIEW_TYPE_INVALID; |
38 } | 38 } |
39 | 39 |
40 void SetViewType(WebContents* tab, ViewType type) { | 40 void SetViewType(WebContents* tab, extensions::ViewType type) { |
41 tab->SetUserData(&kViewTypeUserDataKey, | 41 tab->SetUserData(&kViewTypeUserDataKey, |
42 new ViewTypeUserData(type)); | 42 new ViewTypeUserData(type)); |
43 } | 43 } |
44 | 44 |
45 } // namespace chrome | 45 } // namespace chrome |
OLD | NEW |