| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_page_actions_module.h" | 5 #include "chrome/browser/extensions/extension_page_actions_module.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" | 10 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // Find our extension. | 63 // Find our extension. |
| 64 Extension* extension = NULL; | 64 Extension* extension = NULL; |
| 65 ExtensionsService* service = profile()->GetExtensionsService(); | 65 ExtensionsService* service = profile()->GetExtensionsService(); |
| 66 extension = service->GetExtensionById(extension_id()); | 66 extension = service->GetExtensionById(extension_id()); |
| 67 if (!extension) { | 67 if (!extension) { |
| 68 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError, | 68 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError, |
| 69 extension_id()); | 69 extension_id()); |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 const PageAction* page_action = extension->GetPageAction(page_action_id); | 73 const ContextualAction* page_action = |
| 74 extension->GetContextualAction(page_action_id, |
| 75 ContextualAction::PAGE_ACTION); |
| 74 if (!page_action) { | 76 if (!page_action) { |
| 75 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoPageActionError, | 77 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoPageActionError, |
| 76 page_action_id); | 78 page_action_id); |
| 77 return false; | 79 return false; |
| 78 } | 80 } |
| 79 | 81 |
| 80 // Set visibility and broadcast notifications that the UI should be updated. | 82 // Set visibility and broadcast notifications that the UI should be updated. |
| 81 contents->SetPageActionEnabled(page_action, enable, title, icon_id); | 83 contents->SetPageActionEnabled(page_action, enable, title, icon_id); |
| 82 contents->NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); | 84 contents->NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); |
| 83 | 85 |
| 84 return true; | 86 return true; |
| 85 } | 87 } |
| 86 | 88 |
| 87 bool EnablePageActionFunction::RunImpl() { | 89 bool EnablePageActionFunction::RunImpl() { |
| 88 return SetPageActionEnabled(true); | 90 return SetPageActionEnabled(true); |
| 89 } | 91 } |
| 90 | 92 |
| 91 bool DisablePageActionFunction::RunImpl() { | 93 bool DisablePageActionFunction::RunImpl() { |
| 92 return SetPageActionEnabled(false); | 94 return SetPageActionEnabled(false); |
| 93 } | 95 } |
| OLD | NEW |