| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/first_run_bubble.h" | 5 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/first_run/first_run.h" | 9 #include "chrome/browser/first_run/first_run.h" |
| 10 #include "chrome/browser/search_engines/util.h" | 10 #include "chrome/browser/search_engines/util.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/views/controls/button/image_button.h" | 23 #include "ui/views/controls/button/image_button.h" |
| 24 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 25 #include "ui/views/events/event.h" | 25 #include "ui/views/events/event.h" |
| 26 #include "ui/views/layout/grid_layout.h" | 26 #include "ui/views/layout/grid_layout.h" |
| 27 #include "ui/views/layout/layout_constants.h" | 27 #include "ui/views/layout/layout_constants.h" |
| 28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 29 | 29 |
| 30 using content::UserMetricsAction; | 30 using content::UserMetricsAction; |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 const int kAnchorVerticalOffset = -4; | 33 const int kAnchorVerticalInset = 5; |
| 34 const int kLayoutTopInset = 1; | 34 const int kLayoutTopInset = 1; |
| 35 const int kLayoutLeftInset = 2; | 35 const int kLayoutLeftInset = 2; |
| 36 const int kLayoutBottomInset = 7; | 36 const int kLayoutBottomInset = 7; |
| 37 const int kLayoutRightInset = 2; | 37 const int kLayoutRightInset = 2; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 FirstRunBubble* FirstRunBubble::ShowBubble( | 41 FirstRunBubble* FirstRunBubble::ShowBubble( |
| 42 Profile* profile, | 42 Profile* profile, |
| 43 views::View* anchor_view, | 43 views::View* anchor_view, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 views::GridLayout::LEADING); | 95 views::GridLayout::LEADING); |
| 96 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 96 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
| 97 | 97 |
| 98 layout->StartRow(0, 0); | 98 layout->StartRow(0, 0); |
| 99 layout->AddView(label2); | 99 layout->AddView(label2); |
| 100 } | 100 } |
| 101 | 101 |
| 102 gfx::Rect FirstRunBubble::GetAnchorRect() { | 102 gfx::Rect FirstRunBubble::GetAnchorRect() { |
| 103 // Compensate for padding in anchor. | 103 // Compensate for padding in anchor. |
| 104 gfx::Rect rect(BubbleDelegateView::GetAnchorRect()); | 104 gfx::Rect rect(BubbleDelegateView::GetAnchorRect()); |
| 105 rect.Offset(0, anchor_view() ? kAnchorVerticalOffset : 0); | 105 rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0); |
| 106 return rect; | 106 return rect; |
| 107 } | 107 } |
| 108 | 108 |
| 109 FirstRunBubble::FirstRunBubble( | 109 FirstRunBubble::FirstRunBubble( |
| 110 Profile* profile, | 110 Profile* profile, |
| 111 views::View* anchor_view, | 111 views::View* anchor_view, |
| 112 views::BubbleBorder::ArrowLocation arrow_location, | 112 views::BubbleBorder::ArrowLocation arrow_location, |
| 113 FirstRun::BubbleType bubble_type) | 113 FirstRun::BubbleType bubble_type) |
| 114 : views::BubbleDelegateView(anchor_view, arrow_location), | 114 : views::BubbleDelegateView(anchor_view, arrow_location), |
| 115 profile_(profile), | 115 profile_(profile), |
| 116 bubble_type_(bubble_type) { | 116 bubble_type_(bubble_type) { |
| 117 } | 117 } |
| 118 | 118 |
| 119 FirstRunBubble::~FirstRunBubble() { | 119 FirstRunBubble::~FirstRunBubble() { |
| 120 } | 120 } |
| 121 | 121 |
| 122 void FirstRunBubble::ButtonPressed(views::Button* sender, | 122 void FirstRunBubble::ButtonPressed(views::Button* sender, |
| 123 const views::Event& event) { | 123 const views::Event& event) { |
| 124 if (bubble_type_ == FirstRun::OEM_BUBBLE) { | 124 if (bubble_type_ == FirstRun::OEM_BUBBLE) { |
| 125 content::RecordAction( | 125 content::RecordAction( |
| 126 UserMetricsAction("FirstRunOEMBubbleView_Clicked")); | 126 UserMetricsAction("FirstRunOEMBubbleView_Clicked")); |
| 127 } | 127 } |
| 128 GetWidget()->Close(); | 128 GetWidget()->Close(); |
| 129 } | 129 } |
| OLD | NEW |