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

Side by Side Diff: chrome/common/extensions/manifest_handlers/ui_overrides_handler.cc

Issue 320323003: Enforce "override bookmarks UI" manifest permissions for bookmark shortcut overrides (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stars-remove-settings-overrides-key
Patch Set: check bookmarks_ui property 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/manifest_handlers/ui_overrides_handler.h" 5 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.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"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return false; 174 return false;
175 175
176 scoped_ptr<UIOverrides> info(new UIOverrides); 176 scoped_ptr<UIOverrides> info(new UIOverrides);
177 info->bookmarks_ui.swap(overrides->bookmarks_ui); 177 info->bookmarks_ui.swap(overrides->bookmarks_ui);
178 if (!info->bookmarks_ui) { 178 if (!info->bookmarks_ui) {
179 *error = ErrorUtils::FormatErrorMessageUTF16( 179 *error = ErrorUtils::FormatErrorMessageUTF16(
180 manifest_errors::kInvalidEmptyDictionary, 180 manifest_errors::kInvalidEmptyDictionary,
181 manifest_keys::kUIOverride); 181 manifest_keys::kUIOverride);
182 return false; 182 return false;
183 } 183 }
184 UIOverrides* assigned_ui_overrides = info.get(); 184 info->manifest_permission.reset(new ManifestPermissionImpl(
185 info->bookmarks_ui.get() != NULL));
185 extension->SetManifestData(manifest_keys::kUIOverride, info.release()); 186 extension->SetManifestData(manifest_keys::kUIOverride, info.release());
186 assigned_ui_overrides->manifest_permission.reset(new ManifestPermissionImpl(
187 UIOverrides::RemovesBookmarkButton(extension)));
188 return true; 187 return true;
189 } 188 }
190 189
191 bool UIOverridesHandler::Validate(const Extension* extension, 190 bool UIOverridesHandler::Validate(const Extension* extension,
192 std::string* error, 191 std::string* error,
193 std::vector<InstallWarning>* warnings) const { 192 std::vector<InstallWarning>* warnings) const {
194 const UIOverrides* ui_overrides = UIOverrides::Get(extension); 193 const UIOverrides* ui_overrides = UIOverrides::Get(extension);
195 194
196 if (ui_overrides && ui_overrides->bookmarks_ui) { 195 if (ui_overrides && ui_overrides->bookmarks_ui) {
197 if (!FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled()) { 196 if (!FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled()) {
(...skipping 17 matching lines...) Expand all
215 const UIOverrides* data = UIOverrides::Get(extension); 214 const UIOverrides* data = UIOverrides::Get(extension);
216 if (data) 215 if (data)
217 return data->manifest_permission->Clone(); 216 return data->manifest_permission->Clone();
218 return NULL; 217 return NULL;
219 } 218 }
220 const std::vector<std::string> UIOverridesHandler::Keys() const { 219 const std::vector<std::string> UIOverridesHandler::Keys() const {
221 return SingleKey(manifest_keys::kUIOverride); 220 return SingleKey(manifest_keys::kUIOverride);
222 } 221 }
223 222
224 } // namespace extensions 223 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698