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

Side by Side Diff: chrome/browser/ui/views/sync/bubble_sync_promo_view.cc

Issue 1503583002: [Extensions Views] Update the extension installed bubble's sync promo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.h" 5 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" 8 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h"
9 #include "chrome/grit/chromium_strings.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
12 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/gfx/font.h" 11 #include "ui/gfx/font.h"
14 #include "ui/views/background.h" 12 #include "ui/views/background.h"
15 #include "ui/views/border.h" 13 #include "ui/views/border.h"
16 #include "ui/views/controls/styled_label.h" 14 #include "ui/views/controls/styled_label.h"
17 #include "ui/views/layout/box_layout.h" 15 #include "ui/views/layout/box_layout.h"
18 #include "ui/views/layout/layout_constants.h" 16 #include "ui/views/layout/layout_constants.h"
19 17
20 namespace { 18 namespace {
21 // Background color of the promo. 19 // Background color of the promo.
22 const SkColor kBackgroundColor = SkColorSetRGB(245, 245, 245); 20 const SkColor kBackgroundColor = SkColorSetRGB(245, 245, 245);
23 21
24 // Color of the top border of the promo. 22 // Color of the top border of the promo.
25 const SkColor kBorderColor = SkColorSetRGB(229, 229, 229); 23 const SkColor kBorderColor = SkColorSetRGB(229, 229, 229);
26 24
27 // Width of the top border of the promo. 25 // Width of the top border of the promo.
28 const int kBorderWidth = 1; 26 const int kBorderWidth = 1;
29 27
30 // Color of the text of the promo. 28 // Color of the text of the promo.
31 const SkColor kTextColor = SkColorSetRGB(102, 102, 102); 29 const SkColor kTextColor = SkColorSetRGB(102, 102, 102);
32 30
33 } // namespace 31 } // namespace
34 32
35 BookmarkSyncPromoView::BookmarkSyncPromoView(BookmarkBubbleDelegate* delegate) 33 BubbleSyncPromoView::BubbleSyncPromoView(BubbleSyncPromoDelegate* delegate,
34 int link_text_resource_id,
35 int message_text_resource_id)
36 : delegate_(delegate) { 36 : delegate_(delegate) {
37 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); 37 set_background(views::Background::CreateSolidBackground(kBackgroundColor));
38 SetBorder(views::Border::CreateSolidSidedBorder( 38 SetBorder(views::Border::CreateSolidSidedBorder(kBorderWidth, 0, 0, 0,
39 kBorderWidth, 0, 0, 0, kBorderColor)); 39 kBorderColor));
40 size_t offset; 40 size_t offset = 0;
41 base::string16 link_text = 41 base::string16 link_text = l10n_util::GetStringUTF16(link_text_resource_id);
42 l10n_util::GetStringUTF16(IDS_BOOKMARK_SYNC_PROMO_LINK); 42 base::string16 promo_text =
43 base::string16 promo_text = l10n_util::GetStringFUTF16( 43 l10n_util::GetStringFUTF16(message_text_resource_id, link_text, &offset);
44 IDS_BOOKMARK_SYNC_PROMO_MESSAGE,
45 link_text,
46 &offset);
47 44
48 views::StyledLabel* promo_label = new views::StyledLabel(promo_text, this); 45 views::StyledLabel* promo_label = new views::StyledLabel(promo_text, this);
49 promo_label->SetDisplayedOnBackgroundColor(kBackgroundColor); 46 promo_label->SetDisplayedOnBackgroundColor(kBackgroundColor);
50 47
51 views::StyledLabel::RangeStyleInfo link_style = 48 views::StyledLabel::RangeStyleInfo link_style =
52 views::StyledLabel::RangeStyleInfo::CreateForLink(); 49 views::StyledLabel::RangeStyleInfo::CreateForLink();
53 link_style.font_style = gfx::Font::NORMAL; 50 link_style.font_style = gfx::Font::NORMAL;
54 promo_label->AddStyleRange(gfx::Range(offset, offset + link_text.length()), 51 promo_label->AddStyleRange(gfx::Range(offset, offset + link_text.length()),
55 link_style); 52 link_style);
56 53
57 views::StyledLabel::RangeStyleInfo promo_style; 54 views::StyledLabel::RangeStyleInfo promo_style;
58 promo_style.color = kTextColor; 55 promo_style.color = kTextColor;
59 gfx::Range before_link_range(0, offset); 56 gfx::Range before_link_range(0, offset);
60 if (!before_link_range.is_empty()) 57 if (!before_link_range.is_empty())
61 promo_label->AddStyleRange(before_link_range, promo_style); 58 promo_label->AddStyleRange(before_link_range, promo_style);
62 gfx::Range after_link_range(offset + link_text.length(), promo_text.length()); 59 gfx::Range after_link_range(offset + link_text.length(), promo_text.length());
63 if (!after_link_range.is_empty()) 60 if (!after_link_range.is_empty())
64 promo_label->AddStyleRange(after_link_range, promo_style); 61 promo_label->AddStyleRange(after_link_range, promo_style);
65 62
66 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, 63 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical,
67 views::kButtonHEdgeMarginNew, 64 views::kButtonHEdgeMarginNew,
68 views::kPanelVertMargin, 65 views::kPanelVertMargin, 0);
69 0);
70 SetLayoutManager(layout); 66 SetLayoutManager(layout);
71 AddChildView(promo_label); 67 AddChildView(promo_label);
72 } 68 }
73 69
74 void BookmarkSyncPromoView::StyledLabelLinkClicked(views::StyledLabel* label, 70 BubbleSyncPromoView::~BubbleSyncPromoView() {}
75 const gfx::Range& range, 71
76 int event_flags) { 72 void BubbleSyncPromoView::StyledLabelLinkClicked(views::StyledLabel* label,
73 const gfx::Range& range,
74 int event_flags) {
77 delegate_->OnSignInLinkClicked(); 75 delegate_->OnSignInLinkClicked();
78 } 76 }
79 77
80 const char* BookmarkSyncPromoView::GetClassName() const { 78 const char* BubbleSyncPromoView::GetClassName() const {
81 return "BookmarkSyncPromoView"; 79 return "BubbleSyncPromoView";
82 } 80 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/sync/bubble_sync_promo_view.h ('k') | chrome/browser/ui/views/sync/bubble_sync_promo_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698