| 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/extensions/app_notify_channel_ui.h" | 5 #include "chrome/browser/extensions/app_notify_channel_ui.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/infobars/infobar_tab_helper.h" | 8 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/sync/profile_sync_service.h" | 10 #include "chrome/browser/sync/profile_sync_service.h" |
| 11 #include "chrome/browser/sync/profile_sync_service_factory.h" | 11 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 12 #include "chrome/browser/sync/sync_setup_wizard.h" | 12 #include "chrome/browser/sync/sync_setup_wizard.h" |
| 13 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 13 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 16 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 17 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 16 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 17 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 20 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 22 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 24 | 26 |
| 25 class AppNotifyChannelUIImpl::InfoBar : public ConfirmInfoBarDelegate { | 27 class AppNotifyChannelUIImpl::InfoBar : public ConfirmInfoBarDelegate { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 111 } |
| 110 | 112 |
| 111 InfoBarTabHelper* helper = wrapper_->infobar_tab_helper(); | 113 InfoBarTabHelper* helper = wrapper_->infobar_tab_helper(); |
| 112 helper->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar( | 114 helper->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar( |
| 113 this, helper, app_name_)); | 115 this, helper, app_name_)); |
| 114 } | 116 } |
| 115 | 117 |
| 116 void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { | 118 void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { |
| 117 if (accepted) { | 119 if (accepted) { |
| 118 StartObservingSync(); | 120 StartObservingSync(); |
| 119 ProfileSyncService* service = | 121 LoginUIServiceFactory::GetForProfile( |
| 120 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 122 browser_->profile()->GetOriginalProfile())->ShowLoginUI(); |
| 121 browser_->profile()->GetOriginalProfile()); | |
| 122 service->ShowLoginDialog(); | |
| 123 } else { | 123 } else { |
| 124 delegate_->OnSyncSetupResult(false); | 124 delegate_->OnSyncSetupResult(false); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 void AppNotifyChannelUIImpl::OnStateChanged() { | 128 void AppNotifyChannelUIImpl::OnStateChanged() { |
| 129 ProfileSyncService* sync_service = | 129 ProfileSyncService* sync_service = |
| 130 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 130 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 131 browser_->profile()->GetOriginalProfile()); | 131 browser_->profile()->GetOriginalProfile()); |
| 132 bool wizard_visible = sync_service->WizardIsVisible(); | 132 bool wizard_visible = sync_service->WizardIsVisible(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 150 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 150 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 151 browser_->profile()->GetOriginalProfile())->AddObserver(this); | 151 browser_->profile()->GetOriginalProfile())->AddObserver(this); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void AppNotifyChannelUIImpl::StopObservingSync() { | 154 void AppNotifyChannelUIImpl::StopObservingSync() { |
| 155 CHECK(observing_sync_); | 155 CHECK(observing_sync_); |
| 156 observing_sync_ = false; | 156 observing_sync_ = false; |
| 157 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 157 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 158 browser_->profile()->GetOriginalProfile())->RemoveObserver(this); | 158 browser_->profile()->GetOriginalProfile())->RemoveObserver(this); |
| 159 } | 159 } |
| OLD | NEW |