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

Side by Side Diff: chrome/browser/view_type_utils.cc

Issue 13375017: Move the ViewType enum to extensions\common. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "content/public/browser/web_contents.h"
9
10 using content::WebContents;
11
12 namespace chrome {
13
14 namespace {
15
16 const char kViewTypeUserDataKey[] = "ViewTypeUserData";
17
18 class ViewTypeUserData : public base::SupportsUserData::Data {
19 public:
20 explicit ViewTypeUserData(ViewType type) : type_(type) {}
21 virtual ~ViewTypeUserData() {}
22 ViewType type() { return type_; }
23
24 private:
25 ViewType type_;
26 };
27
28 } // namespace
29
30 ViewType GetViewType(WebContents* tab) {
31 if (!tab)
32 return VIEW_TYPE_INVALID;
33
34 ViewTypeUserData* user_data = static_cast<ViewTypeUserData*>(
35 tab->GetUserData(&kViewTypeUserDataKey));
36
37 return user_data ? user_data->type() : VIEW_TYPE_INVALID;
38 }
39
40 void SetViewType(WebContents* tab, ViewType type) {
41 tab->SetUserData(&kViewTypeUserDataKey,
42 new ViewTypeUserData(type));
43 }
44
45 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698