| 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 #include "chrome/browser/extensions/page_action_controller.h" | 5 #include "chrome/browser/extensions/page_action_controller.h" | 
| 6 | 6 | 
| 7 #include "chrome/browser/extensions/extension_browser_event_router.h" | 7 #include "chrome/browser/extensions/extension_browser_event_router.h" | 
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" | 
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" | 
| 10 #include "chrome/browser/extensions/extension_tab_util.h" | 10 #include "chrome/browser/extensions/extension_tab_util.h" | 
| 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 
| 12 #include "chrome/common/extensions/extension_set.h" | 12 #include "chrome/common/extensions/extension_set.h" | 
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" | 
| 14 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" | 
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" | 
| 16 | 16 | 
| 17 namespace extensions { | 17 namespace extensions { | 
| 18 | 18 | 
| 19 PageActionController::PageActionController(TabContents* tab_contents) | 19 PageActionController::PageActionController(TabContents* tab_contents) | 
| 20     : tab_contents_(tab_contents) {} | 20     : tab_contents_(tab_contents) {} | 
| 21 | 21 | 
| 22 PageActionController::~PageActionController() {} | 22 PageActionController::~PageActionController() {} | 
| 23 | 23 | 
| 24 scoped_ptr<std::vector<ExtensionAction*> > | 24 std::vector<ExtensionAction*> PageActionController::GetCurrentActions() { | 
| 25 PageActionController::GetCurrentActions() { |  | 
| 26   scoped_ptr<std::vector<ExtensionAction*> > current_actions( |  | 
| 27       new std::vector<ExtensionAction*>()); |  | 
| 28 |  | 
| 29   ExtensionService* service = GetExtensionService(); | 25   ExtensionService* service = GetExtensionService(); | 
| 30   if (!service) | 26   if (!service) | 
| 31     return current_actions.Pass(); | 27     return std::vector<ExtensionAction*>(); | 
|  | 28 | 
|  | 29   std::vector<ExtensionAction*> current_actions; | 
| 32 | 30 | 
| 33   for (ExtensionSet::const_iterator i = service->extensions()->begin(); | 31   for (ExtensionSet::const_iterator i = service->extensions()->begin(); | 
| 34        i != service->extensions()->end(); ++i) { | 32        i != service->extensions()->end(); ++i) { | 
| 35     ExtensionAction* action = (*i)->page_action(); | 33     ExtensionAction* action = (*i)->page_action(); | 
| 36     if (action) | 34     if (action) | 
| 37       current_actions->push_back(action); | 35       current_actions.push_back(action); | 
| 38   } | 36   } | 
| 39   return current_actions.Pass(); | 37   return current_actions; | 
| 40 } | 38 } | 
| 41 | 39 | 
| 42 LocationBarController::Action PageActionController::OnClicked( | 40 LocationBarController::Action PageActionController::OnClicked( | 
| 43     const std::string& extension_id, int mouse_button) { | 41     const std::string& extension_id, int mouse_button) { | 
| 44   ExtensionService* service = GetExtensionService(); | 42   ExtensionService* service = GetExtensionService(); | 
| 45   if (!service) | 43   if (!service) | 
| 46     return ACTION_NONE; | 44     return ACTION_NONE; | 
| 47 | 45 | 
| 48   const Extension* extension = service->extensions()->GetByID(extension_id); | 46   const Extension* extension = service->extensions()->GetByID(extension_id); | 
| 49   CHECK(extension); | 47   CHECK(extension); | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 72   } | 70   } | 
| 73 | 71 | 
| 74   return ACTION_NONE; | 72   return ACTION_NONE; | 
| 75 } | 73 } | 
| 76 | 74 | 
| 77 ExtensionService* PageActionController::GetExtensionService() { | 75 ExtensionService* PageActionController::GetExtensionService() { | 
| 78   return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); | 76   return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); | 
| 79 } | 77 } | 
| 80 | 78 | 
| 81 }  // namespace extensions | 79 }  // namespace extensions | 
| OLD | NEW | 
|---|