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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 BuildAndSendSyncStatus(); | 155 BuildAndSendSyncStatus(); |
156 } | 156 } |
157 | 157 |
158 void NewTabPageSyncHandler::OnSigninAllowedPrefChange() { | 158 void NewTabPageSyncHandler::OnSigninAllowedPrefChange() { |
159 // Don't do anything if the page has not yet loaded. | 159 // Don't do anything if the page has not yet loaded. |
160 if (waiting_for_initial_page_load_) | 160 if (waiting_for_initial_page_load_) |
161 return; | 161 return; |
162 BuildAndSendSyncStatus(); | 162 BuildAndSendSyncStatus(); |
163 } | 163 } |
164 | 164 |
165 void NewTabPageSyncHandler::SendSyncMessageToPage( | 165 void NewTabPageSyncHandler::SendSyncMessageToPage(MessageType type, |
166 MessageType type, std::string msg, | 166 const std::string& msg, |
167 std::string linktext) { | 167 const std::string& linktext) { |
168 base::DictionaryValue value; | 168 base::DictionaryValue value; |
169 std::string user; | 169 std::string user; |
170 std::string title; | 170 std::string title; |
171 std::string linkurl; | 171 std::string linkurl; |
172 | 172 |
173 // If there is nothing to show, we should hide the sync section altogether. | 173 // If there is nothing to show, we should hide the sync section altogether. |
174 if (type == HIDE || (msg.empty() && linktext.empty())) { | 174 if (type == HIDE || (msg.empty() && linktext.empty())) { |
175 value.SetBoolean("syncsectionisvisible", false); | 175 value.SetBoolean("syncsectionisvisible", false); |
176 } else { | 176 } else { |
177 if (type == SYNC_ERROR) | 177 if (type == SYNC_ERROR) |
(...skipping 19 matching lines...) Expand all Loading... |
197 if (linkurl.empty()) { | 197 if (linkurl.empty()) { |
198 value.SetBoolean("linkurlisset", false); | 198 value.SetBoolean("linkurlisset", false); |
199 } else { | 199 } else { |
200 value.SetBoolean("linkurlisset", true); | 200 value.SetBoolean("linkurlisset", true); |
201 value.SetString("linkurl", linkurl); | 201 value.SetString("linkurl", linkurl); |
202 } | 202 } |
203 } | 203 } |
204 } | 204 } |
205 web_ui()->CallJavascriptFunction("ntp.syncMessageChanged", value); | 205 web_ui()->CallJavascriptFunction("ntp.syncMessageChanged", value); |
206 } | 206 } |
OLD | NEW |