summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/app_notify_channel_ui.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/app_notify_channel_ui.cc')
-rw-r--r--chrome/browser/extensions/app_notify_channel_ui.cc39
1 files changed, 24 insertions, 15 deletions
diff --git a/chrome/browser/extensions/app_notify_channel_ui.cc b/chrome/browser/extensions/app_notify_channel_ui.cc
index e561bcb..ba8ffbb 100644
--- a/chrome/browser/extensions/app_notify_channel_ui.cc
+++ b/chrome/browser/extensions/app_notify_channel_ui.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
-#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
@@ -85,11 +84,18 @@ void AppNotifyChannelUIImpl::InfoBar::InfoBarDismissed() {
}
-AppNotifyChannelUIImpl::AppNotifyChannelUIImpl(Browser* browser,
- TabContentsWrapper* wrapper,
- const std::string& app_name)
- : browser_(browser), wrapper_(wrapper), app_name_(app_name),
- delegate_(NULL), observing_sync_(false), wizard_shown_to_user_(false) {
+AppNotifyChannelUIImpl::AppNotifyChannelUIImpl(
+ Profile* profile,
+ TabContentsWrapper* wrapper,
+ const std::string& app_name,
+ AppNotifyChannelUI::UIType ui_type)
+ : profile_(profile->GetOriginalProfile()),
+ wrapper_(wrapper),
+ app_name_(app_name),
+ ui_type_(ui_type),
+ delegate_(NULL),
+ observing_sync_(false),
+ wizard_shown_to_user_(false) {
}
AppNotifyChannelUIImpl::~AppNotifyChannelUIImpl() {
@@ -104,11 +110,16 @@ void AppNotifyChannelUIImpl::PromptSyncSetup(
delegate_ = delegate;
if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
- browser_->profile()->GetOriginalProfile())) {
+ profile_)) {
delegate_->OnSyncSetupResult(false);
return;
}
+ if (ui_type_ == NO_INFOBAR) {
+ OnInfoBarResult(true);
+ return;
+ }
+
InfoBarTabHelper* helper = wrapper_->infobar_tab_helper();
helper->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar(
this, helper, app_name_));
@@ -117,8 +128,7 @@ void AppNotifyChannelUIImpl::PromptSyncSetup(
void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) {
if (accepted) {
StartObservingSync();
- LoginUIServiceFactory::GetForProfile(
- browser_->profile()->GetOriginalProfile())->ShowLoginUI(true);
+ LoginUIServiceFactory::GetForProfile(profile_)->ShowLoginUI(true);
} else {
delegate_->OnSyncSetupResult(false);
}
@@ -126,10 +136,9 @@ void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) {
void AppNotifyChannelUIImpl::OnStateChanged() {
ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- browser_->profile()->GetOriginalProfile());
- LoginUIService* login_service = LoginUIServiceFactory::GetForProfile(
- browser_->profile()->GetOriginalProfile());
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
+ LoginUIService* login_service =
+ LoginUIServiceFactory::GetForProfile(profile_);
bool wizard_visible = (login_service->current_login_ui() != NULL);
// ProfileSyncService raises OnStateChanged many times. Even multiple
@@ -150,12 +159,12 @@ void AppNotifyChannelUIImpl::StartObservingSync() {
CHECK(!observing_sync_);
observing_sync_ = true;
ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- browser_->profile()->GetOriginalProfile())->AddObserver(this);
+ profile_)->AddObserver(this);
}
void AppNotifyChannelUIImpl::StopObservingSync() {
CHECK(observing_sync_);
observing_sync_ = false;
ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- browser_->profile()->GetOriginalProfile())->RemoveObserver(this);
+ profile_)->RemoveObserver(this);
}