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

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

Issue 10829452: Auto select the connection tab of the Website Settings UI in case of an https error or mixed content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and really upload the CL :) Created 8 years, 3 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/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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 views::View* anchor_view, 272 views::View* anchor_view,
273 Profile* profile, 273 Profile* profile,
274 TabContents* tab_contents, 274 TabContents* tab_contents,
275 const GURL& url, 275 const GURL& url,
276 const content::SSLStatus& ssl) 276 const content::SSLStatus& ssl)
277 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 277 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
278 tab_contents_(tab_contents), 278 tab_contents_(tab_contents),
279 header_(NULL), 279 header_(NULL),
280 tabbed_pane_(NULL), 280 tabbed_pane_(NULL),
281 site_data_content_(NULL), 281 site_data_content_(NULL),
282 connection_tab_(NULL),
282 cookie_dialog_link_(NULL), 283 cookie_dialog_link_(NULL),
283 permissions_content_(NULL), 284 permissions_content_(NULL),
284 identity_info_content_(NULL), 285 identity_info_content_(NULL),
285 certificate_dialog_link_(NULL), 286 certificate_dialog_link_(NULL),
286 cert_id_(0), 287 cert_id_(0),
287 connection_info_content_(NULL), 288 connection_info_content_(NULL),
288 page_info_content_(NULL) { 289 page_info_content_(NULL) {
289 // Compensate for built-in vertical padding in the anchor view's image. 290 // Compensate for built-in vertical padding in the anchor view's image.
290 set_anchor_insets(gfx::Insets(kLocationIconVerticalMargin, 0, 291 set_anchor_insets(gfx::Insets(kLocationIconVerticalMargin, 0,
291 kLocationIconVerticalMargin, 0)); 292 kLocationIconVerticalMargin, 0));
(...skipping 14 matching lines...) Expand all
306 layout->AddView(header_); 307 layout->AddView(header_);
307 308
308 layout->AddPaddingRow(1, kHeaderMarginBottom); 309 layout->AddPaddingRow(1, kHeaderMarginBottom);
309 tabbed_pane_ = new views::TabbedPane(); 310 tabbed_pane_ = new views::TabbedPane();
310 layout->StartRow(1, content_column); 311 layout->StartRow(1, content_column);
311 layout->AddView(tabbed_pane_); 312 layout->AddView(tabbed_pane_);
312 // Tabs must be added after the tabbed_pane_ was added to the views 313 // Tabs must be added after the tabbed_pane_ was added to the views
313 // hierachy. Adding the |tabbed_pane_| to the views hierachy triggers the 314 // hierachy. Adding the |tabbed_pane_| to the views hierachy triggers the
314 // initialization of the native tab UI element. If the native tab UI 315 // initialization of the native tab UI element. If the native tab UI
315 // element is not initalized adding a tab will result in a NULL pointer 316 // element is not initalized adding a tab will result in a NULL pointer
316 // excetion. 317 // exception.
317 tabbed_pane_->AddTab( 318 tabbed_pane_->AddTabAtIndex(
319 TAB_ID_PERMISSIONS,
318 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), 320 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS),
319 CreatePermissionsTab()); 321 CreatePermissionsTab(),
320 tabbed_pane_->AddTab( 322 true);
323 connection_tab_ = CreateConnectionTab();
324 tabbed_pane_->AddTabAtIndex(
325 TAB_ID_CONNECTION,
321 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), 326 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION),
322 CreateConnectionTab()); 327 connection_tab_,
323 tabbed_pane_->SelectTabAt(0); 328 true);
329 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS);
324 tabbed_pane_->set_listener(this); 330 tabbed_pane_->set_listener(this);
325 331
326 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, 332 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft,
327 kPopupMarginBottom, kPopupMarginRight)); 333 kPopupMarginBottom, kPopupMarginRight));
328 334
329 views::BubbleDelegateView::CreateBubble(this); 335 views::BubbleDelegateView::CreateBubble(this);
330 this->Show(); 336 this->Show();
331 SizeToContents(); 337 SizeToContents();
332 338
333 presenter_.reset(new WebsiteSettings(this, profile, 339 presenter_.reset(new WebsiteSettings(this, profile,
(...skipping 22 matching lines...) Expand all
356 GetWidget()->Close(); 362 GetWidget()->Close();
357 } 363 }
358 364
359 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, 365 void WebsiteSettingsPopupView::LinkClicked(views::Link* source,
360 int event_flags) { 366 int event_flags) {
361 if (source == cookie_dialog_link_) { 367 if (source == cookie_dialog_link_) {
362 new CollectedCookiesViews(tab_contents_); 368 new CollectedCookiesViews(tab_contents_);
363 } else if (source == certificate_dialog_link_) { 369 } else if (source == certificate_dialog_link_) {
364 gfx::NativeWindow parent = 370 gfx::NativeWindow parent =
365 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; 371 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL;
366 ShowCertificateViewerByID(tab_contents_->web_contents(), parent, cert_id_); 372 ShowCertificateViewerByID(tab_contents_->web_contents(), parent, cert_id_);
367 } 373 }
368 // The popup closes automatically when the collected cookies dialog or the 374 // The popup closes automatically when the collected cookies dialog or the
369 // certificate viewer opens. 375 // certificate viewer opens.
370 } 376 }
371 377
372 void WebsiteSettingsPopupView::TabSelectedAt(int index) { 378 void WebsiteSettingsPopupView::TabSelectedAt(int index) {
373 tabbed_pane_->GetSelectedTab()->Layout(); 379 tabbed_pane_->GetSelectedTab()->Layout();
374 SizeToContents(); 380 SizeToContents();
375 } 381 }
376 382
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 UTF8ToUTF16(identity_info.identity_status_description), 521 UTF8ToUTF16(identity_info.identity_status_description),
516 certificate_dialog_link_); 522 certificate_dialog_link_);
517 523
518 ResetConnectionSection( 524 ResetConnectionSection(
519 connection_info_content_, 525 connection_info_content_,
520 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), 526 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status),
521 string16(), // The connection section has no headline. 527 string16(), // The connection section has no headline.
522 UTF8ToUTF16(identity_info.connection_status_description), 528 UTF8ToUTF16(identity_info.connection_status_description),
523 NULL); 529 NULL);
524 530
531 connection_tab_->InvalidateLayout();
525 Layout(); 532 Layout();
526 SizeToContents(); 533 SizeToContents();
msw 2012/08/27 17:41:33 nit: I doubt all three (invalidate, layout, and si
markusheintz_ 2012/08/29 10:49:03 I've tried all sensible permutations. :(
527 } 534 }
528 535
529 void WebsiteSettingsPopupView::SetFirstVisit(const string16& first_visit) { 536 void WebsiteSettingsPopupView::SetFirstVisit(const string16& first_visit) {
530 ResetConnectionSection( 537 ResetConnectionSection(
531 page_info_content_, 538 page_info_content_,
532 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), 539 WebsiteSettingsUI::GetFirstVisitIcon(first_visit),
533 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE), 540 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE),
534 first_visit, 541 first_visit,
535 NULL); 542 NULL);
543 connection_tab_->InvalidateLayout();
536 Layout(); 544 Layout();
537 SizeToContents(); 545 SizeToContents();
538 } 546 }
539 547
548 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) {
549 tabbed_pane_->SelectTabAt(tab_id);
550 }
551
540 views::View* WebsiteSettingsPopupView::CreatePermissionsTab() { 552 views::View* WebsiteSettingsPopupView::CreatePermissionsTab() {
541 views::View* pane = new views::View(); 553 views::View* pane = new views::View();
542 pane->SetLayoutManager( 554 pane->SetLayoutManager(
543 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); 555 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1));
544 // Add cookies and site data section. 556 // Add cookies and site data section.
545 cookie_dialog_link_ = new views::Link( 557 cookie_dialog_link_ = new views::Link(
546 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_SHOW_SITE_DATA)); 558 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_SHOW_SITE_DATA));
547 cookie_dialog_link_->set_listener(this); 559 cookie_dialog_link_->set_listener(this);
548 site_data_content_ = new views::View(); 560 site_data_content_ = new views::View();
549 views::View* site_data_section = 561 views::View* site_data_section =
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 706
695 if (link) { 707 if (link) {
696 content_layout->StartRow(1, 0); 708 content_layout->StartRow(1, 0);
697 content_layout->AddView(link); 709 content_layout->AddView(link);
698 } 710 }
699 711
700 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, 712 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING,
701 views::GridLayout::LEADING); 713 views::GridLayout::LEADING);
702 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); 714 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom);
703 } 715 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698