Index: chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
index bb12026e436057ea5504ac4343fcdc0df5dc8e5b..f350ae2906d3a287dccc26d537c7f2dbf659c54f 100644 |
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
@@ -43,6 +43,7 @@ |
#if defined(OS_WIN) |
#include "chrome/browser/sync/profile_sync_service_factory.h" |
#include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.h" |
+#include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_footnote_view.h" |
#include "components/browser_sync/profile_sync_service.h" |
#endif |
@@ -135,6 +136,7 @@ void BookmarkBubbleView::WindowClosing() { |
// destroyed asynchronously and the shown state will be checked before then. |
DCHECK_EQ(bookmark_bubble_, this); |
bookmark_bubble_ = NULL; |
+ is_showing_ios_promotion_ = false; |
if (observer_) |
observer_->OnBookmarkBubbleHidden(); |
@@ -269,14 +271,23 @@ views::View* BookmarkBubbleView::GetInitiallyFocusedView() { |
} |
views::View* BookmarkBubbleView::CreateFootnoteView() { |
+ if (!is_showing_ios_promotion_ && |
+ IsIOSPromotionEligible( |
+ desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_FOOTNOTE)) { |
+ footnote_view_ = new DesktopIOSPromotionFootnoteView(profile_, this); |
+ return footnote_view_; |
+ } |
+ |
if (!SyncPromoUI::ShouldShowSyncPromo(profile_)) |
return nullptr; |
base::RecordAction( |
base::UserMetricsAction("Signin_Impression_FromBookmarkBubble")); |
- return new BubbleSyncPromoView(delegate_.get(), IDS_BOOKMARK_SYNC_PROMO_LINK, |
- IDS_BOOKMARK_SYNC_PROMO_MESSAGE); |
+ footnote_view_ = |
+ new BubbleSyncPromoView(delegate_.get(), IDS_BOOKMARK_SYNC_PROMO_LINK, |
+ IDS_BOOKMARK_SYNC_PROMO_MESSAGE); |
+ return footnote_view_; |
} |
BookmarkBubbleView::BookmarkBubbleView( |
@@ -301,6 +312,7 @@ BookmarkBubbleView::BookmarkBubbleView( |
title_tf_(nullptr), |
parent_combobox_(nullptr), |
ios_promo_view_(nullptr), |
+ footnote_view_(nullptr), |
remove_bookmark_(false), |
apply_edits_(true), |
is_showing_ios_promotion_(false) { |
@@ -351,13 +363,10 @@ void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { |
} else { |
DCHECK_EQ(close_button_, sender); |
#if defined(OS_WIN) |
- PrefService* prefs = profile_->GetPrefs(); |
- const browser_sync::ProfileSyncService* sync_service = |
- ProfileSyncServiceFactory::GetForProfile(profile_); |
- if (desktop_ios_promotion::IsEligibleForIOSPromotion( |
- prefs, sync_service, |
+ if (IsIOSPromotionEligible( |
desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE)) { |
- ShowIOSPromotion(); |
+ ShowIOSPromotion( |
+ desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE); |
} else { |
GetWidget()->Close(); |
} |
@@ -403,13 +412,35 @@ void BookmarkBubbleView::ApplyEdits() { |
} |
} |
+void BookmarkBubbleView::OnIOSPromotionFootnoteLinkClicked() { |
+#if defined(OS_WIN) |
+ ShowIOSPromotion( |
+ desktop_ios_promotion::PromotionEntryPoint::FOOTNOTE_FOLLOWUP_BUBBLE); |
+#endif |
+} |
+ |
#if defined(OS_WIN) |
-void BookmarkBubbleView::ShowIOSPromotion() { |
+ |
+bool BookmarkBubbleView::IsIOSPromotionEligible( |
+ desktop_ios_promotion::PromotionEntryPoint entry_point) { |
+ PrefService* prefs = profile_->GetPrefs(); |
+ const browser_sync::ProfileSyncService* sync_service = |
+ ProfileSyncServiceFactory::GetForProfile(profile_); |
+ return desktop_ios_promotion::IsEligibleForIOSPromotion(prefs, sync_service, |
+ entry_point); |
+} |
+ |
+void BookmarkBubbleView::ShowIOSPromotion( |
+ desktop_ios_promotion::PromotionEntryPoint entry_point) { |
DCHECK(!is_showing_ios_promotion_); |
RemoveChildView(bookmark_details_view_.get()); |
+ if (footnote_view_) { |
sky
2017/05/24 00:03:35
You don't actually need this conditional (delete n
mrefaat1
2017/05/24 02:27:17
Done.
|
+ delete footnote_view_; |
+ footnote_view_ = nullptr; |
+ } |
+ |
is_showing_ios_promotion_ = true; |
- ios_promo_view_ = new DesktopIOSPromotionBubbleView( |
- profile_, desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE); |
+ ios_promo_view_ = new DesktopIOSPromotionBubbleView(profile_, entry_point); |
AddChildView(ios_promo_view_); |
GetWidget()->UpdateWindowIcon(); |
GetWidget()->UpdateWindowTitle(); |