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/values.h" | 10 #include "base/values.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 extension_action_(NULL) { | 39 extension_action_(NULL) { |
40 } | 40 } |
41 | 41 |
42 ExtensionActionFunction::~ExtensionActionFunction() { | 42 ExtensionActionFunction::~ExtensionActionFunction() { |
43 } | 43 } |
44 | 44 |
45 bool ExtensionActionFunction::RunImpl() { | 45 bool ExtensionActionFunction::RunImpl() { |
46 extension_action_ = GetExtension()->browser_action(); | 46 extension_action_ = GetExtension()->browser_action(); |
47 if (!extension_action_) | 47 if (!extension_action_) |
48 extension_action_ = GetExtension()->page_action(); | 48 extension_action_ = GetExtension()->page_action(); |
49 EXTENSION_FUNCTION_VALIDATE(extension_action_); | 49 if (!extension_action_) { |
| 50 // TODO(kalman): ideally the browserAction/pageAction APIs wouldn't event |
| 51 // exist for extensions that don't have one declared. This should come as |
| 52 // part of the Feature system. |
| 53 error_ = kNoExtensionActionError; |
| 54 return false; |
| 55 } |
50 | 56 |
51 // There may or may not be details (depends on the function). | 57 // There may or may not be details (depends on the function). |
52 // The tabId might appear in details (if it exists) or as the first | 58 // The tabId might appear in details (if it exists) or as the first |
53 // argument besides the action type (depends on the function). | 59 // argument besides the action type (depends on the function). |
54 { | 60 { |
55 base::Value* first_arg = NULL; | 61 base::Value* first_arg = NULL; |
56 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &first_arg)); | 62 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &first_arg)); |
57 | 63 |
58 switch (first_arg->GetType()) { | 64 switch (first_arg->GetType()) { |
59 case Value::TYPE_INTEGER: | 65 case Value::TYPE_INTEGER: |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { | 290 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { |
285 ListValue* list = new ListValue(); | 291 ListValue* list = new ListValue(); |
286 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); | 292 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); |
287 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); | 293 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); |
288 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); | 294 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); |
289 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); | 295 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); |
290 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); | 296 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); |
291 result_.reset(list); | 297 result_.reset(list); |
292 return true; | 298 return true; |
293 } | 299 } |
OLD | NEW |