Revert of Output closure-compiled JavaScript files (patchset #10 id:180001 of https...
[chromium-blink-merge.git] / extensions / browser / view_type_utils.cc
blobba72ceb7de7f3aa8ae0697415020286176220fac
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.
5 #include "extensions/browser/view_type_utils.h"
7 #include "base/lazy_instance.h"
8 #include "content/public/browser/web_contents.h"
10 using content::WebContents;
12 namespace extensions {
14 namespace {
16 const char kViewTypeUserDataKey[] = "ViewTypeUserData";
18 class ViewTypeUserData : public base::SupportsUserData::Data {
19 public:
20 explicit ViewTypeUserData(ViewType type) : type_(type) {}
21 ~ViewTypeUserData() override {}
22 ViewType type() { return type_; }
24 private:
25 ViewType type_;
28 } // namespace
30 ViewType GetViewType(WebContents* tab) {
31 if (!tab)
32 return VIEW_TYPE_INVALID;
34 ViewTypeUserData* user_data = static_cast<ViewTypeUserData*>(
35 tab->GetUserData(&kViewTypeUserDataKey));
37 return user_data ? user_data->type() : VIEW_TYPE_INVALID;
40 void SetViewType(WebContents* tab, ViewType type) {
41 tab->SetUserData(&kViewTypeUserDataKey, new ViewTypeUserData(type));
44 } // namespace extensions