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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 6901084: Use new APIs in base/values.h: Value::GetAsNumber and DictionaryValue::GetNumber. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
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/themes/browser_theme_pack.h" 5 #include "chrome/browser/themes/browser_theme_pack.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return RefCountedBytes::TakeVector(&raw_data); 292 return RefCountedBytes::TakeVector(&raw_data);
293 } 293 }
294 } 294 }
295 } 295 }
296 296
297 return NULL; 297 return NULL;
298 } 298 }
299 299
300 // Does error checking for invalid incoming data while trying to read an 300 // Does error checking for invalid incoming data while trying to read an
301 // floating point value. 301 // floating point value.
302 bool ValidDoubleValue(ListValue* tint_list, int index, double* out) { 302 bool ValidDoubleValue(ListValue* tint_list, int index, double* out) {
Mihai Parparita -not on Chrome 2011/05/02 16:59:49 I think you can delete this now.
Yusuke Sato 2011/05/04 14:10:10 Done.
303 if (tint_list->GetDouble(index, out)) 303 if (tint_list->GetDouble(index, out))
304 return true; 304 return true;
305 305
306 int value = 0; 306 int value = 0;
307 if (tint_list->GetInteger(index, &value)) { 307 if (tint_list->GetInteger(index, &value)) {
308 *out = value; 308 *out = value;
309 return true; 309 return true;
310 } 310 }
311 311
312 return false; 312 return false;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 616
617 // Parse the incoming data from |tints_value| into an intermediary structure. 617 // Parse the incoming data from |tints_value| into an intermediary structure.
618 std::map<int, color_utils::HSL> temp_tints; 618 std::map<int, color_utils::HSL> temp_tints;
619 for (DictionaryValue::key_iterator iter(tints_value->begin_keys()); 619 for (DictionaryValue::key_iterator iter(tints_value->begin_keys());
620 iter != tints_value->end_keys(); ++iter) { 620 iter != tints_value->end_keys(); ++iter) {
621 ListValue* tint_list; 621 ListValue* tint_list;
622 if (tints_value->GetList(*iter, &tint_list) && 622 if (tints_value->GetList(*iter, &tint_list) &&
623 (tint_list->GetSize() == 3)) { 623 (tint_list->GetSize() == 3)) {
624 color_utils::HSL hsl = { -1, -1, -1 }; 624 color_utils::HSL hsl = { -1, -1, -1 };
625 625
626 if (ValidDoubleValue(tint_list, 0, &hsl.h) && 626 if (tint_list->GetDouble(0, &hsl.h) &&
627 ValidDoubleValue(tint_list, 1, &hsl.s) && 627 tint_list->GetDouble(1, &hsl.s) &&
628 ValidDoubleValue(tint_list, 2, &hsl.l)) { 628 tint_list->GetDouble(2, &hsl.l)) {
629 int id = GetIntForString(*iter, kTintTable); 629 int id = GetIntForString(*iter, kTintTable);
630 if (id != -1) { 630 if (id != -1) {
631 temp_tints[id] = hsl; 631 temp_tints[id] = hsl;
632 } 632 }
633 } 633 }
634 } 634 }
635 } 635 }
636 636
637 // Copy data from the intermediary data structure to the array. 637 // Copy data from the intermediary data structure to the array.
638 int count = 0; 638 int count = 0;
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 hsl.h = tints_[i].h; 1045 hsl.h = tints_[i].h;
1046 hsl.s = tints_[i].s; 1046 hsl.s = tints_[i].s;
1047 hsl.l = tints_[i].l; 1047 hsl.l = tints_[i].l;
1048 return hsl; 1048 return hsl;
1049 } 1049 }
1050 } 1050 }
1051 } 1051 }
1052 1052
1053 return ThemeService::GetDefaultTint(id); 1053 return ThemeService::GetDefaultTint(id);
1054 } 1054 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698