Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/webui/ntp/new_tab_page_sync_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 // plug in their own sync engine, we should allow this value to be | 25 // plug in their own sync engine, we should allow this value to be |
| 26 // configurable. | 26 // configurable. |
| 27 static const char kSyncDefaultViewOnlineUrl[] = "http://docs.google.com"; | 27 static const char kSyncDefaultViewOnlineUrl[] = "http://docs.google.com"; |
| 28 | 28 |
| 29 // TODO(idana): the following code was originally copied from | 29 // TODO(idana): the following code was originally copied from |
| 30 // toolbar_importer.h/cc and it needs to be moved to a common Google Accounts | 30 // toolbar_importer.h/cc and it needs to be moved to a common Google Accounts |
| 31 // utility. | 31 // utility. |
| 32 | 32 |
| 33 // A simple pair of fields that identify a set of Google cookies, used to | 33 // A simple pair of fields that identify a set of Google cookies, used to |
| 34 // filter from a larger set. | 34 // filter from a larger set. |
| 35 struct GoogleCookieFilter { | 35 // struct GoogleCookieFilter { |
|
erikwright (departed)
2011/08/19 18:13:05
I guess we will remove this since it is apparently
Randy Smith (Not in Mondays)
2011/08/19 20:54:08
Have you checked with an OWNER of (or someone who'
erikwright (departed)
2011/09/06 17:34:45
Added as a reviewer on the new CL.
| |
| 36 // The generalized, fully qualified URL of pages where | 36 // // The generalized, fully qualified URL of pages where |
| 37 // cookies with id |cookie_id| are obtained / accessed. | 37 // // cookies with id |cookie_id| are obtained / accessed. |
| 38 const char* url; | 38 // const char* url; |
| 39 // The id of the cookie this filter is selecting, | 39 // // The id of the cookie this filter is selecting, |
| 40 // with name/value delimiter (i.e '='). | 40 // // with name/value delimiter (i.e '='). |
| 41 const char* cookie_id; | 41 // const char* cookie_id; |
| 42 }; | 42 // }; |
| 43 | 43 |
| 44 // Filters to select Google GAIA cookies. | 44 // // Filters to select Google GAIA cookies. |
| 45 static const GoogleCookieFilter kGAIACookieFilters[] = { | 45 // static const GoogleCookieFilter kGAIACookieFilters[] = { |
| 46 { "http://.google.com/", "SID=" }, // Gmail. | 46 // { "http://.google.com/", "SID=" }, // Gmail. |
| 47 // Add filters here for other interesting cookies that should result in | 47 // // Add filters here for other interesting cookies that should result in |
| 48 // showing the promotions (e.g ASIDAS for dasher accounts). | 48 // // showing the promotions (e.g ASIDAS for dasher accounts). |
| 49 }; | 49 // }; |
| 50 | 50 |
| 51 bool IsGoogleGAIACookieInstalled() { | 51 // bool IsGoogleGAIACookieInstalled() { |
| 52 for (size_t i = 0; i < arraysize(kGAIACookieFilters); ++i) { | 52 // for (size_t i = 0; i < arraysize(kGAIACookieFilters); ++i) { |
| 53 // Since we are running on the UI thread don't call GetURLRequestContext(). | 53 // // Since we are running on the UI thread don't call GetURLRequestContext( ). |
| 54 net::CookieStore* store = | 54 // net::CookieStore* store = |
| 55 Profile::Deprecated::GetDefaultRequestContext()-> | 55 // Profile::Deprecated::GetDefaultRequestContext()-> |
| 56 DONTUSEME_GetCookieStore(); | 56 // DONTUSEME_GetCookieStore(); |
| 57 GURL url(kGAIACookieFilters[i].url); | 57 // GURL url(kGAIACookieFilters[i].url); |
| 58 net::CookieOptions options; | 58 // net::CookieOptions options; |
| 59 options.set_include_httponly(); // The SID cookie might be httponly. | 59 // options.set_include_httponly(); // The SID cookie might be httponly. |
| 60 std::string cookies = store->GetCookiesWithOptions(url, options); | 60 // std::string cookies = store->GetCookiesWithOptions(url, options); |
| 61 std::vector<std::string> cookie_list; | 61 // std::vector<std::string> cookie_list; |
| 62 base::SplitString(cookies, ';', &cookie_list); | 62 // base::SplitString(cookies, ';', &cookie_list); |
| 63 for (std::vector<std::string>::iterator current = cookie_list.begin(); | 63 // for (std::vector<std::string>::iterator current = cookie_list.begin(); |
| 64 current != cookie_list.end(); | 64 // current != cookie_list.end(); |
| 65 ++current) { | 65 // ++current) { |
| 66 size_t position = | 66 // size_t position = |
| 67 current->find(kGAIACookieFilters[i].cookie_id); | 67 // current->find(kGAIACookieFilters[i].cookie_id); |
| 68 if (0 == position) | 68 // if (0 == position) |
| 69 return true; | 69 // return true; |
| 70 } | 70 // } |
| 71 } | 71 // } |
| 72 return false; | 72 // return false; |
| 73 } | 73 // } |
| 74 | 74 |
| 75 NewTabPageSyncHandler::NewTabPageSyncHandler() : sync_service_(NULL), | 75 NewTabPageSyncHandler::NewTabPageSyncHandler() : sync_service_(NULL), |
| 76 waiting_for_initial_page_load_(true) { | 76 waiting_for_initial_page_load_(true) { |
| 77 } | 77 } |
| 78 | 78 |
| 79 NewTabPageSyncHandler::~NewTabPageSyncHandler() { | 79 NewTabPageSyncHandler::~NewTabPageSyncHandler() { |
| 80 if (sync_service_) | 80 if (sync_service_) |
| 81 sync_service_->RemoveObserver(this); | 81 sync_service_->RemoveObserver(this); |
| 82 } | 82 } |
| 83 | 83 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 if (linkurl.empty()) { | 212 if (linkurl.empty()) { |
| 213 value.SetBoolean("linkurlisset", false); | 213 value.SetBoolean("linkurlisset", false); |
| 214 } else { | 214 } else { |
| 215 value.SetBoolean("linkurlisset", true); | 215 value.SetBoolean("linkurlisset", true); |
| 216 value.SetString("linkurl", linkurl); | 216 value.SetString("linkurl", linkurl); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 web_ui_->CallJavascriptFunction("syncMessageChanged", value); | 220 web_ui_->CallJavascriptFunction("syncMessageChanged", value); |
| 221 } | 221 } |
| OLD | NEW |