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_page_actions_module.h" | 5 #include "chrome/browser/extensions/extension_page_actions_module.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return false; | 205 return false; |
206 | 206 |
207 ListValue* color_value; | 207 ListValue* color_value; |
208 EXTENSION_FUNCTION_VALIDATE(args->GetList(L"color", &color_value)); | 208 EXTENSION_FUNCTION_VALIDATE(args->GetList(L"color", &color_value)); |
209 EXTENSION_FUNCTION_VALIDATE(color_value->GetSize() == 4); | 209 EXTENSION_FUNCTION_VALIDATE(color_value->GetSize() == 4); |
210 | 210 |
211 int color_array[4] = {0}; | 211 int color_array[4] = {0}; |
212 for (size_t i = 0; i < arraysize(color_array); ++i) | 212 for (size_t i = 0; i < arraysize(color_array); ++i) |
213 EXTENSION_FUNCTION_VALIDATE(color_value->GetInteger(i, &color_array[i])); | 213 EXTENSION_FUNCTION_VALIDATE(color_value->GetInteger(i, &color_array[i])); |
214 | 214 |
215 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], | 215 SkColor color = SkColorSetARGB(color_array[0], color_array[1], color_array[2], |
216 color_array[2]); | 216 color_array[3]); |
217 state_->set_badge_background_color(color); | 217 state_->set_badge_background_color(color); |
218 contents_->PageActionStateChanged(); | 218 contents_->PageActionStateChanged(); |
219 return true; | 219 return true; |
220 } | 220 } |
221 | 221 |
222 bool PageActionSetBadgeTextColorFunction::RunImpl() { | 222 bool PageActionSetBadgeTextColorFunction::RunImpl() { |
223 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); | 223 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
224 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); | 224 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); |
225 | 225 |
226 int tab_id; | 226 int tab_id; |
227 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); | 227 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); |
228 if (!InitCommon(tab_id)) | 228 if (!InitCommon(tab_id)) |
229 return false; | 229 return false; |
230 | 230 |
231 ListValue* color_value; | 231 ListValue* color_value; |
232 EXTENSION_FUNCTION_VALIDATE(args->GetList(L"color", &color_value)); | 232 EXTENSION_FUNCTION_VALIDATE(args->GetList(L"color", &color_value)); |
233 EXTENSION_FUNCTION_VALIDATE(color_value->GetSize() == 4); | 233 EXTENSION_FUNCTION_VALIDATE(color_value->GetSize() == 4); |
234 | 234 |
235 int color_array[4] = {0}; | 235 int color_array[4] = {0}; |
236 for (size_t i = 0; i < arraysize(color_array); ++i) | 236 for (size_t i = 0; i < arraysize(color_array); ++i) |
237 EXTENSION_FUNCTION_VALIDATE(color_value->GetInteger(i, &color_array[i])); | 237 EXTENSION_FUNCTION_VALIDATE(color_value->GetInteger(i, &color_array[i])); |
238 | 238 |
239 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], | 239 // TODO(mpcomplete): implement text coloring. |
240 color_array[2]); | |
241 state_->set_badge_text_color(color); | |
242 contents_->PageActionStateChanged(); | |
243 return true; | 240 return true; |
244 } | 241 } |
245 | 242 |
246 bool PageActionSetBadgeTextFunction::RunImpl() { | 243 bool PageActionSetBadgeTextFunction::RunImpl() { |
247 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); | 244 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
248 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); | 245 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); |
249 | 246 |
250 int tab_id; | 247 int tab_id; |
251 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); | 248 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); |
252 if (!InitCommon(tab_id)) | 249 if (!InitCommon(tab_id)) |
253 return false; | 250 return false; |
254 | 251 |
255 std::string text; | 252 std::string text; |
256 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); | 253 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); |
257 | 254 |
258 state_->set_badge_text(text); | 255 state_->set_badge_text(text); |
259 contents_->PageActionStateChanged(); | 256 contents_->PageActionStateChanged(); |
260 return true; | 257 return true; |
261 } | 258 } |
OLD | NEW |