| 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_actions_api.h
" | 5 #include "chrome/browser/extensions/api/extension_action/extension_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 "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 bool ExtensionActionFunction::SetVisible(bool visible) { | 176 bool ExtensionActionFunction::SetVisible(bool visible) { |
| 177 // If --enable-script-badges is on there will be a browser_action here | 177 // If --enable-script-badges is on there will be a browser_action here |
| 178 // instead of a page action. Disable/renable the browser action perhaps? | 178 // instead of a page action. Disable/renable the browser action perhaps? |
| 179 if (!GetExtension()->page_action()) | 179 if (!GetExtension()->page_action()) |
| 180 return true; | 180 return true; |
| 181 extension_action_->SetIsVisible(tab_id_, visible); | 181 extension_action_->SetIsVisible(tab_id_, visible); |
| 182 NotifyChange(); | 182 NotifyChange(); |
| 183 return true; | 183 return true; |
| 184 } | 184 } |
| 185 | 185 |
| 186 ExtensionTabHelper& ExtensionActionFunction::tab_helper() const { |
| 187 CHECK(contents_); |
| 188 return *contents_->extension_tab_helper(); |
| 189 } |
| 190 |
| 186 bool ExtensionActionShowFunction::RunExtensionAction() { | 191 bool ExtensionActionShowFunction::RunExtensionAction() { |
| 187 return SetVisible(true); | 192 return SetVisible(true); |
| 188 } | 193 } |
| 189 | 194 |
| 190 bool ExtensionActionHideFunction::RunExtensionAction() { | 195 bool ExtensionActionHideFunction::RunExtensionAction() { |
| 191 return SetVisible(false); | 196 return SetVisible(false); |
| 192 } | 197 } |
| 193 | 198 |
| 194 bool ExtensionActionSetIconFunction::RunExtensionAction() { | 199 bool ExtensionActionSetIconFunction::RunExtensionAction() { |
| 195 // setIcon can take a variant argument: either a canvas ImageData, or an | 200 // setIcon can take a variant argument: either a canvas ImageData, or an |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { | 304 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { |
| 300 ListValue* list = new ListValue(); | 305 ListValue* list = new ListValue(); |
| 301 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); | 306 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); |
| 302 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); | 307 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); |
| 303 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); | 308 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); |
| 304 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); | 309 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); |
| 305 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); | 310 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); |
| 306 SetResult(list); | 311 SetResult(list); |
| 307 return true; | 312 return true; |
| 308 } | 313 } |
| OLD | NEW |