| 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_browser_actions_api.h" | 5 #include "chrome/browser/extensions/extension_browser_actions_api.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/common/notification_service.h" | 9 #include "chrome/common/notification_service.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 ListValue* list = NULL; | 109 ListValue* list = NULL; |
| 110 EXTENSION_FUNCTION_VALIDATE(details->GetList(L"color", &list)); | 110 EXTENSION_FUNCTION_VALIDATE(details->GetList(L"color", &list)); |
| 111 EXTENSION_FUNCTION_VALIDATE(list->GetSize() == 4); | 111 EXTENSION_FUNCTION_VALIDATE(list->GetSize() == 4); |
| 112 | 112 |
| 113 int color_array[4] = {0}; | 113 int color_array[4] = {0}; |
| 114 for (size_t i = 0; i < arraysize(color_array); ++i) { | 114 for (size_t i = 0; i < arraysize(color_array); ++i) { |
| 115 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i])); | 115 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i])); |
| 116 } | 116 } |
| 117 | 117 |
| 118 SkColor color = SkColorSetARGB(color_array[0], color_array[1], color_array[2], | 118 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], |
| 119 color_array[3]); | 119 color_array[2]); |
| 120 | 120 |
| 121 Extension* extension = dispatcher()->GetExtension(); | 121 Extension* extension = dispatcher()->GetExtension(); |
| 122 if (!extension->browser_action()) { | 122 if (!extension->browser_action()) { |
| 123 error_ = kNoBrowserActionError; | 123 error_ = kNoBrowserActionError; |
| 124 return false; | 124 return false; |
| 125 } | 125 } |
| 126 | 126 |
| 127 extension->browser_action_state()->set_badge_background_color(color); | 127 extension->browser_action_state()->set_badge_background_color(color); |
| 128 | 128 |
| 129 NotificationService::current()->Notify( | 129 NotificationService::current()->Notify( |
| 130 NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, | 130 NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, |
| 131 Source<ExtensionAction>(extension->browser_action()), | 131 Source<ExtensionAction>(extension->browser_action()), |
| 132 Details<ExtensionActionState>(extension->browser_action_state())); | 132 Details<ExtensionActionState>(extension->browser_action_state())); |
| 133 return true; | 133 return true; |
| 134 } | 134 } |
| OLD | NEW |