OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_context_menu_api.h" | 5 #include "chrome/browser/extensions/extension_context_menu_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 if (!properties.HasKey(key)) | 132 if (!properties.HasKey(key)) |
133 return true; | 133 return true; |
134 ListValue* list = NULL; | 134 ListValue* list = NULL; |
135 if (!properties.GetList(key, &list)) | 135 if (!properties.GetList(key, &list)) |
136 return false; | 136 return false; |
137 for (ListValue::iterator i = list->begin(); i != list->end(); ++i) { | 137 for (ListValue::iterator i = list->begin(); i != list->end(); ++i) { |
138 std::string tmp; | 138 std::string tmp; |
139 if (!(*i)->GetAsString(&tmp)) | 139 if (!(*i)->GetAsString(&tmp)) |
140 return false; | 140 return false; |
141 | 141 |
142 URLPattern pattern(ExtensionMenuManager::kAllowedSchemes); | 142 URLPattern pattern(URLPattern::SCHEME_ALL); |
143 // TODO(skerner): Consider enabling strict pattern parsing | 143 // TODO(skerner): Consider enabling strict pattern parsing |
144 // if this extension's location indicates that it is under development. | 144 // if this extension's location indicates that it is under development. |
145 if (URLPattern::PARSE_SUCCESS != pattern.Parse(tmp, | 145 if (URLPattern::PARSE_SUCCESS != pattern.Parse(tmp, |
146 URLPattern::IGNORE_PORTS)) { | 146 URLPattern::IGNORE_PORTS)) { |
147 error_ = ExtensionErrorUtils::FormatErrorMessage(kInvalidURLPatternError, | 147 error_ = ExtensionErrorUtils::FormatErrorMessage(kInvalidURLPatternError, |
148 tmp); | 148 tmp); |
149 return false; | 149 return false; |
150 } | 150 } |
151 result->AddPattern(pattern); | 151 result->AddPattern(pattern); |
152 } | 152 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 352 |
353 return manager->RemoveContextMenuItem(id); | 353 return manager->RemoveContextMenuItem(id); |
354 } | 354 } |
355 | 355 |
356 bool RemoveAllContextMenusFunction::RunImpl() { | 356 bool RemoveAllContextMenusFunction::RunImpl() { |
357 ExtensionService* service = profile()->GetExtensionService(); | 357 ExtensionService* service = profile()->GetExtensionService(); |
358 ExtensionMenuManager* manager = service->menu_manager(); | 358 ExtensionMenuManager* manager = service->menu_manager(); |
359 manager->RemoveAllContextItems(extension_id()); | 359 manager->RemoveAllContextItems(extension_id()); |
360 return true; | 360 return true; |
361 } | 361 } |
OLD | NEW |