| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| 11 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 12 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
| 13 #include "content/common/notification_service.h" | 14 #include "content/common/notification_service.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 // Errors. | 17 // Errors. |
| 17 const char kNoBrowserActionError[] = | 18 const char kNoBrowserActionError[] = |
| 18 "This extension has no browser action specified."; | 19 "This extension has no browser action specified."; |
| 19 const char kIconIndexOutOfBounds[] = | 20 const char kIconIndexOutOfBounds[] = |
| 20 "Browser action icon index out of bounds."; | 21 "Browser action icon index out of bounds."; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 31 browser_action_ = extension->browser_action(); | 32 browser_action_ = extension->browser_action(); |
| 32 if (!browser_action_) { | 33 if (!browser_action_) { |
| 33 error_ = kNoBrowserActionError; | 34 error_ = kNoBrowserActionError; |
| 34 return false; | 35 return false; |
| 35 } | 36 } |
| 36 | 37 |
| 37 if (!RunBrowserAction()) | 38 if (!RunBrowserAction()) |
| 38 return false; | 39 return false; |
| 39 | 40 |
| 40 NotificationService::current()->Notify( | 41 NotificationService::current()->Notify( |
| 41 NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, | 42 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
| 42 Source<ExtensionAction>(browser_action_), | 43 Source<ExtensionAction>(browser_action_), |
| 43 NotificationService::NoDetails()); | 44 NotificationService::NoDetails()); |
| 44 return true; | 45 return true; |
| 45 } | 46 } |
| 46 | 47 |
| 47 bool BrowserActionSetIconFunction::RunBrowserAction() { | 48 bool BrowserActionSetIconFunction::RunBrowserAction() { |
| 48 BinaryValue* binary = NULL; | 49 BinaryValue* binary = NULL; |
| 49 EXTENSION_FUNCTION_VALIDATE(details_->GetBinary("imageData", &binary)); | 50 EXTENSION_FUNCTION_VALIDATE(details_->GetBinary("imageData", &binary)); |
| 50 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); | 51 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); |
| 51 void* iter = NULL; | 52 void* iter = NULL; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 for (size_t i = 0; i < arraysize(color_array); ++i) { | 92 for (size_t i = 0; i < arraysize(color_array); ++i) { |
| 92 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i])); | 93 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i])); |
| 93 } | 94 } |
| 94 | 95 |
| 95 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], | 96 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], |
| 96 color_array[2]); | 97 color_array[2]); |
| 97 browser_action_->SetBadgeBackgroundColor(tab_id_, color); | 98 browser_action_->SetBadgeBackgroundColor(tab_id_, color); |
| 98 | 99 |
| 99 return true; | 100 return true; |
| 100 } | 101 } |
| OLD | NEW |