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

Side by Side Diff: chrome/browser/extensions/api/context_menus/context_menus_api.cc

Issue 186213003: <webview>: Context menu API implementation CL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put ExtensionKey into MenuItem::Id. Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/api/context_menus/context_menus_api.h" 5 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 MenuItem* item = manager->GetItemById(id); 89 MenuItem* item = manager->GetItemById(id);
90 // Ensure one extension can't remove another's menu items. 90 // Ensure one extension can't remove another's menu items.
91 if (!item || item->extension_id() != extension_id()) { 91 if (!item || item->extension_id() != extension_id()) {
92 error_ = ErrorUtils::FormatErrorMessage( 92 error_ = ErrorUtils::FormatErrorMessage(
93 helpers::kCannotFindItemError, helpers::GetIDString(id)); 93 helpers::kCannotFindItemError, helpers::GetIDString(id));
94 return false; 94 return false;
95 } 95 }
96 96
97 if (!manager->RemoveContextMenuItem(id)) 97 if (!manager->RemoveContextMenuItem(id))
98 return false; 98 return false;
99 manager->WriteToStorage(GetExtension()); 99 manager->WriteToStorage(GetExtension(), id.extension_key);
100 return true; 100 return true;
101 } 101 }
102 102
103 bool ContextMenusRemoveAllFunction::RunImpl() { 103 bool ContextMenusRemoveAllFunction::RunImpl() {
104 MenuManager* manager = MenuManager::Get(GetProfile()); 104 MenuManager* manager = MenuManager::Get(GetProfile());
105 manager->RemoveAllContextItems(GetExtension()->id()); 105 manager->RemoveAllContextItems(MenuItem::ExtensionKey(GetExtension()->id()));
106 manager->WriteToStorage(GetExtension()); 106 manager->WriteToStorage(GetExtension(),
107 MenuItem::ExtensionKey(GetExtension()->id()));
107 return true; 108 return true;
108 } 109 }
109 110
110 } // namespace extensions 111 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698