| 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 24 matching lines...) Expand all Loading... |
| 35 void* iter = NULL; | 35 void* iter = NULL; |
| 36 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 36 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
| 37 EXTENSION_FUNCTION_VALIDATE( | 37 EXTENSION_FUNCTION_VALIDATE( |
| 38 IPC::ReadParam(&bitmap_pickle, &iter, bitmap.get())); | 38 IPC::ReadParam(&bitmap_pickle, &iter, bitmap.get())); |
| 39 extension->browser_action_state()->set_icon(bitmap.release()); | 39 extension->browser_action_state()->set_icon(bitmap.release()); |
| 40 } else { | 40 } else { |
| 41 int icon_index = -1; | 41 int icon_index = -1; |
| 42 EXTENSION_FUNCTION_VALIDATE( | 42 EXTENSION_FUNCTION_VALIDATE( |
| 43 static_cast<DictionaryValue*>(args_)->GetInteger( | 43 static_cast<DictionaryValue*>(args_)->GetInteger( |
| 44 L"iconIndex", &icon_index)); | 44 L"iconIndex", &icon_index)); |
| 45 |
| 45 if (icon_index < 0 || | 46 if (icon_index < 0 || |
| 46 static_cast<size_t>(icon_index) >= | 47 static_cast<size_t>(icon_index) >= |
| 47 extension->browser_action()->icon_paths().size()) { | 48 extension->browser_action()->icon_paths().size()) { |
| 48 error_ = kIconIndexOutOfBounds; | 49 error_ = kIconIndexOutOfBounds; |
| 49 return false; | 50 return false; |
| 50 } | 51 } |
| 51 extension->browser_action_state()->set_icon_index(icon_index); | 52 extension->browser_action_state()->set_icon_index(icon_index); |
| 52 extension->browser_action_state()->set_icon(NULL); | 53 extension->browser_action_state()->set_icon(NULL); |
| 53 } | 54 } |
| 54 | 55 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 127 } |
| 127 | 128 |
| 128 extension->browser_action_state()->set_badge_background_color(color); | 129 extension->browser_action_state()->set_badge_background_color(color); |
| 129 | 130 |
| 130 NotificationService::current()->Notify( | 131 NotificationService::current()->Notify( |
| 131 NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, | 132 NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, |
| 132 Source<ExtensionAction>(extension->browser_action()), | 133 Source<ExtensionAction>(extension->browser_action()), |
| 133 Details<ExtensionActionState>(extension->browser_action_state())); | 134 Details<ExtensionActionState>(extension->browser_action_state())); |
| 134 return true; | 135 return true; |
| 135 } | 136 } |
| OLD | NEW |