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

Side by Side Diff: chrome/browser/ui/views/confirm_bubble_views.cc

Issue 11818044: Replace IDR_WEB_UI_CLOSE* with IDR_CLOSE_DIALOG*, cleanup, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 11 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/confirm_bubble_views.h" 5 #include "chrome/browser/ui/views/confirm_bubble_views.h"
6 6
7 #include "chrome/browser/ui/confirm_bubble.h" 7 #include "chrome/browser/ui/confirm_bubble.h"
8 #include "chrome/browser/ui/confirm_bubble_model.h" 8 #include "chrome/browser/ui/confirm_bubble_model.h"
9 #include "grit/theme_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/image/image.h" 11 #include "ui/gfx/image/image.h"
12 #include "ui/views/controls/button/image_button.h" 12 #include "ui/views/controls/button/image_button.h"
13 #include "ui/views/controls/button/text_button.h" 13 #include "ui/views/controls/button/text_button.h"
14 #include "ui/views/controls/image_view.h" 14 #include "ui/views/controls/image_view.h"
15 #include "ui/views/controls/label.h" 15 #include "ui/views/controls/label.h"
16 #include "ui/views/controls/link.h" 16 #include "ui/views/controls/link.h"
17 #include "ui/views/layout/grid_layout.h" 17 #include "ui/views/layout/grid_layout.h"
18 #include "ui/views/layout/layout_constants.h" 18 #include "ui/views/layout/layout_constants.h"
19 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
(...skipping 28 matching lines...) Expand all
48 48
49 void ConfirmBubbleViews::LinkClicked(views::Link* source, int event_flags) { 49 void ConfirmBubbleViews::LinkClicked(views::Link* source, int event_flags) {
50 model_->LinkClicked(); 50 model_->LinkClicked();
51 } 51 }
52 52
53 gfx::Rect ConfirmBubbleViews::GetAnchorRect() { 53 gfx::Rect ConfirmBubbleViews::GetAnchorRect() {
54 return gfx::Rect(anchor_point_, gfx::Size()); 54 return gfx::Rect(anchor_point_, gfx::Size());
55 } 55 }
56 56
57 void ConfirmBubbleViews::Init() { 57 void ConfirmBubbleViews::Init() {
58 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
59 views::GridLayout* layout = new views::GridLayout(this); 58 views::GridLayout* layout = new views::GridLayout(this);
60 SetLayoutManager(layout); 59 SetLayoutManager(layout);
61 60
62 // Add the icon, the title label and the close button to the first row. 61 // Add the icon, the title label and the close button to the first row.
63 views::ColumnSet* cs = layout->AddColumnSet(0); 62 views::ColumnSet* cs = layout->AddColumnSet(0);
64 cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0, 63 cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0,
65 views::GridLayout::USE_PREF, 0, 0); 64 views::GridLayout::USE_PREF, 0, 0);
66 cs->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 65 cs->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
67 cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0, 66 cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0,
68 views::GridLayout::USE_PREF, 0, 0); 67 views::GridLayout::USE_PREF, 0, 0);
69 cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing); 68 cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing);
70 cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0, 69 cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0,
71 views::GridLayout::USE_PREF, 0, 0); 70 views::GridLayout::USE_PREF, 0, 0);
72 71
73 layout->StartRow(0, 0); 72 layout->StartRow(0, 0);
74 gfx::Image* icon_image = model_->GetIcon(); 73 gfx::Image* icon_image = model_->GetIcon();
75 DCHECK(icon_image); 74 DCHECK(icon_image);
76 views::ImageView* icon_view = new views::ImageView; 75 views::ImageView* icon_view = new views::ImageView;
77 icon_view->SetImage(icon_image->ToImageSkia()); 76 icon_view->SetImage(icon_image->ToImageSkia());
78 layout->AddView(icon_view); 77 layout->AddView(icon_view);
79 78
80 const string16 title_text = model_->GetTitle(); 79 const string16 title_text = model_->GetTitle();
81 DCHECK(!title_text.empty()); 80 DCHECK(!title_text.empty());
82 views::Label* title_label = new views::Label(title_text); 81 views::Label* title_label = new views::Label(title_text);
83 title_label->SetFont(bundle.GetFont(ui::ResourceBundle::MediumFont)); 82 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
83 title_label->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont));
84 layout->AddView(title_label); 84 layout->AddView(title_label);
85 85
86 views::ImageButton* close_button = new views::ImageButton(this); 86 views::ImageButton* close_button = new views::ImageButton(this);
87 const gfx::ImageSkia* close_image = 87 close_button->SetImage(views::CustomButton::STATE_NORMAL,
88 bundle.GetImageNamed(IDR_WEB_UI_CLOSE).ToImageSkia(); 88 rb.GetImageSkiaNamed(IDR_CLOSE_DIALOG));
89 close_button->SetImage(views::CustomButton::STATE_NORMAL, close_image); 89 close_button->SetImage(views::CustomButton::STATE_HOVERED,
90 rb.GetImageSkiaNamed(IDR_CLOSE_DIALOG_H));
91 close_button->SetImage(views::CustomButton::STATE_PRESSED,
92 rb.GetImageSkiaNamed(IDR_CLOSE_DIALOG_P));
90 close_button->set_tag(ConfirmBubbleModel::BUTTON_NONE); 93 close_button->set_tag(ConfirmBubbleModel::BUTTON_NONE);
91 layout->AddView(close_button); 94 layout->AddView(close_button);
92 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 95 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
93 96
94 // Add the message label to the second row. 97 // Add the message label to the second row.
95 cs = layout->AddColumnSet(1); 98 cs = layout->AddColumnSet(1);
96 const string16 message_text = model_->GetMessageText(); 99 const string16 message_text = model_->GetMessageText();
97 DCHECK(!message_text.empty()); 100 DCHECK(!message_text.empty());
98 views::Label* message_label = new views::Label(message_text); 101 views::Label* message_label = new views::Label(message_text);
99 int message_width = 102 int message_width =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 158
156 void ShowConfirmBubble(gfx::NativeView view, 159 void ShowConfirmBubble(gfx::NativeView view,
157 const gfx::Point& origin, 160 const gfx::Point& origin,
158 ConfirmBubbleModel* model) { 161 ConfirmBubbleModel* model) {
159 ConfirmBubbleViews* bubble = new ConfirmBubbleViews(origin, model); 162 ConfirmBubbleViews* bubble = new ConfirmBubbleViews(origin, model);
160 views::BubbleDelegateView::CreateBubble(bubble); 163 views::BubbleDelegateView::CreateBubble(bubble);
161 bubble->Show(); 164 bubble->Show();
162 } 165 }
163 166
164 } // namespace chrome 167 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/hover_close_button.mm ('k') | chrome/browser/ui/views/web_intent_picker_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698