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 11e4529426f6770cc3089f3009a2799af4818ba8..18ce54ef07fe60f407dace82e45acfdab30f0e17 100644 |
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
@@ -39,6 +39,13 @@ |
#include "ui/views/layout/layout_constants.h" |
#include "ui/views/widget/widget.h" |
+#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 "components/browser_sync/profile_sync_service.h" |
+#include "ui/views/layout/fill_layout.h" |
+#endif |
+ |
using base::UserMetricsAction; |
using bookmarks::BookmarkModel; |
using bookmarks::BookmarkNode; |
@@ -118,9 +125,11 @@ BookmarkBubbleView::~BookmarkBubbleView() { |
if (node) |
model->Remove(node); |
} |
- // |parent_combobox_| needs to be destroyed before |parent_model_| as it |
- // uses |parent_model_| in its destructor. |
- delete parent_combobox_; |
+ if (!ios_promotion_viewed_) { |
+ // |parent_combobox_| needs to be destroyed before |parent_model_| as it |
+ // uses |parent_model_| in its destructor. |
+ delete parent_combobox_; |
+ } |
} |
void BookmarkBubbleView::WindowClosing() { |
@@ -222,7 +231,26 @@ void BookmarkBubbleView::Init() { |
AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN)); |
} |
+gfx::ImageSkia BookmarkBubbleView::GetWindowIcon() { |
+#if defined(OS_WIN) |
+ if (ios_promotion_viewed_) { |
+ return desktop_ios_promotion::GetPromoImage( |
+ GetNativeTheme()->GetSystemColor( |
+ ui::NativeTheme::kColorId_TextfieldDefaultColor)); |
+ } |
+#endif |
+ return gfx::ImageSkia(); |
+} |
+ |
+bool BookmarkBubbleView::ShouldShowWindowIcon() const { |
+ return ios_promotion_viewed_; |
+} |
+ |
base::string16 BookmarkBubbleView::GetWindowTitle() const { |
+ if (ios_promotion_viewed_) { |
+ return desktop_ios_promotion::GetPromoTitle( |
+ desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE); |
+ } |
return l10n_util::GetStringUTF16(newly_bookmarked_ |
? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED |
: IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK); |
@@ -269,7 +297,8 @@ BookmarkBubbleView::BookmarkBubbleView( |
title_tf_(nullptr), |
parent_combobox_(nullptr), |
remove_bookmark_(false), |
- apply_edits_(true) {} |
+ apply_edits_(true), |
+ ios_promotion_viewed_(false) {} |
base::string16 BookmarkBubbleView::GetTitle() { |
BookmarkModel* bookmark_model = |
@@ -314,10 +343,37 @@ void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { |
ShowEditor(); |
} 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, |
+ desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE)) { |
+ apply_edits_ = false; |
sky
2017/03/27 20:03:55
Why are you resetting apply_edits_?
mrefaat
2017/03/29 19:50:18
changed that
|
+ ShowIOSPromotion(); |
+ } else { |
+ GetWidget()->Close(); |
+ } |
+#else |
GetWidget()->Close(); |
+#endif |
} |
} |
+void BookmarkBubbleView::ShowIOSPromotion() { |
sky
2017/03/27 20:03:55
Make order match header.
mrefaat
2017/03/29 19:50:18
Done.
|
+ RemoveAllChildViews(true); |
sky
2017/03/27 20:03:55
Explicitly removing all the views is error prone (
mrefaat
2017/03/29 19:50:18
Done.
|
+ SetLayoutManager(new views::FillLayout); |
+ ios_promotion_viewed_ = true; |
+ ios_promo_view_ = new DesktopIOSPromotionBubbleView( |
+ profile_, desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE); |
+ AddChildView(ios_promo_view_); |
+ GetWidget()->non_client_view()->ResetWindowControls(); |
+ GetWidget()->UpdateWindowIcon(); |
+ GetWidget()->UpdateWindowTitle(); |
+ SizeToContents(); |
+} |
+ |
void BookmarkBubbleView::ShowEditor() { |
const BookmarkNode* node = |
BookmarkModelFactory::GetForBrowserContext(profile_) |