| 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_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // setIcon can take a variant argument: either a dictionary of canvas | 499 // setIcon can take a variant argument: either a dictionary of canvas |
| 500 // ImageData, or an icon index. | 500 // ImageData, or an icon index. |
| 501 base::DictionaryValue* canvas_set = NULL; | 501 base::DictionaryValue* canvas_set = NULL; |
| 502 int icon_index; | 502 int icon_index; |
| 503 if (details_->GetDictionary("imageData", &canvas_set)) { | 503 if (details_->GetDictionary("imageData", &canvas_set)) { |
| 504 gfx::ImageSkia icon; | 504 gfx::ImageSkia icon; |
| 505 | 505 |
| 506 EXTENSION_FUNCTION_VALIDATE( | 506 EXTENSION_FUNCTION_VALIDATE( |
| 507 ExtensionAction::ParseIconFromCanvasDictionary(*canvas_set, &icon)); | 507 ExtensionAction::ParseIconFromCanvasDictionary(*canvas_set, &icon)); |
| 508 | 508 |
| 509 if (icon.isNull()) { |
| 510 error_ = "Icon invalid."; |
| 511 return false; |
| 512 } |
| 513 |
| 509 extension_action_->SetIcon(tab_id_, gfx::Image(icon)); | 514 extension_action_->SetIcon(tab_id_, gfx::Image(icon)); |
| 510 } else if (details_->GetInteger("iconIndex", &icon_index)) { | 515 } else if (details_->GetInteger("iconIndex", &icon_index)) { |
| 511 // Obsolete argument: ignore it. | 516 // Obsolete argument: ignore it. |
| 512 return true; | 517 return true; |
| 513 } else { | 518 } else { |
| 514 EXTENSION_FUNCTION_VALIDATE(false); | 519 EXTENSION_FUNCTION_VALIDATE(false); |
| 515 } | 520 } |
| 516 NotifyChange(); | 521 NotifyChange(); |
| 517 return true; | 522 return true; |
| 518 } | 523 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 686 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
| 682 host->extension()->id() != extension_->id()) | 687 host->extension()->id() != extension_->id()) |
| 683 return; | 688 return; |
| 684 | 689 |
| 685 SendResponse(true); | 690 SendResponse(true); |
| 686 response_sent_ = true; | 691 response_sent_ = true; |
| 687 registrar_.RemoveAll(); | 692 registrar_.RemoveAll(); |
| 688 } | 693 } |
| 689 | 694 |
| 690 } // namespace extensions | 695 } // namespace extensions |
| OLD | NEW |