OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/session_crashed_bubble_view.h" | 5 #include "chrome/browser/ui/views/session_crashed_bubble_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 using views::GridLayout; | 48 using views::GridLayout; |
49 | 49 |
50 namespace { | 50 namespace { |
51 | 51 |
52 // Fixed width of the column holding the description label of the bubble. | 52 // Fixed width of the column holding the description label of the bubble. |
53 const int kWidthOfDescriptionText = 320; | 53 const int kWidthOfDescriptionText = 320; |
54 | 54 |
55 // Distance between checkbox and the text to the right of it. | 55 // Distance between checkbox and the text to the right of it. |
56 const int kCheckboxTextDistance = 4; | 56 const int kCheckboxTextDistance = 4; |
57 | 57 |
58 // Bottom inset for UMA opt-in view in pixels. | |
msw
2014/09/19 18:01:48
nit: be consistent about "optin" vs. "opt-in" in c
yao
2014/10/09 20:38:40
Done.
| |
59 const int kUMAOptinViewBottomInset = 10; | |
msw
2014/09/19 18:01:48
nit: This could be moved into the scope of the one
yao
2014/10/09 20:38:40
Done.
| |
60 | |
58 // The color of the text and background of the sub panel to offer UMA optin. | 61 // The color of the text and background of the sub panel to offer UMA optin. |
59 // These values match the BookmarkSyncPromoView colors. | 62 // These values match the BookmarkSyncPromoView colors. |
60 const SkColor kBackgroundColor = SkColorSetRGB(245, 245, 245); | 63 const SkColor kBackgroundColor = SkColorSetRGB(245, 245, 245); |
61 const SkColor kTextColor = SkColorSetRGB(102, 102, 102); | 64 const SkColor kTextColor = SkColorSetRGB(102, 102, 102); |
62 | 65 |
63 // The Finch study name and group name that enables session crashed bubble UI. | 66 // The Finch study name and group name that enables session crashed bubble UI. |
64 const char kEnableBubbleUIFinchName[] = "EnableSessionCrashedBubbleUI"; | 67 const char kEnableBubbleUIFinchName[] = "EnableSessionCrashedBubbleUI"; |
65 const char kEnableBubbleUIGroupEnabled[] = "Enabled"; | 68 const char kEnableBubbleUIGroupEnabled[] = "Enabled"; |
66 | 69 |
67 enum SessionCrashedBubbleHistogramValue { | 70 enum SessionCrashedBubbleHistogramValue { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 uma_label->AddStyleRange(gfx::Range(offset, offset + link_text.length()), | 332 uma_label->AddStyleRange(gfx::Range(offset, offset + link_text.length()), |
330 link_style); | 333 link_style); |
331 views::StyledLabel::RangeStyleInfo uma_style; | 334 views::StyledLabel::RangeStyleInfo uma_style; |
332 uma_style.color = kTextColor; | 335 uma_style.color = kTextColor; |
333 gfx::Range before_link_range(0, offset); | 336 gfx::Range before_link_range(0, offset); |
334 if (!before_link_range.is_empty()) | 337 if (!before_link_range.is_empty()) |
335 uma_label->AddStyleRange(before_link_range, uma_style); | 338 uma_label->AddStyleRange(before_link_range, uma_style); |
336 gfx::Range after_link_range(offset + link_text.length(), uma_text.length()); | 339 gfx::Range after_link_range(offset + link_text.length(), uma_text.length()); |
337 if (!after_link_range.is_empty()) | 340 if (!after_link_range.is_empty()) |
338 uma_label->AddStyleRange(after_link_range, uma_style); | 341 uma_label->AddStyleRange(after_link_range, uma_style); |
342 // Since the checkbox has a bigger height than text, moves it down by 1px to | |
msw
2014/09/19 18:01:48
nit: consider "Shift the text down by 1px to align
yao
2014/10/09 20:38:40
Done.
| |
343 // make them look aligned. | |
344 uma_label->SetBorder(views::Border::CreateEmptyBorder(1, 0, 0, 0)); | |
sky
2014/09/22 15:06:34
This only works with the default font on windows.
| |
339 | 345 |
340 // Create a view to hold the checkbox and the text. | 346 // Create a view to hold the checkbox and the text. |
341 views::View* uma_view = new views::View(); | 347 views::View* uma_view = new views::View(); |
342 GridLayout* uma_layout = new GridLayout(uma_view); | 348 GridLayout* uma_layout = new GridLayout(uma_view); |
343 uma_view->SetLayoutManager(uma_layout); | 349 uma_view->SetLayoutManager(uma_layout); |
344 | 350 |
345 uma_view->set_background( | 351 uma_view->set_background( |
346 views::Background::CreateSolidBackground(kBackgroundColor)); | 352 views::Background::CreateSolidBackground(kBackgroundColor)); |
347 int inset_left = GetBubbleFrameView()->GetTitleInsets().left(); | 353 int inset_left = GetBubbleFrameView()->GetTitleInsets().left(); |
348 uma_layout->SetInsets(views::kRelatedControlVerticalSpacing, inset_left, | 354 uma_layout->SetInsets(views::kRelatedControlVerticalSpacing, inset_left, |
349 views::kRelatedControlVerticalSpacing, inset_left); | 355 kUMAOptinViewBottomInset, inset_left); |
350 | 356 |
351 const int kReportColumnSetId = 0; | 357 const int kReportColumnSetId = 0; |
352 views::ColumnSet* cs = uma_layout->AddColumnSet(kReportColumnSetId); | 358 views::ColumnSet* cs = uma_layout->AddColumnSet(kReportColumnSetId); |
353 cs->AddColumn(GridLayout::CENTER, GridLayout::LEADING, 0, | 359 cs->AddColumn(GridLayout::CENTER, GridLayout::LEADING, 0, |
354 GridLayout::USE_PREF, 0, 0); | 360 GridLayout::USE_PREF, 0, 0); |
355 cs->AddPaddingColumn(0, kCheckboxTextDistance); | 361 cs->AddPaddingColumn(0, kCheckboxTextDistance); |
356 cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | 362 cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, |
357 GridLayout::FIXED, kWidthOfDescriptionText, 0); | 363 GridLayout::FIXED, kWidthOfDescriptionText, 0); |
358 | 364 |
359 uma_layout->StartRow(0, kReportColumnSetId); | 365 uma_layout->StartRow(0, kReportColumnSetId); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 GetWidget()->Close(); | 439 GetWidget()->Close(); |
434 } | 440 } |
435 | 441 |
436 bool ShowSessionCrashedBubble(Browser* browser) { | 442 bool ShowSessionCrashedBubble(Browser* browser) { |
437 if (IsBubbleUIEnabled()) { | 443 if (IsBubbleUIEnabled()) { |
438 SessionCrashedBubbleView::Show(browser); | 444 SessionCrashedBubbleView::Show(browser); |
439 return true; | 445 return true; |
440 } | 446 } |
441 return false; | 447 return false; |
442 } | 448 } |
OLD | NEW |