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/browser_signin.h" | 5 #include "chrome/browser/browser_signin.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
20 #include "chrome/browser/sync/sync_setup_flow.h" | 20 #include "chrome/browser/sync/sync_setup_flow.h" |
21 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 21 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
22 #include "chrome/browser/ui/webui/constrained_html_ui.h" | 22 #include "chrome/browser/ui/webui/constrained_html_ui.h" |
23 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 23 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 24 #include "chrome/common/chrome_notification_types.h" |
24 #include "chrome/common/jstemplate_builder.h" | 25 #include "chrome/common/jstemplate_builder.h" |
25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
27 #include "content/browser/browser_thread.h" | 28 #include "content/browser/browser_thread.h" |
28 #include "content/browser/renderer_host/render_view_host.h" | 29 #include "content/browser/renderer_host/render_view_host.h" |
29 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
30 #include "content/common/notification_details.h" | 31 #include "content/common/notification_details.h" |
31 #include "content/common/notification_source.h" | 32 #include "content/common/notification_source.h" |
32 #include "content/common/notification_type.h" | |
33 #include "grit/browser_resources.h" | 33 #include "grit/browser_resources.h" |
34 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
35 | 35 |
36 class BrowserSigninResourcesSource : public ChromeURLDataManager::DataSource { | 36 class BrowserSigninResourcesSource : public ChromeURLDataManager::DataSource { |
37 public: | 37 public: |
38 BrowserSigninResourcesSource() | 38 BrowserSigninResourcesSource() |
39 : DataSource(chrome::kChromeUIDialogHost, MessageLoop::current()) { | 39 : DataSource(chrome::kChromeUIDialogHost, MessageLoop::current()) { |
40 } | 40 } |
41 | 41 |
42 virtual void StartDataRequest(const std::string& path, | 42 virtual void StartDataRequest(const std::string& path, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 ShowSigninTabModal(tab_contents); | 248 ShowSigninTabModal(tab_contents); |
249 } | 249 } |
250 | 250 |
251 std::string BrowserSignin::GetSignedInUsername() const { | 251 std::string BrowserSignin::GetSignedInUsername() const { |
252 std::string username = | 252 std::string username = |
253 profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername); | 253 profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername); |
254 VLOG(1) << "GetSignedInUsername: " << username; | 254 VLOG(1) << "GetSignedInUsername: " << username; |
255 return username; | 255 return username; |
256 } | 256 } |
257 | 257 |
258 void BrowserSignin::Observe(NotificationType type, | 258 void BrowserSignin::Observe(int type, |
259 const NotificationSource& source, | 259 const NotificationSource& source, |
260 const NotificationDetails& details) { | 260 const NotificationDetails& details) { |
261 switch (type.value) { | 261 switch (type) { |
262 case NotificationType::GOOGLE_SIGNIN_SUCCESSFUL: { | 262 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { |
263 VLOG(1) << "GOOGLE_SIGNIN_SUCCESSFUL"; | 263 VLOG(1) << "GOOGLE_SIGNIN_SUCCESSFUL"; |
264 if (delegate_) | 264 if (delegate_) |
265 delegate_->OnLoginSuccess(); | 265 delegate_->OnLoginSuccess(); |
266 // Close the dialog. | 266 // Close the dialog. |
267 OnLoginFinished(); | 267 OnLoginFinished(); |
268 break; | 268 break; |
269 } | 269 } |
270 case NotificationType::GOOGLE_SIGNIN_FAILED: { | 270 case chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED: { |
271 VLOG(1) << "GOOGLE_SIGNIN_FAILED"; | 271 VLOG(1) << "GOOGLE_SIGNIN_FAILED"; |
272 // The signin failed, refresh the UI with error information. | 272 // The signin failed, refresh the UI with error information. |
273 html_dialog_ui_delegate_->ReloadUI(); | 273 html_dialog_ui_delegate_->ReloadUI(); |
274 break; | 274 break; |
275 } | 275 } |
276 default: | 276 default: |
277 NOTREACHED(); | 277 NOTREACHED(); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
(...skipping 22 matching lines...) Expand all Loading... |
303 ProfileSyncService* BrowserSignin::GetProfileSyncService() const { | 303 ProfileSyncService* BrowserSignin::GetProfileSyncService() const { |
304 return profile_->GetProfileSyncService(); | 304 return profile_->GetProfileSyncService(); |
305 } | 305 } |
306 | 306 |
307 BrowserSigninHtml* BrowserSignin::CreateHtmlDialogUI() { | 307 BrowserSigninHtml* BrowserSignin::CreateHtmlDialogUI() { |
308 return new BrowserSigninHtml(this, suggested_email_, login_message_); | 308 return new BrowserSigninHtml(this, suggested_email_, login_message_); |
309 } | 309 } |
310 | 310 |
311 void BrowserSignin::RegisterAuthNotifications() { | 311 void BrowserSignin::RegisterAuthNotifications() { |
312 registrar_.Add(this, | 312 registrar_.Add(this, |
313 NotificationType::GOOGLE_SIGNIN_SUCCESSFUL, | 313 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
314 Source<Profile>(profile_)); | 314 Source<Profile>(profile_)); |
315 registrar_.Add(this, | 315 registrar_.Add(this, |
316 NotificationType::GOOGLE_SIGNIN_FAILED, | 316 chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, |
317 Source<Profile>(profile_)); | 317 Source<Profile>(profile_)); |
318 } | 318 } |
319 | 319 |
320 void BrowserSignin::UnregisterAuthNotifications() { | 320 void BrowserSignin::UnregisterAuthNotifications() { |
321 registrar_.Remove(this, | 321 registrar_.Remove(this, |
322 NotificationType::GOOGLE_SIGNIN_SUCCESSFUL, | 322 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
323 Source<Profile>(profile_)); | 323 Source<Profile>(profile_)); |
324 registrar_.Remove(this, | 324 registrar_.Remove(this, |
325 NotificationType::GOOGLE_SIGNIN_FAILED, | 325 chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, |
326 Source<Profile>(profile_)); | 326 Source<Profile>(profile_)); |
327 } | 327 } |
328 | 328 |
329 void BrowserSignin::ShowSigninTabModal(TabContents* tab_contents) { | 329 void BrowserSignin::ShowSigninTabModal(TabContents* tab_contents) { |
330 // TODO(johnnyg): Need a linux views implementation for ConstrainedHtmlDialog. | 330 // TODO(johnnyg): Need a linux views implementation for ConstrainedHtmlDialog. |
331 #if defined(OS_WIN) || defined(OS_CHROMEOS) || !defined(TOOLKIT_VIEWS) | 331 #if defined(OS_WIN) || defined(OS_CHROMEOS) || !defined(TOOLKIT_VIEWS) |
332 html_dialog_ui_delegate_ = CreateHtmlDialogUI(); | 332 html_dialog_ui_delegate_ = CreateHtmlDialogUI(); |
333 ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile_, | 333 ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile_, |
334 html_dialog_ui_delegate_, | 334 html_dialog_ui_delegate_, |
335 tab_contents); | 335 tab_contents); |
336 #endif | 336 #endif |
337 } | 337 } |
OLD | NEW |