Index: chrome/browser/importer/toolbar_importer_utils.cc |
diff --git a/chrome/browser/importer/toolbar_importer_utils.cc b/chrome/browser/importer/toolbar_importer_utils.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..362b02283730f8d63b8d35655a1bde1570dcef2c |
--- /dev/null |
+++ b/chrome/browser/importer/toolbar_importer_utils.cc |
@@ -0,0 +1,43 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/importer/toolbar_importer_utils.h" |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/string_split.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/net/url_request_context_getter.h" |
+#include "googleurl/src/gurl.h" |
+#include "net/base/cookie_store.h" |
+ |
+namespace { |
+const char kGoogleDomainUrl[] = "http://.google.com/"; |
+const char kGoogleDomainSecureCookieId[] = "SID="; |
+const char kSplitStringToken = ';'; |
+} |
+ |
+namespace toolbar_importer_utils { |
+ |
+bool IsGoogleGAIACookieInstalled() { |
+ net::CookieStore* store = |
+ Profile::GetDefaultRequestContext()->GetCookieStore(); |
+ GURL url(kGoogleDomainUrl); |
+ net::CookieOptions options; |
+ options.set_include_httponly(); // The SID cookie might be httponly. |
+ std::string cookies = store->GetCookiesWithOptions(url, options); |
+ std::vector<std::string> cookie_list; |
+ base::SplitString(cookies, kSplitStringToken, &cookie_list); |
+ for (std::vector<std::string>::iterator current = cookie_list.begin(); |
+ current != cookie_list.end(); |
+ ++current) { |
+ size_t position = (*current).find(kGoogleDomainSecureCookieId); |
+ if (0 == position) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+} // namespace toolbar_importer_utils |