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

Side by Side Diff: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc

Issue 10828201: (Views only) Create a separate class for the contents of the Website Settings UI that is displayed … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/website_settings/website_settings_popup_view.h " 5 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h "
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/certificate_viewer.h" 9 #include "chrome/browser/certificate_viewer.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 private: 128 private:
129 // The label that displays the name of the site's identity. 129 // The label that displays the name of the site's identity.
130 views::Label* name_; 130 views::Label* name_;
131 // The label that displays the status of the identity check for this site. 131 // The label that displays the status of the identity check for this site.
132 views::Label* status_; 132 views::Label* status_;
133 133
134 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); 134 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView);
135 }; 135 };
136 136
137 // Website Settings are not supported for internal Chrome pages. Instead of the
138 // |WebsiteSettingsPopupView| the |WebsiteSettingsInternalPageView| is
139 // displayed.
140 class WebsiteSettingsInternalPageView : public views::BubbleDelegateView {
141 public:
142 explicit WebsiteSettingsInternalPageView(views::View* anchor_view);
143 virtual ~WebsiteSettingsInternalPageView();
144
145 // views::BubbleDelegate implementations.
146 virtual gfx::Rect GetAnchorRect() OVERRIDE;
tfarina 2012/08/08 02:32:46 nit: can this be private? please.
markusheintz_ 2012/08/08 13:20:13 Done.
147
148 private:
149 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsInternalPageView);
150 };
151
137 //////////////////////////////////////////////////////////////////////////////// 152 ////////////////////////////////////////////////////////////////////////////////
138 // Popup Header 153 // Popup Header
139 //////////////////////////////////////////////////////////////////////////////// 154 ////////////////////////////////////////////////////////////////////////////////
140 155
141 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) 156 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener)
142 : name_(NULL), status_(NULL) { 157 : name_(NULL), status_(NULL) {
143 views::GridLayout* layout = new views::GridLayout(this); 158 views::GridLayout* layout = new views::GridLayout(this);
144 SetLayoutManager(layout); 159 SetLayoutManager(layout);
145 160
146 const int label_column = 0; 161 const int label_column = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void PopupHeaderView::SetIdentityName(const string16& name) { 215 void PopupHeaderView::SetIdentityName(const string16& name) {
201 name_->SetText(name); 216 name_->SetText(name);
202 } 217 }
203 218
204 void PopupHeaderView::SetIdentityStatus(const string16& status, 219 void PopupHeaderView::SetIdentityStatus(const string16& status,
205 SkColor text_color) { 220 SkColor text_color) {
206 status_->SetText(status); 221 status_->SetText(status);
207 status_->SetEnabledColor(text_color); 222 status_->SetEnabledColor(text_color);
208 } 223 }
209 224
210 /////////////////////////////////////////////////////////////////////////////// 225 ////////////////////////////////////////////////////////////////////////////////
226 // WebsiteSettingsInternalPageView
227 ////////////////////////////////////////////////////////////////////////////////
228
229 WebsiteSettingsInternalPageView::WebsiteSettingsInternalPageView(
230 views::View* anchor_view)
231 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) {
232 views::GridLayout* layout = new views::GridLayout(this);
msw 2012/08/07 22:21:49 GridLayout seems overkill here, please try a BoxLa
tfarina 2012/08/08 02:32:46 I don't like doing many things in constructors. Is
markusheintz_ 2012/08/08 13:20:13 In general I agree with you. But in this particula
markusheintz_ 2012/08/08 13:20:13 Done.
233 SetLayoutManager(layout);
234 views::ColumnSet* column_set = layout->AddColumnSet(0);
235 column_set->AddColumn(views::GridLayout::FILL,
236 views::GridLayout::FILL,
237 0, // Resize weight.
238 views::GridLayout::USE_PREF,
239 0,
240 0);
241 column_set->AddPaddingColumn(0, kIconMarginLeft);
242 column_set->AddColumn(views::GridLayout::FILL,
243 views::GridLayout::FILL,
244 1,
245 views::GridLayout::USE_PREF,
246 0,
247 0);
248
249 layout->StartRow(1, 0);
250
251 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
252 const gfx::Image& icon = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26);
253 views::ImageView* icon_view = new views::ImageView();
254 icon_view->SetImage(icon.ToImageSkia());
255 layout->AddView(icon_view, 1, 1, views::GridLayout::LEADING,
256 views::GridLayout::LEADING);
257
258 string16 text = l10n_util::GetStringUTF16(
259 IDS_PAGE_INFO_INTERNAL_PAGE);
260 views::Label* label = new views::Label(text);
261 label->SetMultiLine(true);
262 label->SetAllowCharacterBreak(true);
263 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
264 layout->AddView(label, 1, 1, views::GridLayout::LEADING,
265 views::GridLayout::CENTER);
266
267 views::BubbleDelegateView::CreateBubble(this);
268 Show();
269 SizeToContents();
270 }
271
272 WebsiteSettingsInternalPageView::~WebsiteSettingsInternalPageView() {
273 }
274
275 gfx::Rect WebsiteSettingsInternalPageView::GetAnchorRect() {
276 // Compensate for some built-in padding in the icon. This will make the arrow
277 // point to the middle of the icon.
278 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
279 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0);
280 return anchor;
281 }
282
283 ////////////////////////////////////////////////////////////////////////////////
211 // WebsiteSettingsPopupView 284 // WebsiteSettingsPopupView
212 /////////////////////////////////////////////////////////////////////////////// 285 ////////////////////////////////////////////////////////////////////////////////
213 286
214 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { 287 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() {
215 } 288 }
216 289
217 // static 290 // static
218 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, 291 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view,
219 Profile* profile, 292 Profile* profile,
220 TabContents* tab_contents, 293 TabContents* tab_contents,
221 const GURL& url, 294 const GURL& url,
222 const content::SSLStatus& ssl) { 295 const content::SSLStatus& ssl) {
223 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl); 296 if (InternalChromePage(url))
297 new WebsiteSettingsInternalPageView(anchor_view);
298 else
299 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl);
224 } 300 }
225 301
226 WebsiteSettingsPopupView::WebsiteSettingsPopupView( 302 WebsiteSettingsPopupView::WebsiteSettingsPopupView(
227 views::View* anchor_view, 303 views::View* anchor_view,
228 Profile* profile, 304 Profile* profile,
229 TabContents* tab_contents, 305 TabContents* tab_contents,
230 const GURL& url, 306 const GURL& url,
231 const content::SSLStatus& ssl) 307 const content::SSLStatus& ssl)
232 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 308 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
233 tab_contents_(tab_contents), 309 tab_contents_(tab_contents),
234 header_(NULL), 310 header_(NULL),
235 tabbed_pane_(NULL), 311 tabbed_pane_(NULL),
236 site_data_content_(NULL), 312 site_data_content_(NULL),
237 cookie_dialog_link_(NULL), 313 cookie_dialog_link_(NULL),
238 permissions_content_(NULL), 314 permissions_content_(NULL),
239 identity_info_content_(NULL), 315 identity_info_content_(NULL),
240 certificate_dialog_link_(NULL), 316 certificate_dialog_link_(NULL),
241 cert_id_(0), 317 cert_id_(0),
242 connection_info_content_(NULL), 318 connection_info_content_(NULL),
243 page_info_content_(NULL) { 319 page_info_content_(NULL) {
244 if (InternalChromePage(url)) {
245 views::GridLayout* layout = new views::GridLayout(this);
246 SetLayoutManager(layout);
247 views::ColumnSet* column_set = layout->AddColumnSet(0);
248 column_set->AddColumn(views::GridLayout::FILL,
249 views::GridLayout::FILL,
250 0, // Resize weight.
251 views::GridLayout::USE_PREF,
252 0,
253 0);
254 column_set->AddPaddingColumn(0, kIconMarginLeft);
255 column_set->AddColumn(views::GridLayout::FILL,
256 views::GridLayout::FILL,
257 1,
258 views::GridLayout::USE_PREF,
259 0,
260 0);
261
262 layout->StartRow(1, 0);
263
264 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
265 const gfx::Image& icon = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26);
266 views::ImageView* icon_view = new views::ImageView();
267 icon_view->SetImage(icon.ToImageSkia());
268 layout->AddView(icon_view, 1, 1, views::GridLayout::LEADING,
269 views::GridLayout::LEADING);
270
271 string16 text = l10n_util::GetStringUTF16(
272 IDS_PAGE_INFO_INTERNAL_PAGE);
273 views::Label* label = new views::Label(text);
274 label->SetMultiLine(true);
275 label->SetAllowCharacterBreak(true);
276 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
277 layout->AddView(label, 1, 1, views::GridLayout::LEADING,
278 views::GridLayout::CENTER);
279
280 views::BubbleDelegateView::CreateBubble(this);
281 Show();
282 SizeToContents();
283 } else {
284 // Non internal chrome page.
285 views::GridLayout* layout = new views::GridLayout(this); 320 views::GridLayout* layout = new views::GridLayout(this);
286 SetLayoutManager(layout); 321 SetLayoutManager(layout);
287 const int content_column = 0; 322 const int content_column = 0;
288 views::ColumnSet* column_set = layout->AddColumnSet(content_column); 323 views::ColumnSet* column_set = layout->AddColumnSet(content_column);
289 column_set->AddColumn(views::GridLayout::FILL, 324 column_set->AddColumn(views::GridLayout::FILL,
290 views::GridLayout::FILL, 325 views::GridLayout::FILL,
291 1, 326 1,
292 views::GridLayout::USE_PREF, 327 views::GridLayout::USE_PREF,
293 0, 328 0,
294 0); 329 0);
(...skipping 26 matching lines...) Expand all
321 views::BubbleDelegateView::CreateBubble(this); 356 views::BubbleDelegateView::CreateBubble(this);
322 this->Show(); 357 this->Show();
323 SizeToContents(); 358 SizeToContents();
324 359
325 presenter_.reset(new WebsiteSettings(this, profile, 360 presenter_.reset(new WebsiteSettings(this, profile,
326 tab_contents->content_settings(), 361 tab_contents->content_settings(),
327 tab_contents->infobar_tab_helper(), 362 tab_contents->infobar_tab_helper(),
328 url, 363 url,
329 ssl, 364 ssl,
330 content::CertStore::GetInstance())); 365 content::CertStore::GetInstance()));
331 }
332 } 366 }
333 367
334 void WebsiteSettingsPopupView::OnPermissionChanged( 368 void WebsiteSettingsPopupView::OnPermissionChanged(
335 PermissionSelectorView* permission_selector) { 369 PermissionSelectorView* permission_selector) {
336 DCHECK(permission_selector); 370 DCHECK(permission_selector);
337 // It's not necessary to check that the |presenter_| is not NULL since for
338 // internal chrome pages OnPermissionChanged can't be called.
339 presenter_->OnSitePermissionChanged( 371 presenter_->OnSitePermissionChanged(
340 permission_selector->GetPermissionType(), 372 permission_selector->GetPermissionType(),
341 permission_selector->GetSelectedSetting()); 373 permission_selector->GetSelectedSetting());
342 } 374 }
343 375
344 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() { 376 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() {
345 // Compensate for some built-in padding in the icon. This will make the arrow 377 // Compensate for some built-in padding in the icon. This will make the arrow
346 // point to the middle of the icon. 378 // point to the middle of the icon.
347 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); 379 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
348 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); 380 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0);
349 return anchor; 381 return anchor;
350 } 382 }
351 383
352 void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) { 384 void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) {
353 if (presenter_.get()) 385 presenter_->OnUIClosing();
354 presenter_->OnUIClosing();
355 } 386 }
356 387
357 void WebsiteSettingsPopupView::ButtonPressed( 388 void WebsiteSettingsPopupView::ButtonPressed(
358 views::Button* button, 389 views::Button* button,
359 const views::Event& event) { 390 const views::Event& event) {
360 GetWidget()->Close(); 391 GetWidget()->Close();
361 } 392 }
362 393
363 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, 394 void WebsiteSettingsPopupView::LinkClicked(views::Link* source,
364 int event_flags) { 395 int event_flags) {
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 729
699 if (link) { 730 if (link) {
700 content_layout->StartRow(1, 0); 731 content_layout->StartRow(1, 0);
701 content_layout->AddView(link); 732 content_layout->AddView(link);
702 } 733 }
703 734
704 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, 735 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING,
705 views::GridLayout::LEADING); 736 views::GridLayout::LEADING);
706 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); 737 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom);
707 } 738 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698