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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 case sync_ui_util::SYNC_PROMO: | 91 case sync_ui_util::SYNC_PROMO: |
92 return SYNC_PROMO; | 92 return SYNC_PROMO; |
93 case sync_ui_util::PRE_SYNCED: | 93 case sync_ui_util::PRE_SYNCED: |
94 case sync_ui_util::SYNCED: | 94 case sync_ui_util::SYNCED: |
95 default: | 95 default: |
96 return HIDE; | 96 return HIDE; |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 WebUIMessageHandler* NewTabPageSyncHandler::Attach(WebUI* web_ui) { | 100 WebUIMessageHandler* NewTabPageSyncHandler::Attach(WebUI* web_ui) { |
101 sync_service_ = web_ui->GetProfile()->GetProfileSyncService(); | 101 sync_service_ = Profile::FromWebUI(web_ui)->GetProfileSyncService(); |
102 DCHECK(sync_service_); // This shouldn't get called by an incognito NTP. | 102 DCHECK(sync_service_); // This shouldn't get called by an incognito NTP. |
103 DCHECK(!sync_service_->IsManaged()); // And neither if sync is managed. | 103 DCHECK(!sync_service_->IsManaged()); // And neither if sync is managed. |
104 sync_service_->AddObserver(this); | 104 sync_service_->AddObserver(this); |
105 return WebUIMessageHandler::Attach(web_ui); | 105 return WebUIMessageHandler::Attach(web_ui); |
106 } | 106 } |
107 | 107 |
108 void NewTabPageSyncHandler::RegisterMessages() { | 108 void NewTabPageSyncHandler::RegisterMessages() { |
109 web_ui_->RegisterMessageCallback("GetSyncMessage", | 109 web_ui_->RegisterMessageCallback("GetSyncMessage", |
110 NewCallback(this, &NewTabPageSyncHandler::HandleGetSyncMessage)); | 110 NewCallback(this, &NewTabPageSyncHandler::HandleGetSyncMessage)); |
111 web_ui_->RegisterMessageCallback("SyncLinkClicked", | 111 web_ui_->RegisterMessageCallback("SyncLinkClicked", |
(...skipping 100 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 |