| 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" |
| 11 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| 12 #include "chrome/browser/extensions/extension_cookies_api_constants.h" | 12 #include "chrome/browser/extensions/extension_cookies_api_constants.h" |
| 13 #include "chrome/browser/extensions/extension_tabs_module.h" | 13 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 14 #include "chrome/browser/profile.h" | 14 #include "chrome/browser/profile.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 | 18 |
| 19 namespace keys = extension_cookies_api_constants; | 19 namespace keys = extension_cookies_api_constants; |
| 20 | 20 |
| 21 namespace extension_cookies_helpers { | 21 namespace extension_cookies_helpers { |
| 22 | 22 |
| 23 static const char kOriginalProfileStoreId[] = "0"; | 23 static const char kOriginalProfileStoreId[] = "0"; |
| 24 static const char kOffTheRecordProfileStoreId[] = "1"; | 24 static const char kOffTheRecordProfileStoreId[] = "1"; |
| 25 | 25 |
| 26 Profile* ChooseProfileFromStoreId(const std::string& store_id, | 26 Profile* ChooseProfileFromStoreId(const std::string& store_id, |
| 27 Profile* profile, | 27 Profile* profile, |
| 28 bool include_incognito) { | 28 bool include_incognito) { |
| 29 DCHECK(profile); | 29 DCHECK(profile); |
| 30 if (store_id == kOriginalProfileStoreId) | 30 bool allow_original = !profile->IsOffTheRecord(); |
| 31 bool allow_incognito = profile->IsOffTheRecord() || include_incognito; |
| 32 if (store_id == kOriginalProfileStoreId && allow_original) |
| 31 return profile->GetOriginalProfile(); | 33 return profile->GetOriginalProfile(); |
| 32 if (store_id == kOffTheRecordProfileStoreId && include_incognito) | 34 if (store_id == kOffTheRecordProfileStoreId && allow_incognito) |
| 33 return profile->GetOffTheRecordProfile(); | 35 return profile->GetOffTheRecordProfile(); |
| 34 return NULL; | 36 return NULL; |
| 35 } | 37 } |
| 36 | 38 |
| 37 const char* GetStoreIdFromProfile(Profile* profile) { | 39 const char* GetStoreIdFromProfile(Profile* profile) { |
| 38 DCHECK(profile); | 40 DCHECK(profile); |
| 39 return profile->IsOffTheRecord() ? | 41 return profile->IsOffTheRecord() ? |
| 40 kOffTheRecordProfileStoreId : kOriginalProfileStoreId; | 42 kOffTheRecordProfileStoreId : kOriginalProfileStoreId; |
| 41 } | 43 } |
| 42 | 44 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 sub_domain.length() >= filter_value.length();) { | 175 sub_domain.length() >= filter_value.length();) { |
| 174 if (sub_domain == filter_value) | 176 if (sub_domain == filter_value) |
| 175 return true; | 177 return true; |
| 176 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 178 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
| 177 sub_domain.erase(0, next_dot); | 179 sub_domain.erase(0, next_dot); |
| 178 } | 180 } |
| 179 return false; | 181 return false; |
| 180 } | 182 } |
| 181 | 183 |
| 182 } // namespace extension_cookies_helpers | 184 } // namespace extension_cookies_helpers |
| OLD | NEW |