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(URLPattern::SCHEME_ALL); | 142 URLPattern pattern(URLPattern::IGNORE_PORTS, 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)) { | |
147 error_ = ExtensionErrorUtils::FormatErrorMessage(kInvalidURLPatternError, | 146 error_ = ExtensionErrorUtils::FormatErrorMessage(kInvalidURLPatternError, |
148 tmp); | 147 tmp); |
149 return false; | 148 return false; |
150 } | 149 } |
151 result->AddPattern(pattern); | 150 result->AddPattern(pattern); |
152 } | 151 } |
153 return true; | 152 return true; |
154 } | 153 } |
155 | 154 |
156 bool ExtensionContextMenuFunction::SetURLPatterns( | 155 bool ExtensionContextMenuFunction::SetURLPatterns( |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 351 |
353 return manager->RemoveContextMenuItem(id); | 352 return manager->RemoveContextMenuItem(id); |
354 } | 353 } |
355 | 354 |
356 bool RemoveAllContextMenusFunction::RunImpl() { | 355 bool RemoveAllContextMenusFunction::RunImpl() { |
357 ExtensionService* service = profile()->GetExtensionService(); | 356 ExtensionService* service = profile()->GetExtensionService(); |
358 ExtensionMenuManager* manager = service->menu_manager(); | 357 ExtensionMenuManager* manager = service->menu_manager(); |
359 manager->RemoveAllContextItems(extension_id()); | 358 manager->RemoveAllContextItems(extension_id()); |
360 return true; | 359 return true; |
361 } | 360 } |
OLD | NEW |