Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/browser.h" | |
| 8 #include "chrome/browser/ui/browser_finder.h" | |
| 9 #include "chrome/browser/ui/browser_list.h" | |
| 10 #include "chrome/browser/ui/browser_window.h" | |
| 11 #include "chrome/browser/ui/chrome_pages.h" | |
| 12 #include "chrome/browser/ui/sync/sync_promo_ui.h" | |
| 13 | |
| 14 BookmarkBubbleSignInDelegate::BookmarkBubbleSignInDelegate(Browser* browser) | |
| 15 : browser_(browser), | |
| 16 profile_(browser->profile()), | |
| 17 desktop_type_(browser->host_desktop_type()) { | |
| 18 BrowserList::AddObserver(this); | |
| 19 } | |
| 20 | |
| 21 BookmarkBubbleSignInDelegate::~BookmarkBubbleSignInDelegate() { | |
| 22 BrowserList::RemoveObserver(this); | |
| 23 } | |
| 24 | |
| 25 void BookmarkBubbleSignInDelegate::OnSignInLinkClicked() { | |
| 26 EnsureBrowser(); | |
| 27 chrome::ShowBrowserSignin(browser_, SyncPromoUI::SOURCE_BOOKMARK_BUBBLE); | |
| 28 } | |
| 29 | |
| 30 void BookmarkBubbleSignInDelegate::OnBrowserRemoved(Browser* browser) { | |
| 31 if (browser == browser_) | |
| 32 browser_ = NULL; | |
| 33 } | |
| 34 | |
| 35 void BookmarkBubbleSignInDelegate::EnsureBrowser() { | |
| 36 if (!browser_) { | |
| 37 Profile* original_profile = profile_->GetOriginalProfile(); | |
| 38 browser_ = chrome::FindLastActiveWithProfile(original_profile, | |
| 39 desktop_type_); | |
| 40 if (!browser_) { | |
| 41 browser_ = new Browser(Browser::CreateParams(original_profile, | |
| 42 desktop_type_)); | |
| 43 } | |
| 44 browser_->window()->Show(); | |
|
sky
2013/07/18 16:08:42
DCHECK(tabstrip not empty?)
fdoray
2013/07/18 18:49:12
The tab strip of a newly created browser IS empty.
sky
2013/07/19 00:02:32
Yes, sorry, DCHECK after ShowBrowserSignin.
| |
| 45 } | |
| 46 } | |
| OLD | NEW |