OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/extensions_service.h" | 8 #include "chrome/browser/extensions/extensions_service.h" |
9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 if (!parent) { | 181 if (!parent) { |
182 error_ = "Cannot find menu item with id " + IntToString(parent_id); | 182 error_ = "Cannot find menu item with id " + IntToString(parent_id); |
183 return false; | 183 return false; |
184 } | 184 } |
185 if (parent->type() != ExtensionMenuItem::NORMAL) { | 185 if (parent->type() != ExtensionMenuItem::NORMAL) { |
186 error_ = kParentsMustBeNormalError; | 186 error_ = kParentsMustBeNormalError; |
187 return false; | 187 return false; |
188 } | 188 } |
189 id = menu_manager->AddChildItem(parent_id, item.release()); | 189 id = menu_manager->AddChildItem(parent_id, item.release()); |
190 } else { | 190 } else { |
191 id = menu_manager->AddContextItem(item.release()); | 191 id = menu_manager->AddContextItem(GetExtension(), item.release()); |
192 } | 192 } |
193 | 193 |
194 if (id <= 0) | 194 if (id <= 0) |
195 return false; | 195 return false; |
196 | 196 |
197 if (has_callback()) | 197 if (has_callback()) |
198 result_.reset(Value::CreateIntegerValue(id)); | 198 result_.reset(Value::CreateIntegerValue(id)); |
199 | 199 |
200 return true; | 200 return true; |
201 } | 201 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 285 |
286 return manager->RemoveContextMenuItem(id); | 286 return manager->RemoveContextMenuItem(id); |
287 } | 287 } |
288 | 288 |
289 bool RemoveAllContextMenusFunction::RunImpl() { | 289 bool RemoveAllContextMenusFunction::RunImpl() { |
290 ExtensionsService* service = profile()->GetExtensionsService(); | 290 ExtensionsService* service = profile()->GetExtensionsService(); |
291 ExtensionMenuManager* manager = service->menu_manager(); | 291 ExtensionMenuManager* manager = service->menu_manager(); |
292 manager->RemoveAllContextItems(extension_id()); | 292 manager->RemoveAllContextItems(extension_id()); |
293 return true; | 293 return true; |
294 } | 294 } |
OLD | NEW |