| OLD | NEW |
| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 for (std::map<int, SkColor>::const_iterator it = color_map.begin(); | 71 for (std::map<int, SkColor>::const_iterator it = color_map.begin(); |
| 72 it != color_map.end(); ++it) { | 72 it != color_map.end(); ++it) { |
| 73 SkColor color = ThemeService::GetDefaultColor(it->first); | 73 SkColor color = ThemeService::GetDefaultColor(it->first); |
| 74 theme_pack_->GetColor(it->first, &color); | 74 theme_pack_->GetColor(it->first, &color); |
| 75 EXPECT_EQ(it->second, color) << "Color id = " << it->first; | 75 EXPECT_EQ(it->second, color) << "Color id = " << it->first; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 void LoadColorJSON(const std::string& json) { | 79 void LoadColorJSON(const std::string& json) { |
| 80 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); | 80 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); |
| 81 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); | 81 ASSERT_TRUE(value->IsDictionary()); |
| 82 LoadColorDictionary(static_cast<DictionaryValue*>(value.get())); | 82 LoadColorDictionary(static_cast<DictionaryValue*>(value.get())); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void LoadColorDictionary(DictionaryValue* value) { | 85 void LoadColorDictionary(DictionaryValue* value) { |
| 86 theme_pack_->BuildColorsFromJSON(value); | 86 theme_pack_->BuildColorsFromJSON(value); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void LoadTintJSON(const std::string& json) { | 89 void LoadTintJSON(const std::string& json) { |
| 90 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); | 90 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); |
| 91 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); | 91 ASSERT_TRUE(value->IsDictionary()); |
| 92 LoadTintDictionary(static_cast<DictionaryValue*>(value.get())); | 92 LoadTintDictionary(static_cast<DictionaryValue*>(value.get())); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void LoadTintDictionary(DictionaryValue* value) { | 95 void LoadTintDictionary(DictionaryValue* value) { |
| 96 theme_pack_->BuildTintsFromJSON(value); | 96 theme_pack_->BuildTintsFromJSON(value); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void LoadDisplayPropertiesJSON(const std::string& json) { | 99 void LoadDisplayPropertiesJSON(const std::string& json) { |
| 100 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); | 100 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); |
| 101 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); | 101 ASSERT_TRUE(value->IsDictionary()); |
| 102 LoadDisplayPropertiesDictionary(static_cast<DictionaryValue*>(value.get())); | 102 LoadDisplayPropertiesDictionary(static_cast<DictionaryValue*>(value.get())); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void LoadDisplayPropertiesDictionary(DictionaryValue* value) { | 105 void LoadDisplayPropertiesDictionary(DictionaryValue* value) { |
| 106 theme_pack_->BuildDisplayPropertiesFromJSON(value); | 106 theme_pack_->BuildDisplayPropertiesFromJSON(value); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ParseImageNamesJSON(const std::string& json, | 109 void ParseImageNamesJSON(const std::string& json, |
| 110 std::map<int, FilePath>* out_file_paths) { | 110 std::map<int, FilePath>* out_file_paths) { |
| 111 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); | 111 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); |
| 112 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); | 112 ASSERT_TRUE(value->IsDictionary()); |
| 113 ParseImageNamesDictionary(static_cast<DictionaryValue*>(value.get()), | 113 ParseImageNamesDictionary(static_cast<DictionaryValue*>(value.get()), |
| 114 out_file_paths); | 114 out_file_paths); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ParseImageNamesDictionary(DictionaryValue* value, | 117 void ParseImageNamesDictionary(DictionaryValue* value, |
| 118 std::map<int, FilePath>* out_file_paths) { | 118 std::map<int, FilePath>* out_file_paths) { |
| 119 theme_pack_->ParseImageNamesFromJSON(value, FilePath(), out_file_paths); | 119 theme_pack_->ParseImageNamesFromJSON(value, FilePath(), out_file_paths); |
| 120 | 120 |
| 121 // Build the source image list for HasCustomImage(). | 121 // Build the source image list for HasCustomImage(). |
| 122 theme_pack_->BuildSourceImagesArray(*out_file_paths); | 122 theme_pack_->BuildSourceImagesArray(*out_file_paths); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 // Part 2: Try to read back the data pack that we just wrote to disk. | 422 // Part 2: Try to read back the data pack that we just wrote to disk. |
| 423 { | 423 { |
| 424 scoped_refptr<BrowserThemePack> pack = | 424 scoped_refptr<BrowserThemePack> pack = |
| 425 BrowserThemePack::BuildFromDataPack( | 425 BrowserThemePack::BuildFromDataPack( |
| 426 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); | 426 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); |
| 427 ASSERT_TRUE(pack.get()); | 427 ASSERT_TRUE(pack.get()); |
| 428 VerifyStarGazing(pack.get()); | 428 VerifyStarGazing(pack.get()); |
| 429 } | 429 } |
| 430 } | 430 } |
| OLD | NEW |