| 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 "extensions/browser/api/declarative/deduping_factory.h" | 5 #include "extensions/browser/api/declarative/deduping_factory.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 // Note that this class must be immutable. | 53 // Note that this class must be immutable. |
| 54 const int parameter_; | 54 const int parameter_; |
| 55 DISALLOW_COPY_AND_ASSIGN(Foo); | 55 DISALLOW_COPY_AND_ASSIGN(Foo); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 scoped_refptr<const BaseClass> CreateFoo(const std::string& /*instance_type*/, | 58 scoped_refptr<const BaseClass> CreateFoo(const std::string& /*instance_type*/, |
| 59 const base::Value* value, | 59 const base::Value* value, |
| 60 std::string* error, | 60 std::string* error, |
| 61 bool* bad_message) { | 61 bool* bad_message) { |
| 62 const base::DictionaryValue* dict = NULL; | 62 const base::DictionaryValue* dict = nullptr; |
| 63 CHECK(value->GetAsDictionary(&dict)); | 63 CHECK(value->GetAsDictionary(&dict)); |
| 64 int parameter = 0; | 64 int parameter = 0; |
| 65 if (!dict->GetInteger("parameter", ¶meter)) { | 65 if (!dict->GetInteger("parameter", ¶meter)) { |
| 66 *error = "No parameter"; | 66 *error = "No parameter"; |
| 67 *bad_message = true; | 67 *bad_message = true; |
| 68 return scoped_refptr<const BaseClass>(NULL); | 68 return scoped_refptr<const BaseClass>(nullptr); |
| 69 } | 69 } |
| 70 return scoped_refptr<const BaseClass>(new Foo(parameter)); | 70 return scoped_refptr<const BaseClass>(new Foo(parameter)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 scoped_ptr<base::DictionaryValue> CreateDictWithParameter(int parameter) { | 73 scoped_ptr<base::DictionaryValue> CreateDictWithParameter(int parameter) { |
| 74 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 74 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 75 dict->SetInteger("parameter", parameter); | 75 dict->SetInteger("parameter", parameter); |
| 76 return dict.Pass(); | 76 return dict.Pass(); |
| 77 } | 77 } |
| 78 | 78 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 scoped_refptr<const BaseClass> c1_b( | 191 scoped_refptr<const BaseClass> c1_b( |
| 192 factory.Instantiate(kTypeName, d1.get(), &error, &bad_message)); | 192 factory.Instantiate(kTypeName, d1.get(), &error, &bad_message)); |
| 193 | 193 |
| 194 ASSERT_TRUE(c1_a.get()); | 194 ASSERT_TRUE(c1_a.get()); |
| 195 ASSERT_TRUE(c1_b.get()); | 195 ASSERT_TRUE(c1_b.get()); |
| 196 EXPECT_NE(c1_a, c1_b); | 196 EXPECT_NE(c1_a, c1_b); |
| 197 } | 197 } |
| 198 | 198 |
| 199 } // namespace extensions | 199 } // namespace extensions |
| OLD | NEW |