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

Side by Side Diff: chrome/browser/importer/toolbar_importer_utils.cc

Issue 18120005: Remove Google Toolbar importer (aka google.com/bookmarks importer). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: -explicit Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/importer/toolbar_importer_utils.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/bind.h"
11 #include "base/strings/string_split.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "googleurl/src/gurl.h"
15 #include "net/cookies/cookie_store.h"
16 #include "net/url_request/url_request_context.h"
17 #include "net/url_request/url_request_context_getter.h"
18
19 using content::BrowserThread;
20
21 namespace {
22 const char kGoogleDomainUrl[] = "http://.google.com/";
23 const char kGoogleDomainSecureCookieId[] = "SID=";
24 const char kSplitStringToken = ';';
25 }
26
27 namespace toolbar_importer_utils {
28
29 void OnGetCookies(const base::Callback<void(bool)>& callback,
30 const std::string& cookies) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 std::vector<std::string> cookie_list;
33 base::SplitString(cookies, kSplitStringToken, &cookie_list);
34 for (std::vector<std::string>::iterator current = cookie_list.begin();
35 current != cookie_list.end();
36 ++current) {
37 size_t position = (*current).find(kGoogleDomainSecureCookieId);
38 if (position == 0) {
39 callback.Run(true);
40 return;
41 }
42 }
43 callback.Run(false);
44 }
45
46 void OnFetchComplete(const base::Callback<void(bool)>& callback,
47 const std::string& cookies) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
49 BrowserThread::PostTask(
50 BrowserThread::UI, FROM_HERE,
51 base::Bind(&OnGetCookies, callback, cookies));
52 }
53
54 void FetchCookiesOnIOThread(
55 const base::Callback<void(bool)>& callback,
56 net::URLRequestContextGetter* context_getter) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
58 net::CookieStore* store = context_getter->
59 GetURLRequestContext()->cookie_store();
60 GURL url(kGoogleDomainUrl);
61 net::CookieOptions options;
62 options.set_include_httponly(); // The SID cookie might be httponly.
63 store->GetCookiesWithOptionsAsync(
64 url, options,
65 base::Bind(&toolbar_importer_utils::OnFetchComplete, callback));
66 }
67
68 void IsGoogleGAIACookieInstalled(const base::Callback<void(bool)>& callback,
69 Profile* profile) {
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
71 if (!callback.is_null()) {
72 BrowserThread::PostTask(
73 BrowserThread::IO, FROM_HERE,
74 base::Bind(&FetchCookiesOnIOThread,
75 callback, base::Unretained(profile->GetRequestContext())));
76 }
77 }
78
79 } // namespace toolbar_importer_utils
OLDNEW
« no previous file with comments | « chrome/browser/importer/toolbar_importer_utils.h ('k') | chrome/browser/importer/toolbar_importer_utils_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698