| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Tests common functionality used by the Chrome Extensions Cookies API | 5 // Tests common functionality used by the Chrome Extensions Cookies API |
| 6 // implementation. | 6 // implementation. |
| 7 | 7 |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_cookies_api_constants.h" | 11 #include "chrome/browser/extensions/extension_cookies_api_constants.h" |
| 12 #include "chrome/browser/extensions/extension_cookies_helpers.h" | 12 #include "chrome/browser/extensions/extension_cookies_helpers.h" |
| 13 #include "chrome/test/testing_profile.h" | 13 #include "chrome/test/testing_profile.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 | 15 |
| 16 namespace keys = extension_cookies_api_constants; | 16 namespace keys = extension_cookies_api_constants; |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 struct DomainMatchCase { | 20 struct DomainMatchCase { |
| 21 const char* filter; | 21 const char* filter; |
| 22 const char* domain; | 22 const char* domain; |
| 23 const bool matches; | 23 const bool matches; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 // A test profile that supports linking with another profile for off-the-record | 26 // A test profile that supports linking with another profile for incognito suppo
rt. |
| 27 // (a.k.a. incognito) support. | |
| 28 class OtrTestingProfile : public TestingProfile { | 27 class OtrTestingProfile : public TestingProfile { |
| 29 public: | 28 public: |
| 30 OtrTestingProfile() : linked_profile_(NULL) {} | 29 OtrTestingProfile() : linked_profile_(NULL) {} |
| 31 virtual Profile* GetOriginalProfile() { | 30 virtual Profile* GetOriginalProfile() { |
| 32 if (IsOffTheRecord()) | 31 if (IsOffTheRecord()) |
| 33 return linked_profile_; | 32 return linked_profile_; |
| 34 else | 33 else |
| 35 return this; | 34 return this; |
| 36 } | 35 } |
| 37 | 36 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 details->SetString(keys::kDomainKey, std::string(tests[i].filter)); | 198 details->SetString(keys::kDomainKey, std::string(tests[i].filter)); |
| 200 extension_cookies_helpers::MatchFilter filter(details.get()); | 199 extension_cookies_helpers::MatchFilter filter(details.get()); |
| 201 net::CookieMonster::CanonicalCookie cookie(GURL(), "", "", tests[i].domain, | 200 net::CookieMonster::CanonicalCookie cookie(GURL(), "", "", tests[i].domain, |
| 202 "", false, false, | 201 "", false, false, |
| 203 base::Time(), | 202 base::Time(), |
| 204 base::Time(), | 203 base::Time(), |
| 205 false, base::Time()); | 204 false, base::Time()); |
| 206 EXPECT_EQ(tests[i].matches, filter.MatchesCookie(cookie)); | 205 EXPECT_EQ(tests[i].matches, filter.MatchesCookie(cookie)); |
| 207 } | 206 } |
| 208 } | 207 } |
| OLD | NEW |