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 ca52a4507855165aeda92a43ae2258eb3510d169..deae199c85f7d98d82e52a4484b3649cc4d3c721 100644 |
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
| +#include "base/command_line.h" |
| #include "base/strings/string16.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -14,8 +15,12 @@ |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| #include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| #include "chrome/browser/ui/browser_list.h" |
| +#include "chrome/browser/ui/sync/sync_promo_ui.h" |
| #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view_observer.h" |
| +#include "chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "content/public/browser/user_metrics.h" |
| #include "grit/generated_resources.h" |
| #include "grit/theme_resources.h" |
| @@ -41,6 +46,15 @@ namespace { |
| // Minimum width of the the bubble. |
| const int kMinBubbleWidth = 350; |
| +// Top padding of the bubble. |
| +const int kBubbleTopPadding = 12; |
| + |
| +// Horizontal and bottom padding of the bubble. |
| +const int kBubblePadding = 19; |
| + |
| +// Width of the border of a button or text field. |
| +const int kControlBorderWidth = 1; |
| + |
| } // namespace |
| // Declared in browser_dialogs.h so callers don't have to depend on our header. |
| @@ -123,7 +137,7 @@ void BookmarkBubbleView::WindowClosing() { |
| if (observer_) |
| observer_->OnBookmarkBubbleHidden(); |
| - } |
| +} |
| bool BookmarkBubbleView::AcceleratorPressed( |
| const ui::Accelerator& accelerator) { |
| @@ -174,12 +188,15 @@ void BookmarkBubbleView::Init() { |
| const int kTitleColumnSetID = 0; |
| ColumnSet* cs = layout->AddColumnSet(kTitleColumnSetID); |
| + cs->AddPaddingColumn(0, kBubblePadding); |
| cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::USE_PREF, |
| 0, 0); |
| + cs->AddPaddingColumn(0, kBubblePadding); |
| // The column layout used for middle and bottom rows. |
| const int kFirstColumnSetID = 1; |
| cs = layout->AddColumnSet(kFirstColumnSetID); |
| + cs->AddPaddingColumn(0, kBubblePadding); |
| cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
| GridLayout::USE_PREF, 0, 0); |
| cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); |
| @@ -193,6 +210,7 @@ void BookmarkBubbleView::Init() { |
| cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); |
| cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0, |
| GridLayout::USE_PREF, 0, 0); |
| + cs->AddPaddingColumn(0, kBubblePadding - kControlBorderWidth); |
| layout->StartRow(0, kTitleColumnSetID); |
| layout->AddView(title_label); |
| @@ -220,6 +238,30 @@ void BookmarkBubbleView::Init() { |
| layout->AddView(edit_button_); |
| layout->AddView(close_button_); |
| + layout->AddPaddingRow(0, kBubblePadding - kControlBorderWidth); |
| + |
| + const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + if (command_line->HasSwitch(switches::kEnableBookmarkSyncPromo) && |
| + SyncPromoUI::ShouldShowSyncPromo(profile_)) { |
| + // The column layout used for the sync promo. |
| + const int kSyncPromoColumnSetID = 2; |
|
Roger Tawa OOO till Jul 10th
2013/07/11 15:28:30
Would it be better to put the three constants in a
fdoray
2013/07/11 19:00:40
Done.
|
| + cs = layout->AddColumnSet(kSyncPromoColumnSetID); |
| + cs->AddColumn(GridLayout::FILL, |
| + GridLayout::FILL, |
| + 1, |
| + GridLayout::USE_PREF, |
| + 0, |
| + 0); |
| + |
| + Browser* browser = chrome::FindBrowserWithProfile( |
| + profile_, |
| + chrome::HOST_DESKTOP_TYPE_NATIVE); |
| + sync_promo_view_ = new BookmarkSyncPromoView(browser); |
| + |
| + layout->StartRow(0, kSyncPromoColumnSetID); |
| + layout->AddView(sync_promo_view_); |
| + } |
| + |
| AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
| } |
| @@ -242,13 +284,14 @@ BookmarkBubbleView::BookmarkBubbleView(views::View* anchor_view, |
| close_button_(NULL), |
| title_tf_(NULL), |
| parent_combobox_(NULL), |
| + sync_promo_view_(NULL), |
| remove_bookmark_(false), |
| apply_edits_(true) { |
| const SkColor background_color = GetNativeTheme()->GetSystemColor( |
| ui::NativeTheme::kColorId_DialogBackground); |
| set_color(background_color); |
| set_background(views::Background::CreateSolidBackground(background_color)); |
| - set_margins(gfx::Insets(12, 19, 18, 18)); |
| + set_margins(gfx::Insets(kBubbleTopPadding, 0, 0, 0)); |
| // Compensate for built-in vertical padding in the anchor view's image. |
| set_anchor_view_insets(gfx::Insets(7, 0, 7, 0)); |
| } |