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/api/extension_action/extension_page_actions_
api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" | 10 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 // Make sure the URL hasn't changed. | 89 // Make sure the URL hasn't changed. |
90 NavigationEntry* entry = | 90 NavigationEntry* entry = |
91 contents->web_contents()->GetController().GetActiveEntry(); | 91 contents->web_contents()->GetController().GetActiveEntry(); |
92 if (!entry || url != entry->GetURL().spec()) { | 92 if (!entry || url != entry->GetURL().spec()) { |
93 error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url); | 93 error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url); |
94 return false; | 94 return false; |
95 } | 95 } |
96 | 96 |
97 // Set visibility and broadcast notifications that the UI should be updated. | 97 // Set visibility and broadcast notifications that the UI should be updated. |
98 page_action->SetIsVisible(tab_id, enable); | 98 page_action->SetAppearance( |
| 99 tab_id, enable ? ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE); |
99 page_action->SetTitle(tab_id, title); | 100 page_action->SetTitle(tab_id, title); |
100 page_action->SetIconIndex(tab_id, icon_id); | 101 page_action->SetIconIndex(tab_id, icon_id); |
101 contents->extension_tab_helper()->location_bar_controller()->NotifyChange(); | 102 contents->extension_tab_helper()->location_bar_controller()->NotifyChange(); |
102 | 103 |
103 return true; | 104 return true; |
104 } | 105 } |
105 | 106 |
106 bool EnablePageActionsFunction::RunImpl() { | 107 bool EnablePageActionsFunction::RunImpl() { |
107 return SetPageActionEnabled(true); | 108 return SetPageActionEnabled(true); |
108 } | 109 } |
109 | 110 |
110 bool DisablePageActionsFunction::RunImpl() { | 111 bool DisablePageActionsFunction::RunImpl() { |
111 return SetPageActionEnabled(false); | 112 return SetPageActionEnabled(false); |
112 } | 113 } |
OLD | NEW |