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 18 matching lines...) Expand all Loading... |
29 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
33 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
34 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
35 #include "grit/google_chrome_strings.h" | 35 #include "grit/google_chrome_strings.h" |
36 #include "grit/ui_resources.h" | 36 #include "grit/ui_resources.h" |
37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/views/bubble/bubble_frame_view.h" |
39 #include "ui/views/controls/button/checkbox.h" | 40 #include "ui/views/controls/button/checkbox.h" |
40 #include "ui/views/controls/button/label_button.h" | 41 #include "ui/views/controls/button/label_button.h" |
41 #include "ui/views/controls/label.h" | 42 #include "ui/views/controls/label.h" |
42 #include "ui/views/controls/separator.h" | 43 #include "ui/views/controls/separator.h" |
43 #include "ui/views/controls/styled_label.h" | 44 #include "ui/views/controls/styled_label.h" |
44 #include "ui/views/layout/grid_layout.h" | 45 #include "ui/views/layout/grid_layout.h" |
45 #include "ui/views/layout/layout_constants.h" | 46 #include "ui/views/layout/layout_constants.h" |
46 #include "ui/views/widget/widget.h" | 47 #include "ui/views/widget/widget.h" |
47 | 48 |
48 using views::GridLayout; | 49 using views::GridLayout; |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 // Fixed width of the column holding the description label of the bubble. | 53 // Fixed width of the column holding the description label of the bubble. |
53 const int kWidthOfDescriptionText = 320; | 54 const int kWidthOfDescriptionText = 320; |
54 | 55 |
55 // Distance between checkbox and the text to the right of it. | 56 // Distance between checkbox and the text to the right of it. |
56 const int kCheckboxTextDistance = 4; | 57 const int kCheckboxTextDistance = 4; |
57 | 58 |
58 // Margins width for the top rows to compensate for the bottom panel for which | 59 // The color of the text and background of the sub panel to offer UMA optin. |
59 // we don't want any margin. | 60 // These values match the BookmarkSyncPromoView colors. |
60 const int kMarginWidth = 12; | 61 const SkColor kBackgroundColor = SkColorSetRGB(245, 245, 245); |
61 const int kMarginHeight = kMarginWidth; | 62 const SkColor kTextColor = SkColorSetRGB(102, 102, 102); |
62 | |
63 // The color of the background of the sub panel to offer UMA optin. | |
64 const SkColor kLightGrayBackgroundColor = 0xFFF0F0F0; | |
65 const SkColor kWhiteBackgroundColor = 0xFFFFFFFF; | |
66 | 63 |
67 // The Finch study name and group name that enables session crashed bubble UI. | 64 // The Finch study name and group name that enables session crashed bubble UI. |
68 const char kEnableBubbleUIFinchName[] = "EnableSessionCrashedBubbleUI"; | 65 const char kEnableBubbleUIFinchName[] = "EnableSessionCrashedBubbleUI"; |
69 const char kEnableBubbleUIGroupEnabled[] = "Enabled"; | 66 const char kEnableBubbleUIGroupEnabled[] = "Enabled"; |
70 | 67 |
71 bool ShouldOfferMetricsReporting() { | 68 bool ShouldOfferMetricsReporting() { |
72 // Stats collection only applies to Google Chrome builds. | 69 // Stats collection only applies to Google Chrome builds. |
73 #if defined(GOOGLE_CHROME_BUILD) | 70 #if defined(GOOGLE_CHROME_BUILD) |
74 // Only show metrics reporting option if user didn't already consent to it. | 71 // Only show metrics reporting option if user didn't already consent to it. |
75 if (GoogleUpdateSettings::GetCollectStatsConsent()) | 72 if (GoogleUpdateSettings::GetCollectStatsConsent()) |
76 return false; | 73 return false; |
77 return g_browser_process->local_state()->FindPreference( | 74 return g_browser_process->local_state()->FindPreference( |
78 prefs::kMetricsReportingEnabled)->IsUserModifiable(); | 75 prefs::kMetricsReportingEnabled)->IsUserModifiable(); |
79 #else | 76 #else |
80 return false; | 77 return false; |
81 #endif // defined(GOOGLE_CHROME_BUILD) | 78 #endif // defined(GOOGLE_CHROME_BUILD) |
82 } | 79 } |
83 | 80 |
84 // Whether or not the bubble UI should be used. | 81 // Whether or not the bubble UI should be used. |
85 bool IsBubbleUIEnabled() { | 82 bool IsBubbleUIEnabled() { |
86 const std::string group_name = base::FieldTrialList::FindFullName( | |
87 kEnableBubbleUIFinchName); | |
88 const base::CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 83 const base::CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
89 if (command_line.HasSwitch(switches::kDisableSessionCrashedBubble)) | 84 if (command_line.HasSwitch(switches::kDisableSessionCrashedBubble)) |
90 return false; | 85 return false; |
91 if (command_line.HasSwitch(switches::kEnableSessionCrashedBubble)) | 86 if (command_line.HasSwitch(switches::kEnableSessionCrashedBubble)) |
92 return true; | 87 return true; |
| 88 const std::string group_name = base::FieldTrialList::FindFullName( |
| 89 kEnableBubbleUIFinchName); |
93 return group_name == kEnableBubbleUIGroupEnabled; | 90 return group_name == kEnableBubbleUIGroupEnabled; |
94 } | 91 } |
95 | 92 |
96 } // namespace | 93 } // namespace |
97 | 94 |
98 // A helper class that listens to browser removal event. | 95 // A helper class that listens to browser removal event. |
99 class SessionCrashedBubbleView::BrowserRemovalObserver | 96 class SessionCrashedBubbleView::BrowserRemovalObserver |
100 : public chrome::BrowserListObserver { | 97 : public chrome::BrowserListObserver { |
101 public: | 98 public: |
102 explicit BrowserRemovalObserver(Browser* browser); | 99 explicit BrowserRemovalObserver(Browser* browser) : browser_(browser) { |
103 virtual ~BrowserRemovalObserver(); | 100 DCHECK(browser_); |
| 101 BrowserList::AddObserver(this); |
| 102 } |
| 103 |
| 104 virtual ~BrowserRemovalObserver() { |
| 105 BrowserList::RemoveObserver(this); |
| 106 } |
104 | 107 |
105 // Overridden from chrome::BrowserListObserver. | 108 // Overridden from chrome::BrowserListObserver. |
106 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | 109 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE { |
| 110 if (browser == browser_) |
| 111 browser_ = NULL; |
| 112 } |
107 | 113 |
108 Browser* browser() const; | 114 Browser* browser() const { return browser_; } |
109 | 115 |
110 private: | 116 private: |
111 Browser* browser_; | 117 Browser* browser_; |
112 | 118 |
113 DISALLOW_COPY_AND_ASSIGN(BrowserRemovalObserver); | 119 DISALLOW_COPY_AND_ASSIGN(BrowserRemovalObserver); |
114 }; | 120 }; |
115 | 121 |
116 SessionCrashedBubbleView::BrowserRemovalObserver::BrowserRemovalObserver( | |
117 Browser* browser) | |
118 : browser_(browser) { | |
119 DCHECK(browser_); | |
120 BrowserList::AddObserver(this); | |
121 } | |
122 | |
123 SessionCrashedBubbleView::BrowserRemovalObserver::~BrowserRemovalObserver() { | |
124 BrowserList::RemoveObserver(this); | |
125 } | |
126 | |
127 void SessionCrashedBubbleView::BrowserRemovalObserver::OnBrowserRemoved( | |
128 Browser* browser) { | |
129 if (browser == browser_) | |
130 browser_ = NULL; | |
131 } | |
132 | |
133 Browser* SessionCrashedBubbleView::BrowserRemovalObserver::browser() const { | |
134 return browser_; | |
135 } | |
136 | |
137 // static | 122 // static |
138 void SessionCrashedBubbleView::Show(Browser* browser) { | 123 void SessionCrashedBubbleView::Show(Browser* browser) { |
139 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 124 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
140 if (browser->profile()->IsOffTheRecord()) | 125 if (browser->profile()->IsOffTheRecord()) |
141 return; | 126 return; |
142 | 127 |
143 // Observes browser removal event and will be deallocated in ShowForReal. | 128 // Observes browser removal event and will be deallocated in ShowForReal. |
144 scoped_ptr<BrowserRemovalObserver> browser_observer( | 129 scoped_ptr<BrowserRemovalObserver> browser_observer( |
145 new BrowserRemovalObserver(browser)); | 130 new BrowserRemovalObserver(browser)); |
146 | 131 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 SessionCrashedBubbleView::SessionCrashedBubbleView( | 166 SessionCrashedBubbleView::SessionCrashedBubbleView( |
182 views::View* anchor_view, | 167 views::View* anchor_view, |
183 Browser* browser, | 168 Browser* browser, |
184 content::WebContents* web_contents, | 169 content::WebContents* web_contents, |
185 bool offer_uma_optin) | 170 bool offer_uma_optin) |
186 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 171 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
187 content::WebContentsObserver(web_contents), | 172 content::WebContentsObserver(web_contents), |
188 browser_(browser), | 173 browser_(browser), |
189 web_contents_(web_contents), | 174 web_contents_(web_contents), |
190 restore_button_(NULL), | 175 restore_button_(NULL), |
191 close_(NULL), | |
192 uma_option_(NULL), | 176 uma_option_(NULL), |
193 offer_uma_optin_(offer_uma_optin), | 177 offer_uma_optin_(offer_uma_optin), |
194 started_navigation_(false) { | 178 started_navigation_(false) { |
195 set_close_on_deactivate(false); | 179 set_close_on_deactivate(false); |
196 registrar_.Add( | 180 registrar_.Add( |
197 this, | 181 this, |
198 chrome::NOTIFICATION_TAB_CLOSING, | 182 chrome::NOTIFICATION_TAB_CLOSING, |
199 content::Source<content::NavigationController>(&( | 183 content::Source<content::NavigationController>(&( |
200 web_contents->GetController()))); | 184 web_contents->GetController()))); |
201 browser->tab_strip_model()->AddObserver(this); | 185 browser->tab_strip_model()->AddObserver(this); |
202 } | 186 } |
203 | 187 |
204 SessionCrashedBubbleView::~SessionCrashedBubbleView() { | 188 SessionCrashedBubbleView::~SessionCrashedBubbleView() { |
205 browser_->tab_strip_model()->RemoveObserver(this); | 189 browser_->tab_strip_model()->RemoveObserver(this); |
206 } | 190 } |
207 | 191 |
208 views::View* SessionCrashedBubbleView::GetInitiallyFocusedView() { | 192 views::View* SessionCrashedBubbleView::GetInitiallyFocusedView() { |
209 return restore_button_; | 193 return restore_button_; |
210 } | 194 } |
211 | 195 |
| 196 base::string16 SessionCrashedBubbleView::GetWindowTitle() const { |
| 197 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_BUBBLE_TITLE); |
| 198 } |
| 199 |
| 200 bool SessionCrashedBubbleView::ShouldShowWindowTitle() const { |
| 201 return true; |
| 202 } |
| 203 |
| 204 bool SessionCrashedBubbleView::ShouldShowCloseButton() const { |
| 205 return true; |
| 206 } |
| 207 |
212 void SessionCrashedBubbleView::Init() { | 208 void SessionCrashedBubbleView::Init() { |
213 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | |
214 | |
215 // Close button. | |
216 close_ = new views::LabelButton(this, base::string16()); | |
217 close_->SetImage(views::CustomButton::STATE_NORMAL, | |
218 *rb->GetImageNamed(IDR_CLOSE_2).ToImageSkia()); | |
219 close_->SetImage(views::CustomButton::STATE_HOVERED, | |
220 *rb->GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); | |
221 close_->SetImage(views::CustomButton::STATE_PRESSED, | |
222 *rb->GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); | |
223 close_->SetSize(close_->GetPreferredSize()); | |
224 close_->SetBorder(views::Border::CreateEmptyBorder(0, 0, 0, 0)); | |
225 | |
226 // Bubble title label. | |
227 views::Label* title_label = new views::Label( | |
228 l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_BUBBLE_TITLE)); | |
229 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
230 title_label->SetFontList(rb->GetFontList(ui::ResourceBundle::BoldFont)); | |
231 | |
232 // Description text label. | 209 // Description text label. |
233 views::Label* text_label = new views::Label( | 210 views::Label* text_label = new views::Label( |
234 l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE)); | 211 l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE)); |
235 text_label->SetMultiLine(true); | 212 text_label->SetMultiLine(true); |
236 text_label->SetLineHeight(20); | 213 text_label->SetLineHeight(20); |
237 text_label->SetEnabledColor(SK_ColorDKGRAY); | |
238 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 214 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
239 text_label->SizeToFit(kWidthOfDescriptionText); | 215 text_label->SizeToFit(kWidthOfDescriptionText); |
240 | 216 |
241 // Restore button. | 217 // Restore button. |
242 restore_button_ = new views::LabelButton( | 218 restore_button_ = new views::LabelButton( |
243 this, l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON)); | 219 this, l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON)); |
244 restore_button_->SetStyle(views::Button::STYLE_BUTTON); | 220 restore_button_->SetStyle(views::Button::STYLE_BUTTON); |
245 restore_button_->SetIsDefault(true); | 221 restore_button_->SetIsDefault(true); |
246 restore_button_->SetFontList(rb->GetFontList(ui::ResourceBundle::BoldFont)); | |
247 | 222 |
248 GridLayout* layout = new GridLayout(this); | 223 GridLayout* layout = new GridLayout(this); |
249 SetLayoutManager(layout); | 224 SetLayoutManager(layout); |
250 | 225 |
251 // Title and close button row. | 226 // Text row. |
252 const int kTitleColumnSetId = 0; | 227 const int kTextColumnSetId = 0; |
253 views::ColumnSet* cs = layout->AddColumnSet(kTitleColumnSetId); | 228 views::ColumnSet* cs = layout->AddColumnSet(kTextColumnSetId); |
254 cs->AddPaddingColumn(0, kMarginWidth); | 229 cs->AddPaddingColumn(0, GetBubbleFrameView()->GetTitleInsets().left()); |
255 cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0, | 230 cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
| 231 GridLayout::FIXED, kWidthOfDescriptionText, 0); |
| 232 cs->AddPaddingColumn(0, GetBubbleFrameView()->GetTitleInsets().left()); |
| 233 |
| 234 // Restore button row. |
| 235 const int kButtonColumnSetId = 1; |
| 236 cs = layout->AddColumnSet(kButtonColumnSetId); |
| 237 cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 1, |
256 GridLayout::USE_PREF, 0, 0); | 238 GridLayout::USE_PREF, 0, 0); |
257 cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing); | 239 cs->AddPaddingColumn(0, GetBubbleFrameView()->GetTitleInsets().left()); |
258 cs->AddColumn(GridLayout::TRAILING, GridLayout::LEADING, 0, | |
259 GridLayout::USE_PREF, 0, 0); | |
260 | |
261 // Text row. | |
262 const int kTextColumnSetId = 1; | |
263 cs = layout->AddColumnSet(kTextColumnSetId); | |
264 cs->AddPaddingColumn(0, kMarginWidth); | |
265 cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | |
266 GridLayout::FIXED, kWidthOfDescriptionText, 0); | |
267 | |
268 // Restore button row | |
269 const int kButtonColumnSetId = 2; | |
270 cs = layout->AddColumnSet(kButtonColumnSetId); | |
271 cs->AddPaddingColumn(0, kMarginWidth); | |
272 cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing); | |
273 cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, | |
274 GridLayout::USE_PREF, 0, 0); | |
275 cs->AddPaddingColumn(0, kMarginWidth); | |
276 | |
277 layout->AddPaddingRow(0, kMarginHeight); | |
278 layout->StartRow(0, kTitleColumnSetId); | |
279 layout->AddView(title_label); | |
280 layout->AddView(close_); | |
281 layout->AddPaddingRow(0, kMarginHeight); | |
282 | 240 |
283 layout->StartRow(0, kTextColumnSetId); | 241 layout->StartRow(0, kTextColumnSetId); |
284 layout->AddView(text_label); | 242 layout->AddView(text_label); |
285 layout->AddPaddingRow(0, kMarginHeight); | 243 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
286 | 244 |
287 layout->StartRow(0, kButtonColumnSetId); | 245 layout->StartRow(0, kButtonColumnSetId); |
288 layout->AddView(restore_button_); | 246 layout->AddView(restore_button_); |
289 layout->AddPaddingRow(0, kMarginHeight); | 247 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
290 | 248 |
291 // Metrics reporting option. | 249 // Metrics reporting option. |
292 if (offer_uma_optin_) | 250 if (offer_uma_optin_) |
293 CreateUmaOptinView(layout); | 251 CreateUmaOptinView(layout); |
294 | 252 |
295 set_color(kWhiteBackgroundColor); | |
296 set_margins(gfx::Insets()); | 253 set_margins(gfx::Insets()); |
297 Layout(); | 254 Layout(); |
298 } | 255 } |
299 | 256 |
300 void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { | 257 void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { |
301 // Checkbox for metric reporting setting. | 258 // Checkbox for metric reporting setting. |
302 // Since the text to the right of the checkbox can't be a simple string (needs | 259 // Since the text to the right of the checkbox can't be a simple string (needs |
303 // a hyperlink in it), this checkbox contains an empty string as its label, | 260 // a hyperlink in it), this checkbox contains an empty string as its label, |
304 // and the real text will be added as a separate view. | 261 // and the real text will be added as a separate view. |
305 uma_option_ = new views::Checkbox(base::string16()); | 262 uma_option_ = new views::Checkbox(base::string16()); |
306 uma_option_->SetTextColor(views::Button::STATE_NORMAL, SK_ColorGRAY); | |
307 uma_option_->SetChecked(false); | 263 uma_option_->SetChecked(false); |
308 uma_option_->set_background( | 264 uma_option_->set_background( |
309 views::Background::CreateSolidBackground(kLightGrayBackgroundColor)); | 265 views::Background::CreateSolidBackground(kBackgroundColor)); |
310 uma_option_->set_listener(this); | |
311 | 266 |
312 // The text to the right of the checkbox. | 267 // The text to the right of the checkbox. |
313 size_t offset; | 268 size_t offset; |
314 base::string16 link_text = | 269 base::string16 link_text = |
315 l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_BUBBLE_UMA_LINK_TEXT); | 270 l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_BUBBLE_UMA_LINK_TEXT); |
316 base::string16 uma_text = l10n_util::GetStringFUTF16( | 271 base::string16 uma_text = l10n_util::GetStringFUTF16( |
317 IDS_SESSION_CRASHED_VIEW_UMA_OPTIN, | 272 IDS_SESSION_CRASHED_VIEW_UMA_OPTIN, |
318 link_text, | 273 link_text, |
319 &offset); | 274 &offset); |
320 views::StyledLabel* uma_label = new views::StyledLabel(uma_text, this); | 275 views::StyledLabel* uma_label = new views::StyledLabel(uma_text, this); |
321 uma_label->set_background( | 276 uma_label->set_background( |
322 views::Background::CreateSolidBackground(kLightGrayBackgroundColor)); | 277 views::Background::CreateSolidBackground(kBackgroundColor)); |
323 views::StyledLabel::RangeStyleInfo link_style = | 278 views::StyledLabel::RangeStyleInfo link_style = |
324 views::StyledLabel::RangeStyleInfo::CreateForLink(); | 279 views::StyledLabel::RangeStyleInfo::CreateForLink(); |
325 link_style.font_style = gfx::Font::NORMAL; | 280 link_style.font_style = gfx::Font::NORMAL; |
326 uma_label->AddStyleRange(gfx::Range(offset, offset + link_text.length()), | 281 uma_label->AddStyleRange(gfx::Range(offset, offset + link_text.length()), |
327 link_style); | 282 link_style); |
328 views::StyledLabel::RangeStyleInfo uma_style; | 283 views::StyledLabel::RangeStyleInfo uma_style; |
329 uma_style.color = SK_ColorGRAY; | 284 uma_style.color = kTextColor; |
330 gfx::Range before_link_range(0, offset); | 285 gfx::Range before_link_range(0, offset); |
331 if (!before_link_range.is_empty()) | 286 if (!before_link_range.is_empty()) |
332 uma_label->AddStyleRange(before_link_range, uma_style); | 287 uma_label->AddStyleRange(before_link_range, uma_style); |
333 gfx::Range after_link_range(offset + link_text.length(), uma_text.length()); | 288 gfx::Range after_link_range(offset + link_text.length(), uma_text.length()); |
334 if (!after_link_range.is_empty()) | 289 if (!after_link_range.is_empty()) |
335 uma_label->AddStyleRange(after_link_range, uma_style); | 290 uma_label->AddStyleRange(after_link_range, uma_style); |
336 | 291 |
337 // We use a border instead of padding so that the background color reach | 292 // We use a border instead of padding so that the background color reaches |
338 // the edges of the bubble. | 293 // the edges of the bubble. |
339 uma_option_->SetBorder( | 294 const gfx::Insets title_insets = GetBubbleFrameView()->GetTitleInsets(); |
340 views::Border::CreateSolidSidedBorder(0, kMarginWidth, 0, 0, | 295 uma_option_->SetBorder(views::Border::CreateSolidSidedBorder( |
341 kLightGrayBackgroundColor)); | 296 0, title_insets.left(), 0, 0, kBackgroundColor)); |
342 uma_label->SetBorder( | 297 uma_label->SetBorder(views::Border::CreateSolidSidedBorder( |
343 views::Border::CreateSolidSidedBorder( | 298 views::kRelatedControlVerticalSpacing, kCheckboxTextDistance, |
344 kMarginHeight, kCheckboxTextDistance, kMarginHeight, kMarginWidth, | 299 views::kRelatedControlVerticalSpacing, title_insets.left(), |
345 kLightGrayBackgroundColor)); | 300 kBackgroundColor)); |
346 | 301 |
347 // Separator. | 302 // Separator. |
348 const int kSeparatorColumnSetId = 3; | 303 const int kSeparatorColumnSetId = 2; |
349 views::ColumnSet* cs = layout->AddColumnSet(kSeparatorColumnSetId); | 304 views::ColumnSet* cs = layout->AddColumnSet(kSeparatorColumnSetId); |
350 cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | 305 cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
351 GridLayout::FIXED, kWidthOfDescriptionText + kMarginWidth, 0); | 306 GridLayout::USE_PREF, 0, 0); |
352 | 307 |
353 // Reporting row. | 308 // Reporting row. |
354 const int kReportColumnSetId = 4; | 309 const int kReportColumnSetId = 3; |
355 cs = layout->AddColumnSet(kReportColumnSetId); | 310 cs = layout->AddColumnSet(kReportColumnSetId); |
356 cs->AddColumn(GridLayout::CENTER, GridLayout::FILL, 0, | 311 cs->AddColumn(GridLayout::CENTER, GridLayout::FILL, 0, |
357 GridLayout::USE_PREF, 0, 0); | 312 GridLayout::USE_PREF, 0, 0); |
358 cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | 313 cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, |
359 GridLayout::FIXED, kWidthOfDescriptionText, 0); | 314 GridLayout::FIXED, kWidthOfDescriptionText, 0); |
360 | 315 |
361 layout->StartRow(0, kSeparatorColumnSetId); | 316 layout->StartRow(0, kSeparatorColumnSetId); |
362 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 317 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
363 layout->StartRow(0, kReportColumnSetId); | 318 layout->StartRow(0, kReportColumnSetId); |
364 layout->AddView(uma_option_); | 319 layout->AddView(uma_option_); |
365 layout->AddView(uma_label); | 320 layout->AddView(uma_label); |
366 } | 321 } |
367 | 322 |
368 void SessionCrashedBubbleView::ButtonPressed(views::Button* sender, | 323 void SessionCrashedBubbleView::ButtonPressed(views::Button* sender, |
369 const ui::Event& event) { | 324 const ui::Event& event) { |
370 DCHECK(sender); | 325 DCHECK_EQ(sender, restore_button_); |
371 if (sender == restore_button_) | 326 RestorePreviousSession(sender); |
372 RestorePreviousSession(sender); | |
373 else if (sender == close_) | |
374 CloseBubble(); | |
375 } | 327 } |
376 | 328 |
377 void SessionCrashedBubbleView::StyledLabelLinkClicked(const gfx::Range& range, | 329 void SessionCrashedBubbleView::StyledLabelLinkClicked(const gfx::Range& range, |
378 int event_flags) { | 330 int event_flags) { |
379 browser_->OpenURL(content::OpenURLParams( | 331 browser_->OpenURL(content::OpenURLParams( |
380 GURL("https://support.google.com/chrome/answer/96817"), | 332 GURL("https://support.google.com/chrome/answer/96817"), |
381 content::Referrer(), | 333 content::Referrer(), |
382 NEW_FOREGROUND_TAB, | 334 NEW_FOREGROUND_TAB, |
383 content::PAGE_TRANSITION_LINK, | 335 content::PAGE_TRANSITION_LINK, |
384 false)); | 336 false)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 GetWidget()->Close(); | 392 GetWidget()->Close(); |
441 } | 393 } |
442 | 394 |
443 bool ShowSessionCrashedBubble(Browser* browser) { | 395 bool ShowSessionCrashedBubble(Browser* browser) { |
444 if (IsBubbleUIEnabled()) { | 396 if (IsBubbleUIEnabled()) { |
445 SessionCrashedBubbleView::Show(browser); | 397 SessionCrashedBubbleView::Show(browser); |
446 return true; | 398 return true; |
447 } | 399 } |
448 return false; | 400 return false; |
449 } | 401 } |
OLD | NEW |