Chromium Code Reviews| 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..91890680164714b78dd7594fbc0225d0961b4803 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; |
| @@ -60,7 +67,6 @@ class UnsizedCombobox : public views::Combobox { |
| private: |
| DISALLOW_COPY_AND_ASSIGN(UnsizedCombobox); |
| }; |
| - |
| } // namespace |
| BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; |
| @@ -171,8 +177,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_.reset(new View); |
|
sky
2017/03/30 20:30:17
Use base::MakeUnique (search for threads on chromi
mrefaat
2017/03/30 20:46:51
Done.
|
| + 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 +228,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 +299,11 @@ BookmarkBubbleView::BookmarkBubbleView( |
| close_button_(nullptr), |
| title_tf_(nullptr), |
| parent_combobox_(nullptr), |
| + bookmark_details_view_(nullptr), |
|
sky
2017/03/30 20:30:17
Remove this as bookmark_details_view_ is now a uni
mrefaat
2017/03/30 20:46:51
Done.
|
| + 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() { |
| + RemoveChildView(bookmark_details_view_.get()); |
|
sky
2017/03/30 20:30:17
DCHECK(!is_showing_ios_promotion_)
mrefaat
2017/03/30 20:46:51
Done.
|
| + is_showing_ios_promotion_ = true; |
| + ios_promo_view_ = new DesktopIOSPromotionBubbleView( |
| + profile_, desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE); |
| + AddChildView(ios_promo_view_); |
| + GetWidget()->non_client_view()->ResetWindowControls(); |
|
sky
2017/03/30 20:30:17
Why do you need the ResetWindowControls()?
mrefaat
2017/03/30 20:46:51
i thought because is use the control (Done) and th
|
| + GetWidget()->UpdateWindowIcon(); |
| + GetWidget()->UpdateWindowTitle(); |
| + SizeToContents(); |
| +} |
| +#endif |