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 // Implements common functionality for the Chrome Extensions Cookies API. | 5 // Implements common functionality for the Chrome Extensions Cookies API. |
6 | 6 |
7 #include "chrome/browser/extensions/extension_cookies_helpers.h" | 7 #include "chrome/browser/extensions/extension_cookies_helpers.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace extension_cookies_helpers { | 23 namespace extension_cookies_helpers { |
24 | 24 |
25 static const char kOriginalProfileStoreId[] = "0"; | 25 static const char kOriginalProfileStoreId[] = "0"; |
26 static const char kOffTheRecordProfileStoreId[] = "1"; | 26 static const char kOffTheRecordProfileStoreId[] = "1"; |
27 | 27 |
28 Profile* ChooseProfileFromStoreId(const std::string& store_id, | 28 Profile* ChooseProfileFromStoreId(const std::string& store_id, |
29 Profile* profile, | 29 Profile* profile, |
30 bool include_incognito) { | 30 bool include_incognito) { |
31 DCHECK(profile); | 31 DCHECK(profile); |
32 bool allow_original = !profile->IsOffTheRecord(); | 32 bool allow_original = !profile->IsOffTheRecord(); |
33 bool allow_incognito = profile->IsOffTheRecord() || include_incognito; | 33 bool allow_incognito = profile->IsOffTheRecord() || |
| 34 (include_incognito && profile->HasOffTheRecordProfile()); |
34 if (store_id == kOriginalProfileStoreId && allow_original) | 35 if (store_id == kOriginalProfileStoreId && allow_original) |
35 return profile->GetOriginalProfile(); | 36 return profile->GetOriginalProfile(); |
36 if (store_id == kOffTheRecordProfileStoreId && allow_incognito) | 37 if (store_id == kOffTheRecordProfileStoreId && allow_incognito) |
37 return profile->GetOffTheRecordProfile(); | 38 return profile->GetOffTheRecordProfile(); |
38 return NULL; | 39 return NULL; |
39 } | 40 } |
40 | 41 |
41 const char* GetStoreIdFromProfile(Profile* profile) { | 42 const char* GetStoreIdFromProfile(Profile* profile) { |
42 DCHECK(profile); | 43 DCHECK(profile); |
43 return profile->IsOffTheRecord() ? | 44 return profile->IsOffTheRecord() ? |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 sub_domain.length() >= filter_value.length();) { | 179 sub_domain.length() >= filter_value.length();) { |
179 if (sub_domain == filter_value) | 180 if (sub_domain == filter_value) |
180 return true; | 181 return true; |
181 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 182 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
182 sub_domain.erase(0, next_dot); | 183 sub_domain.erase(0, next_dot); |
183 } | 184 } |
184 return false; | 185 return false; |
185 } | 186 } |
186 | 187 |
187 } // namespace extension_cookies_helpers | 188 } // namespace extension_cookies_helpers |
OLD | NEW |