OLD | NEW |
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 #ifndef CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // This class keeps track of menu items added by extensions. | 271 // This class keeps track of menu items added by extensions. |
272 class MenuManager : public content::NotificationObserver, | 272 class MenuManager : public content::NotificationObserver, |
273 public base::SupportsWeakPtr<MenuManager>, | 273 public base::SupportsWeakPtr<MenuManager>, |
274 public KeyedService, | 274 public KeyedService, |
275 public ExtensionRegistryObserver { | 275 public ExtensionRegistryObserver { |
276 public: | 276 public: |
277 static const char kOnContextMenus[]; | 277 static const char kOnContextMenus[]; |
278 static const char kOnWebviewContextMenus[]; | 278 static const char kOnWebviewContextMenus[]; |
279 | 279 |
280 MenuManager(content::BrowserContext* context, StateStore* store_); | 280 MenuManager(content::BrowserContext* context, StateStore* store_); |
281 virtual ~MenuManager(); | 281 ~MenuManager() override; |
282 | 282 |
283 // Convenience function to get the MenuManager for a browser context. | 283 // Convenience function to get the MenuManager for a browser context. |
284 static MenuManager* Get(content::BrowserContext* context); | 284 static MenuManager* Get(content::BrowserContext* context); |
285 | 285 |
286 // Returns the keys of extensions which have menu items registered. | 286 // Returns the keys of extensions which have menu items registered. |
287 std::set<MenuItem::ExtensionKey> ExtensionIds(); | 287 std::set<MenuItem::ExtensionKey> ExtensionIds(); |
288 | 288 |
289 // Returns a list of all the *top-level* menu items (added via AddContextItem) | 289 // Returns a list of all the *top-level* menu items (added via AddContextItem) |
290 // for the given extension specified by |extension_key|, *not* including child | 290 // for the given extension specified by |extension_key|, *not* including child |
291 // items (added via AddChildItem); although those can be reached via the | 291 // items (added via AddChildItem); although those can be reached via the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 content::WebContents* web_contents, | 333 content::WebContents* web_contents, |
334 const content::ContextMenuParams& params, | 334 const content::ContextMenuParams& params, |
335 const MenuItem::Id& menu_item_id); | 335 const MenuItem::Id& menu_item_id); |
336 | 336 |
337 // This returns a bitmap of width/height kFaviconSize, loaded either from an | 337 // This returns a bitmap of width/height kFaviconSize, loaded either from an |
338 // entry specified in the extension's 'icon' section of the manifest, or a | 338 // entry specified in the extension's 'icon' section of the manifest, or a |
339 // default extension icon. | 339 // default extension icon. |
340 const SkBitmap& GetIconForExtension(const std::string& extension_id); | 340 const SkBitmap& GetIconForExtension(const std::string& extension_id); |
341 | 341 |
342 // content::NotificationObserver implementation. | 342 // content::NotificationObserver implementation. |
343 virtual void Observe(int type, const content::NotificationSource& source, | 343 void Observe(int type, |
344 const content::NotificationDetails& details) override; | 344 const content::NotificationSource& source, |
| 345 const content::NotificationDetails& details) override; |
345 | 346 |
346 // ExtensionRegistryObserver implementation. | 347 // ExtensionRegistryObserver implementation. |
347 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 348 void OnExtensionLoaded(content::BrowserContext* browser_context, |
348 const Extension* extension) override; | 349 const Extension* extension) override; |
349 virtual void OnExtensionUnloaded( | 350 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
350 content::BrowserContext* browser_context, | 351 const Extension* extension, |
351 const Extension* extension, | 352 UnloadedExtensionInfo::Reason reason) override; |
352 UnloadedExtensionInfo::Reason reason) override; | |
353 | 353 |
354 // Stores the menu items for the extension in the state storage. | 354 // Stores the menu items for the extension in the state storage. |
355 void WriteToStorage(const Extension* extension, | 355 void WriteToStorage(const Extension* extension, |
356 const MenuItem::ExtensionKey& extension_key); | 356 const MenuItem::ExtensionKey& extension_key); |
357 | 357 |
358 // Reads menu items for the extension from the state storage. Any invalid | 358 // Reads menu items for the extension from the state storage. Any invalid |
359 // items are ignored. | 359 // items are ignored. |
360 void ReadFromStorage(const std::string& extension_id, | 360 void ReadFromStorage(const std::string& extension_id, |
361 scoped_ptr<base::Value> value); | 361 scoped_ptr<base::Value> value); |
362 | 362 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 401 |
402 // Owned by ExtensionSystem. | 402 // Owned by ExtensionSystem. |
403 StateStore* store_; | 403 StateStore* store_; |
404 | 404 |
405 DISALLOW_COPY_AND_ASSIGN(MenuManager); | 405 DISALLOW_COPY_AND_ASSIGN(MenuManager); |
406 }; | 406 }; |
407 | 407 |
408 } // namespace extensions | 408 } // namespace extensions |
409 | 409 |
410 #endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ | 410 #endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ |
OLD | NEW |