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