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

Side by Side Diff: chrome/browser/extensions/api/content_settings/content_settings_store_unittest.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/content_settings/content_settings_store. h" 5 #include "chrome/browser/extensions/api/content_settings/content_settings_store. h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include <memory>
10
10 #include "components/content_settings/core/browser/content_settings_rule.h" 11 #include "components/content_settings/core/browser/content_settings_rule.h"
11 #include "components/content_settings/core/browser/content_settings_utils.h" 12 #include "components/content_settings/core/browser/content_settings_utils.h"
12 #include "components/content_settings/core/test/content_settings_test_utils.h" 13 #include "components/content_settings/core/test/content_settings_test_utils.h"
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 using ::testing::Mock; 18 using ::testing::Mock;
18 19
19 namespace extensions { 20 namespace extensions {
(...skipping 28 matching lines...) Expand all
48 MOCK_METHOD2(OnContentSettingChanged, 49 MOCK_METHOD2(OnContentSettingChanged,
49 void(const std::string& extension_id, bool incognito)); 50 void(const std::string& extension_id, bool incognito));
50 }; 51 };
51 52
52 ContentSetting GetContentSettingFromStore( 53 ContentSetting GetContentSettingFromStore(
53 const ContentSettingsStore* store, 54 const ContentSettingsStore* store,
54 const GURL& primary_url, const GURL& secondary_url, 55 const GURL& primary_url, const GURL& secondary_url,
55 ContentSettingsType content_type, 56 ContentSettingsType content_type,
56 const std::string& resource_identifier, 57 const std::string& resource_identifier,
57 bool incognito) { 58 bool incognito) {
58 scoped_ptr<content_settings::RuleIterator> rule_iterator( 59 std::unique_ptr<content_settings::RuleIterator> rule_iterator(
59 store->GetRuleIterator(content_type, resource_identifier, incognito)); 60 store->GetRuleIterator(content_type, resource_identifier, incognito));
60 scoped_ptr<base::Value> setting( 61 std::unique_ptr<base::Value> setting(
61 content_settings::TestUtils::GetContentSettingValueAndPatterns( 62 content_settings::TestUtils::GetContentSettingValueAndPatterns(
62 rule_iterator.get(), primary_url, secondary_url, NULL, NULL)); 63 rule_iterator.get(), primary_url, secondary_url, NULL, NULL));
63 return content_settings::ValueToContentSetting(setting.get()); 64 return content_settings::ValueToContentSetting(setting.get());
64 } 65 }
65 66
66 void GetSettingsForOneTypeFromStore( 67 void GetSettingsForOneTypeFromStore(
67 const ContentSettingsStore* store, 68 const ContentSettingsStore* store,
68 ContentSettingsType content_type, 69 ContentSettingsType content_type,
69 const std::string& resource_identifier, 70 const std::string& resource_identifier,
70 bool incognito, 71 bool incognito,
71 std::vector<content_settings::Rule>* rules) { 72 std::vector<content_settings::Rule>* rules) {
72 rules->clear(); 73 rules->clear();
73 scoped_ptr<content_settings::RuleIterator> rule_iterator( 74 std::unique_ptr<content_settings::RuleIterator> rule_iterator(
74 store->GetRuleIterator(content_type, resource_identifier, incognito)); 75 store->GetRuleIterator(content_type, resource_identifier, incognito));
75 while (rule_iterator->HasNext()) 76 while (rule_iterator->HasNext())
76 rules->push_back(rule_iterator->Next()); 77 rules->push_back(rule_iterator->Next());
77 } 78 }
78 79
79 } // namespace 80 } // namespace
80 81
81 class ContentSettingsStoreTest : public ::testing::Test { 82 class ContentSettingsStoreTest : public ::testing::Test {
82 public: 83 public:
83 ContentSettingsStoreTest() : 84 ContentSettingsStoreTest() :
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 248
248 // Uninstall second extension. 249 // Uninstall second extension.
249 store()->UnregisterExtension(ext_id_2); 250 store()->UnregisterExtension(ext_id_2);
250 251
251 GetSettingsForOneTypeFromStore( 252 GetSettingsForOneTypeFromStore(
252 store(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), incognito, &rules); 253 store(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), incognito, &rules);
253 ASSERT_EQ(0u, rules.size()); 254 ASSERT_EQ(0u, rules.size());
254 } 255 }
255 256
256 } // namespace extensions 257 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698