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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.cc

Issue 18603006: Bookmark sync promo for Views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improved style Created 7 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.h"
6
7 #include "base/strings/string16.h"
8 #include "chrome/browser/ui/chrome_pages.h"
9 #include "grit/generated_resources.h"
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/gfx/font.h"
13 #include "ui/views/background.h"
14 #include "ui/views/border.h"
15 #include "ui/views/controls/styled_label.h"
16 #include "ui/views/layout/box_layout.h"
17
18 namespace {
19 // Background color of the promo.
20 const SkColor kBackgroundColor = SkColorSetRGB(245, 245, 245);
21
22 // Color of the top border of the promo.
23 const SkColor kBorderColor = SkColorSetRGB(229, 229, 229);
24
25 // Width of the top border of the promo.
26 const int kBorderWidth = 1;
27
28 // Color of the text of the promo.
29 const SkColor kTextColor = SkColorSetRGB(102, 102, 102);
30
31 // Vertical padding of the promo (dp).
32 const int kVerticalPadding = 15;
33
34 // Horizontal padding of the promo.
35 const int kHorizontalPadding = 19;
36 } // namespace
37
38 BookmarkSyncPromoView::BookmarkSyncPromoView(Browser* browser)
39 : browser_(browser) {
40 set_background(views::Background::CreateSolidBackground(kBackgroundColor));
41 set_border(views::Border::CreateSolidSidedBorder(kBorderWidth,
42 0,
43 0,
44 0,
45 kBorderColor));
46 size_t offset;
47 string16 link_text = l10n_util::GetStringUTF16(IDS_BOOKMARK_SYNC_PROMO_LINK);
48 string16 promo_text = l10n_util::GetStringFUTF16(
49 IDS_BOOKMARK_SYNC_PROMO_MESSAGE,
50 link_text,
51 &offset);
52
53 views::StyledLabel* promo_label = new views::StyledLabel(promo_text, this);
54 promo_label->SetBackgroundColor(kBackgroundColor);
55
56 views::StyledLabel::RangeStyleInfo link_style =
57 views::StyledLabel::RangeStyleInfo::CreateForLink();
58 link_style.font_style = gfx::Font::NORMAL;
59 promo_label->AddStyleRange(ui::Range(offset, offset + link_text.length()),
60 link_style);
61
62 views::StyledLabel::RangeStyleInfo promo_style;
63 promo_style.color = kTextColor;
64 ui::Range before_link_range(0, offset);
65 if (!before_link_range.is_empty())
66 promo_label->AddStyleRange(before_link_range, promo_style);
67 ui::Range after_link_range(offset + link_text.length(), promo_text.length());
68 if (!after_link_range.is_empty())
69 promo_label->AddStyleRange(after_link_range, promo_style);
Roger Tawa OOO till Jul 10th 2013/07/11 15:28:30 Are the range not allowed to overlap?
fdoray 2013/07/11 19:00:40 Overlap doesn't work in all cases. It works if th
70
71 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical,
72 kHorizontalPadding,
73 kVerticalPadding,
74 0);
75 SetLayoutManager(layout);
76 AddChildView(promo_label);
77 }
78
79 void BookmarkSyncPromoView::StyledLabelLinkClicked(const ui::Range& range,
80 int event_flags) {
81 chrome::ShowBrowserSignin(browser_, SyncPromoUI::SOURCE_BOOKMARK_BUBBLE);
82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698