| OLD | NEW |
| 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/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/certificate_viewer.h" | 9 #include "chrome/browser/certificate_viewer.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/views/collected_cookies_views.h" | 13 #include "chrome/browser/ui/views/collected_cookies_views.h" |
| 14 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" | 14 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" |
| 15 #include "chrome/browser/ui/website_settings/website_settings.h" | 15 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 16 #include "chrome/browser/ui/website_settings/website_settings_utils.h" | 16 #include "chrome/browser/ui/website_settings/website_settings_utils.h" |
| 17 #include "chrome/common/content_settings_types.h" | 17 #include "chrome/common/content_settings_types.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/cert_store.h" | 20 #include "content/public/browser/cert_store.h" |
| 20 #include "content/public/browser/user_metrics.h" | 21 #include "content/public/browser/user_metrics.h" |
| 21 #include "grit/chromium_strings.h" | 22 #include "grit/chromium_strings.h" |
| 22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 24 #include "grit/ui_resources.h" | 25 #include "grit/ui_resources.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/base/models/simple_menu_model.h" | 27 #include "ui/base/models/simple_menu_model.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/canvas.h" | 29 #include "ui/gfx/canvas.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 tabbed_pane_(NULL), | 284 tabbed_pane_(NULL), |
| 284 site_data_content_(NULL), | 285 site_data_content_(NULL), |
| 285 cookie_dialog_link_(NULL), | 286 cookie_dialog_link_(NULL), |
| 286 permissions_content_(NULL), | 287 permissions_content_(NULL), |
| 287 connection_tab_(NULL), | 288 connection_tab_(NULL), |
| 288 identity_info_content_(NULL), | 289 identity_info_content_(NULL), |
| 289 certificate_dialog_link_(NULL), | 290 certificate_dialog_link_(NULL), |
| 290 cert_id_(0), | 291 cert_id_(0), |
| 291 help_center_link_(NULL), | 292 help_center_link_(NULL), |
| 292 connection_info_content_(NULL), | 293 connection_info_content_(NULL), |
| 293 page_info_content_(NULL) { | 294 page_info_content_(NULL), |
| 295 weak_factory_(this) { |
| 294 // Compensate for built-in vertical padding in the anchor view's image. | 296 // Compensate for built-in vertical padding in the anchor view's image. |
| 295 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, | 297 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, |
| 296 kLocationIconVerticalMargin, 0)); | 298 kLocationIconVerticalMargin, 0)); |
| 297 | 299 |
| 298 views::GridLayout* layout = new views::GridLayout(this); | 300 views::GridLayout* layout = new views::GridLayout(this); |
| 299 SetLayoutManager(layout); | 301 SetLayoutManager(layout); |
| 300 const int content_column = 0; | 302 const int content_column = 0; |
| 301 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | 303 views::ColumnSet* column_set = layout->AddColumnSet(content_column); |
| 302 column_set->AddColumn(views::GridLayout::FILL, | 304 column_set->AddColumn(views::GridLayout::FILL, |
| 303 views::GridLayout::FILL, | 305 views::GridLayout::FILL, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 } | 358 } |
| 357 | 359 |
| 358 void WebsiteSettingsPopupView::ButtonPressed( | 360 void WebsiteSettingsPopupView::ButtonPressed( |
| 359 views::Button* button, | 361 views::Button* button, |
| 360 const ui::Event& event) { | 362 const ui::Event& event) { |
| 361 GetWidget()->Close(); | 363 GetWidget()->Close(); |
| 362 } | 364 } |
| 363 | 365 |
| 364 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | 366 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, |
| 365 int event_flags) { | 367 int event_flags) { |
| 366 if (source == cookie_dialog_link_) { | |
| 367 // Count how often the Collected Cookies dialog is opened. | |
| 368 content::RecordAction( | |
| 369 content::UserMetricsAction("WebsiteSettings_CookiesDialogOpened")); | |
| 370 new CollectedCookiesViews(web_contents_); | |
| 371 } else if (source == certificate_dialog_link_) { | |
| 372 gfx::NativeWindow parent = | |
| 373 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; | |
| 374 ShowCertificateViewerByID(web_contents_, parent, cert_id_); | |
| 375 } else if (source == help_center_link_) { | |
| 376 browser_->OpenURL(content::OpenURLParams( | |
| 377 GURL(chrome::kPageInfoHelpCenterURL), | |
| 378 content::Referrer(), | |
| 379 NEW_FOREGROUND_TAB, | |
| 380 content::PAGE_TRANSITION_LINK, | |
| 381 false)); | |
| 382 } | |
| 383 // The popup closes automatically when the collected cookies dialog or the | 368 // The popup closes automatically when the collected cookies dialog or the |
| 384 // certificate viewer opens. | 369 // certificate viewer opens. So delay handling of the link clicked to avoid |
| 370 // a crash in the base class which needs to complete the mouse event handling. |
| 371 content::BrowserThread::PostTask( |
| 372 content::BrowserThread::UI, FROM_HERE, |
| 373 base::Bind(&WebsiteSettingsPopupView::HandleLinkClickedAsync, |
| 374 weak_factory_.GetWeakPtr(), source)); |
| 385 } | 375 } |
| 386 | 376 |
| 387 void WebsiteSettingsPopupView::TabSelectedAt(int index) { | 377 void WebsiteSettingsPopupView::TabSelectedAt(int index) { |
| 388 tabbed_pane_->GetSelectedTab()->Layout(); | 378 tabbed_pane_->GetSelectedTab()->Layout(); |
| 389 SizeToContents(); | 379 SizeToContents(); |
| 390 } | 380 } |
| 391 | 381 |
| 392 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() { | 382 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() { |
| 393 if (header_ == NULL && tabbed_pane_ == NULL) | 383 if (header_ == NULL && tabbed_pane_ == NULL) |
| 394 return views::View::GetPreferredSize(); | 384 return views::View::GetPreferredSize(); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 732 |
| 743 if (link) { | 733 if (link) { |
| 744 content_layout->StartRow(1, 0); | 734 content_layout->StartRow(1, 0); |
| 745 content_layout->AddView(link); | 735 content_layout->AddView(link); |
| 746 } | 736 } |
| 747 | 737 |
| 748 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, | 738 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, |
| 749 views::GridLayout::LEADING); | 739 views::GridLayout::LEADING); |
| 750 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); | 740 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); |
| 751 } | 741 } |
| 742 |
| 743 // Used to asynchronously handle clicks since these calls may cause the |
| 744 // destruction of the settings view and the base class window still |
| 745 // needs to be alive to finish handling the mouse click. |
| 746 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { |
| 747 if (source == cookie_dialog_link_) { |
| 748 // Count how often the Collected Cookies dialog is opened. |
| 749 content::RecordAction( |
| 750 content::UserMetricsAction("WebsiteSettings_CookiesDialogOpened")); |
| 751 new CollectedCookiesViews(web_contents_); |
| 752 } else if (source == certificate_dialog_link_) { |
| 753 gfx::NativeWindow parent = |
| 754 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; |
| 755 ShowCertificateViewerByID(web_contents_, parent, cert_id_); |
| 756 } else if (source == help_center_link_) { |
| 757 browser_->OpenURL(content::OpenURLParams( |
| 758 GURL(chrome::kPageInfoHelpCenterURL), |
| 759 content::Referrer(), |
| 760 NEW_FOREGROUND_TAB, |
| 761 content::PAGE_TRANSITION_LINK, |
| 762 false)); |
| 763 } |
| 764 } |
| OLD | NEW |