Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Side by Side Diff: chrome/browser/extensions/api/extension_action/extension_action_api.cc

Issue 1781563003: chrome.browserAction.setBadgeBackgroundColor accepts color keyword (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // Whether the browser action is visible in the toolbar. 49 // Whether the browser action is visible in the toolbar.
50 const char kBrowserActionVisible[] = "browser_action_visible"; 50 const char kBrowserActionVisible[] = "browser_action_visible";
51 51
52 // Errors. 52 // Errors.
53 const char kNoExtensionActionError[] = 53 const char kNoExtensionActionError[] =
54 "This extension has no action specified."; 54 "This extension has no action specified.";
55 const char kNoTabError[] = "No tab with id: *."; 55 const char kNoTabError[] = "No tab with id: *.";
56 const char kOpenPopupError[] = 56 const char kOpenPopupError[] =
57 "Failed to show popup either because there is an existing popup or another " 57 "Failed to show popup either because there is an existing popup or another "
58 "error occurred."; 58 "error occurred.";
59 const char kInvalidColorError[] =
60 "The color specification could not be parsed.";
59 61
60 } // namespace 62 } // namespace
61 63
62 // 64 //
63 // ExtensionActionAPI::Observer 65 // ExtensionActionAPI::Observer
64 // 66 //
65 67
66 void ExtensionActionAPI::Observer::OnExtensionActionUpdated( 68 void ExtensionActionAPI::Observer::OnExtensionActionUpdated(
67 ExtensionAction* extension_action, 69 ExtensionAction* extension_action,
68 content::WebContents* web_contents, 70 content::WebContents* web_contents,
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 int color_array[4] = {0}; 575 int color_array[4] = {0};
574 for (size_t i = 0; i < arraysize(color_array); ++i) { 576 for (size_t i = 0; i < arraysize(color_array); ++i) {
575 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i])); 577 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i]));
576 } 578 }
577 579
578 color = SkColorSetARGB(color_array[3], color_array[0], 580 color = SkColorSetARGB(color_array[3], color_array[0],
579 color_array[1], color_array[2]); 581 color_array[1], color_array[2]);
580 } else if (color_value->IsType(base::Value::TYPE_STRING)) { 582 } else if (color_value->IsType(base::Value::TYPE_STRING)) {
581 std::string color_string; 583 std::string color_string;
582 EXTENSION_FUNCTION_VALIDATE(details_->GetString("color", &color_string)); 584 EXTENSION_FUNCTION_VALIDATE(details_->GetString("color", &color_string));
583 if (!image_util::ParseCssColorString(color_string, &color)) 585 if (!image_util::ParseCssColorString(color_string, &color)) {
586 error_ = kInvalidColorError;
584 return false; 587 return false;
588 }
585 } 589 }
586 590
587 extension_action_->SetBadgeBackgroundColor(tab_id_, color); 591 extension_action_->SetBadgeBackgroundColor(tab_id_, color);
588 NotifyChange(); 592 NotifyChange();
589 return true; 593 return true;
590 } 594 }
591 595
592 bool ExtensionActionGetTitleFunction::RunExtensionAction() { 596 bool ExtensionActionGetTitleFunction::RunExtensionAction() {
593 SetResult(new base::StringValue(extension_action_->GetTitle(tab_id_))); 597 SetResult(new base::StringValue(extension_action_->GetTitle(tab_id_)));
594 return true; 598 return true;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || 696 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP ||
693 host->extension()->id() != extension_->id()) 697 host->extension()->id() != extension_->id())
694 return; 698 return;
695 699
696 SendResponse(true); 700 SendResponse(true);
697 response_sent_ = true; 701 response_sent_ = true;
698 registrar_.RemoveAll(); 702 registrar_.RemoveAll();
699 } 703 }
700 704
701 } // namespace extensions 705 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698