| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/chromeos/external_cookie_handler.h" | 5 #include "chrome/browser/chromeos/external_cookie_handler.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chromeos/pipe_reader.h" | 8 #include "chrome/browser/chromeos/pipe_reader.h" |
| 9 #include "chrome/browser/net/url_request_context_getter.h" |
| 9 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 12 #include "net/base/cookie_store.h" | 13 #include "net/base/cookie_store.h" |
| 13 #include "net/url_request/url_request_context.h" | 14 #include "net/url_request/url_request_context.h" |
| 14 | 15 |
| 15 void ExternalCookieHandler::GetCookies(const CommandLine& parsed_command_line, | 16 void ExternalCookieHandler::GetCookies(const CommandLine& parsed_command_line, |
| 16 Profile* profile) { | 17 Profile* profile) { |
| 17 // If there are Google External SSO cookies, add them to the cookie store. | 18 // If there are Google External SSO cookies, add them to the cookie store. |
| 18 if (parsed_command_line.HasSwitch(switches::kCookiePipe)) { | 19 if (parsed_command_line.HasSwitch(switches::kCookiePipe)) { |
| 19 std::string pipe_name = | 20 std::string pipe_name = |
| 20 WideToASCII(parsed_command_line.GetSwitchValue(switches::kCookiePipe)); | 21 WideToASCII(parsed_command_line.GetSwitchValue(switches::kCookiePipe)); |
| 21 ExternalCookieHandler cookie_handler(new PipeReader(pipe_name)); | 22 ExternalCookieHandler cookie_handler(new PipeReader(pipe_name)); |
| 22 cookie_handler.HandleCookies( | 23 cookie_handler.HandleCookies( |
| 23 profile->GetRequestContext()->cookie_store()); | 24 profile->GetRequestContext()->GetCookieStore()); |
| 24 } | 25 } |
| 25 } | 26 } |
| 26 | 27 |
| 27 // static | 28 // static |
| 28 const char ExternalCookieHandler::kGoogleAccountsUrl[] = | 29 const char ExternalCookieHandler::kGoogleAccountsUrl[] = |
| 29 "https://www.google.com/a/google.com/acs"; | 30 "https://www.google.com/a/google.com/acs"; |
| 30 | 31 |
| 31 const int kChunkSize = 256; | 32 const int kChunkSize = 256; |
| 32 | 33 |
| 33 // Reads up to a newline, or the end of the data, in increments of |chunk| | 34 // Reads up to a newline, or the end of the data, in increments of |chunk| |
| (...skipping 28 matching lines...) Expand all Loading... |
| 62 std::string cookie_line = ReadLine(kChunkSize); | 63 std::string cookie_line = ReadLine(kChunkSize); |
| 63 while (!cookie_line.empty()) { | 64 while (!cookie_line.empty()) { |
| 64 if (!cookie_store->SetCookieWithOptions(url, cookie_line, options)) | 65 if (!cookie_store->SetCookieWithOptions(url, cookie_line, options)) |
| 65 return false; | 66 return false; |
| 66 cookie_line = ReadLine(kChunkSize); | 67 cookie_line = ReadLine(kChunkSize); |
| 67 } | 68 } |
| 68 return true; | 69 return true; |
| 69 } | 70 } |
| 70 return false; | 71 return false; |
| 71 } | 72 } |
| OLD | NEW |