Chromium Code Reviews| Index: chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc |
| diff --git a/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc b/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cee261cf5cf31796f6eec008ebf22edbe8a3413a |
| --- /dev/null |
| +++ b/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" |
| + |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| +#include "chrome/browser/ui/browser_list.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/browser/ui/chrome_pages.h" |
| +#include "chrome/browser/ui/sync/sync_promo_ui.h" |
| + |
| +BookmarkBubbleSignInDelegate::BookmarkBubbleSignInDelegate(Browser* browser) |
| + : browser_(browser), |
| + profile_(browser->profile()), |
| + desktop_type_(browser->host_desktop_type()) { |
| + BrowserList::AddObserver(this); |
| +} |
| + |
| +BookmarkBubbleSignInDelegate::~BookmarkBubbleSignInDelegate() { |
| + BrowserList::RemoveObserver(this); |
| +} |
| + |
| +void BookmarkBubbleSignInDelegate::OnSignInLinkClicked() { |
| + EnsureBrowser(); |
| + chrome::ShowBrowserSignin(browser_, SyncPromoUI::SOURCE_BOOKMARK_BUBBLE); |
| +} |
| + |
| +void BookmarkBubbleSignInDelegate::OnBrowserRemoved(Browser* browser) { |
| + if (browser == browser_) |
| + browser_ = NULL; |
| +} |
| + |
| +void BookmarkBubbleSignInDelegate::EnsureBrowser() { |
| + if (!browser_) { |
| + browser_ = chrome::FindLastActiveWithProfile(profile_, desktop_type_); |
| + if (!browser_) { |
| + browser_ = new Browser(Browser::CreateParams(profile_, |
|
sky
2013/07/17 21:42:54
Does this do the right thing if profile_ is OTR?
fdoray
2013/07/17 23:22:53
Done. The new code prevents the creation of 1 inco
|
| + desktop_type_)); |
| + } |
| + browser_->window()->Show(); |
| + } |
| +} |