| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Once sync has been enabled, the supported "sync statuses" for the NNTP | 104 // Once sync has been enabled, the supported "sync statuses" for the NNTP |
| 105 // from the user's perspective are: | 105 // from the user's perspective are: |
| 106 // | 106 // |
| 107 // "Sync error", when we can't authenticate or establish a connection with | 107 // "Sync error", when we can't authenticate or establish a connection with |
| 108 // the sync server (appropriate information appended to | 108 // the sync server (appropriate information appended to |
| 109 // message). | 109 // message). |
| 110 string16 status_msg; | 110 string16 status_msg; |
| 111 string16 link_text; | 111 string16 link_text; |
| 112 SigninManager* signin = SigninManagerFactory::GetForProfile( |
| 113 Profile::FromWebUI(web_ui())); |
| 114 |
| 112 sync_ui_util::MessageType type = | 115 sync_ui_util::MessageType type = |
| 113 sync_ui_util::GetStatusLabelsForNewTabPage(sync_service_, | 116 sync_ui_util::GetStatusLabelsForNewTabPage(sync_service_, |
| 117 *signin, |
| 114 &status_msg, | 118 &status_msg, |
| 115 &link_text); | 119 &link_text); |
| 116 SendSyncMessageToPage(FromSyncStatusMessageType(type), | 120 SendSyncMessageToPage(FromSyncStatusMessageType(type), |
| 117 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); | 121 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); |
| 118 } | 122 } |
| 119 | 123 |
| 120 void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) { | 124 void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) { |
| 121 DCHECK(!waiting_for_initial_page_load_); | 125 DCHECK(!waiting_for_initial_page_load_); |
| 122 DCHECK(sync_service_); | 126 DCHECK(sync_service_); |
| 123 if (!sync_service_->IsSyncEnabled()) | 127 if (!sync_service_->IsSyncEnabled()) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 if (linkurl.empty()) { | 187 if (linkurl.empty()) { |
| 184 value.SetBoolean("linkurlisset", false); | 188 value.SetBoolean("linkurlisset", false); |
| 185 } else { | 189 } else { |
| 186 value.SetBoolean("linkurlisset", true); | 190 value.SetBoolean("linkurlisset", true); |
| 187 value.SetString("linkurl", linkurl); | 191 value.SetString("linkurl", linkurl); |
| 188 } | 192 } |
| 189 } | 193 } |
| 190 } | 194 } |
| 191 web_ui()->CallJavascriptFunction("ntp.syncMessageChanged", value); | 195 web_ui()->CallJavascriptFunction("ntp.syncMessageChanged", value); |
| 192 } | 196 } |
| OLD | NEW |