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

Side by Side Diff: chrome/common/extensions/api/supervised_user_private/supervised_user_handler.cc

Issue 345563008: Rename "managed (mode|user)" to "supervised user" (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 6 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/common/extensions/api/managed_mode_private/managed_mode_handler .h" 5 #include "chrome/common/extensions/api/supervised_user_private/supervised_user_h andler.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "extensions/common/error_utils.h" 11 #include "extensions/common/error_utils.h"
12 #include "extensions/common/manifest_constants.h" 12 #include "extensions/common/manifest_constants.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 namespace keys = manifest_keys; 16 namespace keys = manifest_keys;
17 17
18 ManagedModeInfo::ManagedModeInfo() { 18 SupervisedUserInfo::SupervisedUserInfo() {
19 } 19 }
20 20
21 ManagedModeInfo::~ManagedModeInfo() { 21 SupervisedUserInfo::~SupervisedUserInfo() {
22 } 22 }
23 23
24 // static 24 // static
25 bool ManagedModeInfo::IsContentPack(const Extension* extension) { 25 bool SupervisedUserInfo::IsContentPack(const Extension* extension) {
26 ManagedModeInfo* info = static_cast<ManagedModeInfo*>( 26 SupervisedUserInfo* info = static_cast<SupervisedUserInfo*>(
27 extension->GetManifestData(keys::kContentPack)); 27 extension->GetManifestData(keys::kContentPack));
28 return info ? !info->site_list.empty() : false; 28 return info ? !info->site_list.empty() : false;
29 } 29 }
30 30
31 // static 31 // static
32 ExtensionResource ManagedModeInfo::GetContentPackSiteList( 32 ExtensionResource SupervisedUserInfo::GetContentPackSiteList(
33 const Extension* extension) { 33 const Extension* extension) {
34 ManagedModeInfo* info = static_cast<ManagedModeInfo*>( 34 SupervisedUserInfo* info = static_cast<SupervisedUserInfo*>(
35 extension->GetManifestData(keys::kContentPack)); 35 extension->GetManifestData(keys::kContentPack));
36 return info && !info->site_list.empty() ? 36 return info && !info->site_list.empty()
37 extension->GetResource(info->site_list) : 37 ? extension->GetResource(info->site_list)
38 ExtensionResource(); 38 : ExtensionResource();
39 } 39 }
40 40
41 ManagedModeHandler::ManagedModeHandler() { 41 SupervisedUserHandler::SupervisedUserHandler() {
42 } 42 }
43 43
44 ManagedModeHandler::~ManagedModeHandler() { 44 SupervisedUserHandler::~SupervisedUserHandler() {
45 } 45 }
46 46
47 bool ManagedModeHandler::Parse(Extension* extension, base::string16* error) { 47 bool SupervisedUserHandler::Parse(Extension* extension, base::string16* error) {
48 if (!extension->manifest()->HasKey(keys::kContentPack)) 48 if (!extension->manifest()->HasKey(keys::kContentPack))
49 return true; 49 return true;
50 50
51 scoped_ptr<ManagedModeInfo> info(new ManagedModeInfo); 51 scoped_ptr<SupervisedUserInfo> info(new SupervisedUserInfo);
52 const base::DictionaryValue* content_pack_value = NULL; 52 const base::DictionaryValue* content_pack_value = NULL;
53 if (!extension->manifest()->GetDictionary(keys::kContentPack, 53 if (!extension->manifest()->GetDictionary(keys::kContentPack,
54 &content_pack_value)) { 54 &content_pack_value)) {
55 *error = base::ASCIIToUTF16(manifest_errors::kInvalidContentPack); 55 *error = base::ASCIIToUTF16(manifest_errors::kInvalidContentPack);
56 return false; 56 return false;
57 } 57 }
58 58
59 if (!LoadSites(info.get(), content_pack_value, error) || 59 if (!LoadSites(info.get(), content_pack_value, error) ||
60 !LoadConfigurations(info.get(), content_pack_value, error)) { 60 !LoadConfigurations(info.get(), content_pack_value, error)) {
61 return false; 61 return false;
62 } 62 }
63 63
64 extension->SetManifestData(keys::kContentPack, info.release()); 64 extension->SetManifestData(keys::kContentPack, info.release());
65 return true; 65 return true;
66 } 66 }
67 67
68 const std::vector<std::string> ManagedModeHandler::Keys() const { 68 const std::vector<std::string> SupervisedUserHandler::Keys() const {
69 return SingleKey(keys::kContentPack); 69 return SingleKey(keys::kContentPack);
70 } 70 }
71 71
72 bool ManagedModeHandler::LoadSites( 72 bool SupervisedUserHandler::LoadSites(
73 ManagedModeInfo* info, 73 SupervisedUserInfo* info,
74 const base::DictionaryValue* content_pack_value, 74 const base::DictionaryValue* content_pack_value,
75 base::string16* error) { 75 base::string16* error) {
76 if (!content_pack_value->HasKey(keys::kContentPackSites)) 76 if (!content_pack_value->HasKey(keys::kContentPackSites))
77 return true; 77 return true;
78 78
79 base::FilePath::StringType site_list_string; 79 base::FilePath::StringType site_list_string;
80 if (!content_pack_value->GetString(keys::kContentPackSites, 80 if (!content_pack_value->GetString(keys::kContentPackSites,
81 &site_list_string)) { 81 &site_list_string)) {
82 *error = base::ASCIIToUTF16(manifest_errors::kInvalidContentPackSites); 82 *error = base::ASCIIToUTF16(manifest_errors::kInvalidContentPackSites);
83 return false; 83 return false;
84 } 84 }
85 85
86 info->site_list = base::FilePath(site_list_string); 86 info->site_list = base::FilePath(site_list_string);
87 87
88 return true; 88 return true;
89 } 89 }
90 90
91 bool ManagedModeHandler::LoadConfigurations( 91 bool SupervisedUserHandler::LoadConfigurations(
92 ManagedModeInfo* info, 92 SupervisedUserInfo* info,
93 const base::DictionaryValue* content_pack_value, 93 const base::DictionaryValue* content_pack_value,
94 base::string16* error) { 94 base::string16* error) {
95 NOTIMPLEMENTED(); 95 NOTIMPLEMENTED();
96 return true; 96 return true;
97 } 97 }
98 98
99 } // namespace extensions 99 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698