Chromium Code Reviews| Index: chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.cc |
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7fa7c2c1cb4835b07ceecee9b81cb8e6ea8fc5ef |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.cc |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.h" |
| + |
| +#include "base/strings/string16.h" |
| +#include "chrome/browser/ui/chrome_pages.h" |
| +#include "grit/generated_resources.h" |
| +#include "third_party/skia/include/core/SkColor.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| +#include "ui/gfx/font.h" |
| +#include "ui/views/background.h" |
| +#include "ui/views/border.h" |
| +#include "ui/views/controls/styled_label.h" |
| +#include "ui/views/layout/box_layout.h" |
| +#include "ui/views/layout/layout_constants.h" |
| + |
| +namespace { |
| +// Background color of the promo. |
| +const SkColor kBackgroundColor = SkColorSetRGB(245, 245, 245); |
| + |
| +// Color of the top border of the promo. |
| +const SkColor kBorderColor = SkColorSetRGB(229, 229, 229); |
| + |
| +// Width of the top border of the promo. |
| +const int kBorderWidth = 1; |
| + |
| +// Color of the text of the promo. |
| +const SkColor kTextColor = SkColorSetRGB(102, 102, 102); |
| + |
| +// Vertical padding of the promo (dp). |
| +const int kVerticalPadding = 15; |
|
fdoray
2013/07/16 17:58:56
This comes from the designer. Not defined in layou
sky
2013/07/16 21:23:00
There is a reason why we try to use the same const
fdoray
2013/07/17 15:01:59
I sent a screenshot of the result with a common co
|
| + |
| +} // namespace |
| + |
| +BookmarkSyncPromoView::BookmarkSyncPromoView(Browser* browser) |
| + : browser_(browser) { |
| + set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| + set_border(views::Border::CreateSolidSidedBorder(kBorderWidth, |
| + 0, |
| + 0, |
| + 0, |
| + kBorderColor)); |
| + size_t offset; |
| + string16 link_text = l10n_util::GetStringUTF16(IDS_BOOKMARK_SYNC_PROMO_LINK); |
| + string16 promo_text = l10n_util::GetStringFUTF16( |
| + IDS_BOOKMARK_SYNC_PROMO_MESSAGE, |
| + link_text, |
| + &offset); |
| + |
| + views::StyledLabel* promo_label = new views::StyledLabel(promo_text, this); |
| + promo_label->SetDisplayedOnBackgroundColor(kBackgroundColor); |
| + |
| + views::StyledLabel::RangeStyleInfo link_style = |
| + views::StyledLabel::RangeStyleInfo::CreateForLink(); |
| + link_style.font_style = gfx::Font::NORMAL; |
| + promo_label->AddStyleRange(ui::Range(offset, offset + link_text.length()), |
| + link_style); |
| + |
| + views::StyledLabel::RangeStyleInfo promo_style; |
| + promo_style.color = kTextColor; |
| + ui::Range before_link_range(0, offset); |
| + if (!before_link_range.is_empty()) |
| + promo_label->AddStyleRange(before_link_range, promo_style); |
| + ui::Range after_link_range(offset + link_text.length(), promo_text.length()); |
| + if (!after_link_range.is_empty()) |
| + promo_label->AddStyleRange(after_link_range, promo_style); |
| + |
| + views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, |
| + views::kButtonHEdgeMarginNew, |
| + kVerticalPadding, |
| + 0); |
| + SetLayoutManager(layout); |
| + AddChildView(promo_label); |
| +} |
| + |
| +void BookmarkSyncPromoView::StyledLabelLinkClicked(const ui::Range& range, |
| + int event_flags) { |
| + chrome::ShowBrowserSignin(browser_, SyncPromoUI::SOURCE_BOOKMARK_BUBBLE); |
| +} |