| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/validation_message_bubble_view.h" | 5 #include "chrome/browser/ui/views/validation_message_bubble_view.h" |
| 6 | 6 |
| 7 #include "chrome/grit/theme_resources.h" | 7 #include "chrome/grit/theme_resources.h" |
| 8 #include "content/public/browser/render_widget_host.h" | 8 #include "content/public/browser/render_widget_host.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 set_arrow(views::BubbleBorder::TOP_LEFT); | 36 set_arrow(views::BubbleBorder::TOP_LEFT); |
| 37 SetAnchorRect( | 37 SetAnchorRect( |
| 38 RootViewToScreenRect(anchor_in_root_view, render_widget_host_view)); | 38 RootViewToScreenRect(anchor_in_root_view, render_widget_host_view)); |
| 39 | 39 |
| 40 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 40 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 41 views::ImageView* icon = new views::ImageView(); | 41 views::ImageView* icon = new views::ImageView(); |
| 42 icon->SetImage(*bundle.GetImageSkiaNamed(IDR_INPUT_ALERT)); | 42 icon->SetImage(*bundle.GetImageSkiaNamed(IDR_INPUT_ALERT)); |
| 43 icon->SizeToPreferredSize(); | 43 icon->SizeToPreferredSize(); |
| 44 AddChildView(icon); | 44 AddChildView(icon); |
| 45 | 45 |
| 46 views::Label* label = new views::Label( | 46 // TODO(tapted): Move |main_text| to WidgetDelegate::GetWindowTitle(). |
| 47 main_text, bundle.GetFontList(ui::ResourceBundle::MediumFont)); | 47 views::Label* label = |
| 48 new views::Label(main_text, views::typography::CONTEXT_DIALOG_TITLE); |
| 48 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 49 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 49 int text_start_x = icon->bounds().right() + kIconTextMargin; | 50 int text_start_x = icon->bounds().right() + kIconTextMargin; |
| 50 int min_available = kWindowMinWidth - text_start_x; | 51 int min_available = kWindowMinWidth - text_start_x; |
| 51 int max_available = kWindowMaxWidth - text_start_x; | 52 int max_available = kWindowMaxWidth - text_start_x; |
| 52 int label_width = label->GetPreferredSize().width(); | 53 int label_width = label->GetPreferredSize().width(); |
| 53 label->SetMultiLine(true); | 54 label->SetMultiLine(true); |
| 54 AddChildView(label); | 55 AddChildView(label); |
| 55 | 56 |
| 56 views::Label* sub_label = nullptr; | 57 views::Label* sub_label = nullptr; |
| 57 if (!sub_text.empty()) { | 58 if (!sub_text.empty()) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void ValidationMessageBubbleView::SetPositionRelativeToAnchor( | 106 void ValidationMessageBubbleView::SetPositionRelativeToAnchor( |
| 106 content::RenderWidgetHost* widget_host, | 107 content::RenderWidgetHost* widget_host, |
| 107 const gfx::Rect& anchor_in_root_view) { | 108 const gfx::Rect& anchor_in_root_view) { |
| 108 SetAnchorRect( | 109 SetAnchorRect( |
| 109 RootViewToScreenRect(anchor_in_root_view, widget_host->GetView())); | 110 RootViewToScreenRect(anchor_in_root_view, widget_host->GetView())); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void ValidationMessageBubbleView::CloseValidationMessage() { | 113 void ValidationMessageBubbleView::CloseValidationMessage() { |
| 113 GetWidget()->Close(); | 114 GetWidget()->Close(); |
| 114 } | 115 } |
| OLD | NEW |