| 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 #ifndef CHROME_BROWSER_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/chromeos/pipe_reader.h" | 11 #include "chrome/browser/chromeos/pipe_reader.h" |
| 12 | 12 |
| 13 // Single sign on cookies for Google can be passed in over a | 13 // Single sign on cookies for Google can be passed in over a |
| 14 // pipe. If they've been sent, this reads them and adds them to the | 14 // pipe. If they've been sent, this reads them and adds them to the |
| 15 // cookie store as session cookies. | 15 // cookie store as session cookies. |
| 16 | 16 |
| 17 class CommandLine; | 17 class CommandLine; |
| 18 class Profile; | 18 class Profile; |
| 19 namespace net { | 19 namespace net { |
| 20 class CookieStore; | 20 class CookieStore; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace chromeos { |
| 24 |
| 23 class ExternalCookieHandler { | 25 class ExternalCookieHandler { |
| 24 public: | 26 public: |
| 25 // Takes ownsership of |reader|. | 27 // Takes ownsership of |reader|. |
| 26 explicit ExternalCookieHandler(PipeReader *reader) : reader_(reader) {} | 28 explicit ExternalCookieHandler(PipeReader *reader) : reader_(reader) {} |
| 27 virtual ~ExternalCookieHandler() {} | 29 virtual ~ExternalCookieHandler() {} |
| 28 | 30 |
| 29 // Given a pipe to read cookies from, reads and adds them to |cookie_store|. | 31 // Given a pipe to read cookies from, reads and adds them to |cookie_store|. |
| 30 virtual bool HandleCookies(net::CookieStore *cookie_store); | 32 virtual bool HandleCookies(net::CookieStore *cookie_store); |
| 31 | 33 |
| 32 // Checks |parsed_command_line| for the --cookie-pipe; if found, reads | 34 // Checks |parsed_command_line| for the --cookie-pipe; if found, reads |
| 33 // cookies from the pipe and adds them to the cookie store found in |profile|. | 35 // cookies from the pipe and adds them to the cookie store found in |profile|. |
| 34 static void GetCookies(const CommandLine& parsed_command_line, | 36 static void GetCookies(const CommandLine& parsed_command_line, |
| 35 Profile* profile); | 37 Profile* profile); |
| 36 | 38 |
| 37 // The url with which we associate the read-in cookies. | 39 // The url with which we associate the read-in cookies. |
| 38 static const char kGoogleAccountsUrl[]; | 40 static const char kGoogleAccountsUrl[]; |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 // Reads up to a newline, or the end of the data, in increments of |chunk|. | 43 // Reads up to a newline, or the end of the data, in increments of |chunk|. |
| 42 std::string ReadLine(int chunk); | 44 std::string ReadLine(int chunk); |
| 43 | 45 |
| 44 scoped_ptr<PipeReader> reader_; | 46 scoped_ptr<PipeReader> reader_; |
| 45 | 47 |
| 46 DISALLOW_COPY_AND_ASSIGN(ExternalCookieHandler); | 48 DISALLOW_COPY_AND_ASSIGN(ExternalCookieHandler); |
| 47 }; | 49 }; |
| 48 | 50 |
| 51 } // namespace chromeos |
| 52 |
| 49 #endif // CHROME_BROWSER_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_ | 53 #endif // CHROME_BROWSER_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_ |
| OLD | NEW |