| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/inline_login_ui.h" | 5 #include "chrome/browser/ui/webui/inline_login_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/signin/token_service.h" | 13 #include "chrome/browser/signin/token_service.h" |
| 14 #include "chrome/browser/signin/token_service_factory.h" | 14 #include "chrome/browser/signin/token_service_factory.h" |
| 15 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 15 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
| 16 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
| 16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 17 #include "content/public/browser/web_ui.h" | 18 #include "content/public/browser/web_ui.h" |
| 18 #include "content/public/browser/web_ui_data_source.h" | 19 #include "content/public/browser/web_ui_data_source.h" |
| 19 #include "content/public/browser/web_ui_message_handler.h" | 20 #include "content/public/browser/web_ui_message_handler.h" |
| 20 #include "google_apis/gaia/gaia_switches.h" | 21 #include "google_apis/gaia/gaia_switches.h" |
| 21 #include "google_apis/gaia/gaia_urls.h" | 22 #include "google_apis/gaia/gaia_urls.h" |
| 22 #include "grit/browser_resources.h" | 23 #include "grit/browser_resources.h" |
| 23 | 24 |
| 24 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
| 25 #include "chrome/browser/chromeos/login/oauth2_token_fetcher.h" | 26 #include "chrome/browser/chromeos/login/oauth2_token_fetcher.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 125 |
| 125 // Call OneClickSigninSyncStarter to exchange cookies for oauth tokens. | 126 // Call OneClickSigninSyncStarter to exchange cookies for oauth tokens. |
| 126 // OneClickSigninSyncStarter will delete itself once the job is done. | 127 // OneClickSigninSyncStarter will delete itself once the job is done. |
| 127 // TODO(guohui): should collect from user whether they want to use | 128 // TODO(guohui): should collect from user whether they want to use |
| 128 // default sync settings or configure first. | 129 // default sync settings or configure first. |
| 129 new OneClickSigninSyncStarter( | 130 new OneClickSigninSyncStarter( |
| 130 profile_, NULL, "0" /* session_index 0 for the default user */, | 131 profile_, NULL, "0" /* session_index 0 for the default user */, |
| 131 UTF16ToASCII(email), UTF16ToASCII(password), | 132 UTF16ToASCII(email), UTF16ToASCII(password), |
| 132 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, | 133 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, |
| 133 true /* force_same_tab_navigation */, | 134 true /* force_same_tab_navigation */, |
| 134 OneClickSigninSyncStarter::NO_CONFIRMATION); | 135 OneClickSigninSyncStarter::NO_CONFIRMATION, |
| 136 SyncPromoUI::SOURCE_UNKNOWN); |
| 135 web_ui()->CallJavascriptFunction("inline.login.closeDialog"); | 137 web_ui()->CallJavascriptFunction("inline.login.closeDialog"); |
| 136 #endif | 138 #endif |
| 137 } | 139 } |
| 138 | 140 |
| 139 Profile* profile_; | 141 Profile* profile_; |
| 140 #if defined(OS_CHROMEOS) | 142 #if defined(OS_CHROMEOS) |
| 141 scoped_ptr<chromeos::OAuth2TokenFetcher> oauth2_token_fetcher_; | 143 scoped_ptr<chromeos::OAuth2TokenFetcher> oauth2_token_fetcher_; |
| 142 scoped_ptr<InlineLoginUIOAuth2Delegate> oauth2_delegate_; | 144 scoped_ptr<InlineLoginUIOAuth2Delegate> oauth2_delegate_; |
| 143 #endif | 145 #endif |
| 144 | 146 |
| 145 DISALLOW_COPY_AND_ASSIGN(InlineLoginUIHandler); | 147 DISALLOW_COPY_AND_ASSIGN(InlineLoginUIHandler); |
| 146 }; | 148 }; |
| 147 | 149 |
| 148 } // namespace | 150 } // namespace |
| 149 | 151 |
| 150 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) | 152 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) |
| 151 : WebDialogUI(web_ui), | 153 : WebDialogUI(web_ui), |
| 152 auth_extension_(Profile::FromWebUI(web_ui)) { | 154 auth_extension_(Profile::FromWebUI(web_ui)) { |
| 153 Profile* profile = Profile::FromWebUI(web_ui); | 155 Profile* profile = Profile::FromWebUI(web_ui); |
| 154 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); | 156 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); |
| 155 | 157 |
| 156 web_ui->AddMessageHandler(new InlineLoginUIHandler(profile)); | 158 web_ui->AddMessageHandler(new InlineLoginUIHandler(profile)); |
| 157 } | 159 } |
| 158 | 160 |
| 159 InlineLoginUI::~InlineLoginUI() {} | 161 InlineLoginUI::~InlineLoginUI() {} |
| OLD | NEW |