Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2803)

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc

Issue 2781553003: Integrate Desktop iOS promotion with bookmarks. (Closed)
Patch Set: address comments 3 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 49617312ca41df86300bae0cb5a93f208ed5d8ad..0e8c261e3a902436d472a5d049443203c147a18e 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
@@ -35,10 +35,17 @@
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h"
#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"
+#endif
+
using base::UserMetricsAction;
using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode;
@@ -171,8 +178,10 @@ void BookmarkBubbleView::Init() {
parent_combobox_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_BUBBLE_FOLDER_TEXT));
- GridLayout* layout = new GridLayout(this);
- SetLayoutManager(layout);
+ SetLayoutManager(new views::FillLayout);
+ bookmark_details_view_ = base::MakeUnique<View>();
+ GridLayout* layout = new GridLayout(bookmark_details_view_.get());
+ bookmark_details_view_->SetLayoutManager(layout);
// This column set is used for the labels and textfields as well as the
// buttons at the bottom.
@@ -220,9 +229,32 @@ void BookmarkBubbleView::Init() {
AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE));
AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN));
AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN));
+
+ AddChildView(bookmark_details_view_.get());
+}
+
+gfx::ImageSkia BookmarkBubbleView::GetWindowIcon() {
+#if defined(OS_WIN)
+ if (is_showing_ios_promotion_) {
+ return desktop_ios_promotion::GetPromoImage(
+ GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_TextfieldDefaultColor));
+ }
+#endif
+ return gfx::ImageSkia();
+}
+
+bool BookmarkBubbleView::ShouldShowWindowIcon() const {
+ return is_showing_ios_promotion_;
}
base::string16 BookmarkBubbleView::GetWindowTitle() const {
+#if defined(OS_WIN)
+ if (is_showing_ios_promotion_) {
+ return desktop_ios_promotion::GetPromoTitle(
+ desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE);
+ }
+#endif
return l10n_util::GetStringUTF16(newly_bookmarked_
? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED
: IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK);
@@ -268,8 +300,10 @@ BookmarkBubbleView::BookmarkBubbleView(
close_button_(nullptr),
title_tf_(nullptr),
parent_combobox_(nullptr),
+ ios_promo_view_(nullptr),
remove_bookmark_(false),
- apply_edits_(true) {}
+ apply_edits_(true),
+ is_showing_ios_promotion_(false) {}
base::string16 BookmarkBubbleView::GetTitle() {
BookmarkModel* bookmark_model =
@@ -314,7 +348,20 @@ 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)) {
+ ShowIOSPromotion();
+ } else {
+ GetWidget()->Close();
+ }
+#else
GetWidget()->Close();
+#endif
}
}
@@ -353,3 +400,17 @@ void BookmarkBubbleView::ApplyEdits() {
parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index());
}
}
+
+#if defined(OS_WIN)
+void BookmarkBubbleView::ShowIOSPromotion() {
+ DCHECK(!is_showing_ios_promotion_);
+ RemoveChildView(bookmark_details_view_.get());
+ is_showing_ios_promotion_ = true;
+ ios_promo_view_ = new DesktopIOSPromotionBubbleView(
+ profile_, desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE);
+ AddChildView(ios_promo_view_);
+ GetWidget()->UpdateWindowIcon();
+ GetWidget()->UpdateWindowTitle();
+ SizeToContents();
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698