| 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" |
| 11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/net/chrome_url_request_context.h" | 15 #include "chrome/browser/net/chrome_url_request_context.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/signin/signin_manager.h" | 18 #include "chrome/browser/signin/signin_manager.h" |
| 19 #include "chrome/browser/signin/signin_manager_factory.h" | 19 #include "chrome/browser/signin/signin_manager_factory.h" |
| 20 #include "chrome/browser/sync/profile_sync_service.h" | 20 #include "chrome/browser/sync/profile_sync_service.h" |
| 21 #include "chrome/browser/sync/profile_sync_service_factory.h" | 21 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_finder.h" |
| 24 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 24 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 25 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 25 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
| 29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 30 #include "net/cookies/cookie_monster.h" | 30 #include "net/cookies/cookie_monster.h" |
| 31 #include "net/url_request/url_request_context.h" | 31 #include "net/url_request/url_request_context.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 | 33 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 SendSyncMessageToPage(FromSyncStatusMessageType(type), | 120 SendSyncMessageToPage(FromSyncStatusMessageType(type), |
| 121 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); | 121 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) { | 124 void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) { |
| 125 DCHECK(!waiting_for_initial_page_load_); | 125 DCHECK(!waiting_for_initial_page_load_); |
| 126 DCHECK(sync_service_); | 126 DCHECK(sync_service_); |
| 127 if (!sync_service_->IsSyncEnabled()) | 127 if (!sync_service_->IsSyncEnabled()) |
| 128 return; | 128 return; |
| 129 Browser* browser = | 129 Browser* browser = |
| 130 BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 130 browser::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
| 131 if (!browser || browser->IsAttemptingToCloseBrowser()) | 131 if (!browser || browser->IsAttemptingToCloseBrowser()) |
| 132 return; | 132 return; |
| 133 browser->ShowSyncSetup(SyncPromoUI::SOURCE_NTP_LINK); | 133 browser->ShowSyncSetup(SyncPromoUI::SOURCE_NTP_LINK); |
| 134 | 134 |
| 135 if (sync_service_->HasSyncSetupCompleted()) { | 135 if (sync_service_->HasSyncSetupCompleted()) { |
| 136 string16 user = UTF8ToUTF16(SigninManagerFactory::GetForProfile( | 136 string16 user = UTF8ToUTF16(SigninManagerFactory::GetForProfile( |
| 137 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername()); | 137 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername()); |
| 138 DictionaryValue value; | 138 DictionaryValue value; |
| 139 value.SetString("syncEnabledMessage", | 139 value.SetString("syncEnabledMessage", |
| 140 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO, | 140 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 if (linkurl.empty()) { | 187 if (linkurl.empty()) { |
| 188 value.SetBoolean("linkurlisset", false); | 188 value.SetBoolean("linkurlisset", false); |
| 189 } else { | 189 } else { |
| 190 value.SetBoolean("linkurlisset", true); | 190 value.SetBoolean("linkurlisset", true); |
| 191 value.SetString("linkurl", linkurl); | 191 value.SetString("linkurl", linkurl); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 web_ui()->CallJavascriptFunction("ntp.syncMessageChanged", value); | 195 web_ui()->CallJavascriptFunction("ntp.syncMessageChanged", value); |
| 196 } | 196 } |
| OLD | NEW |