| 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/page_info/website_settings_popup_view.h" | 5 #include "chrome/browser/ui/views/page_info/page_info_popup_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/certificate_viewer.h" | 18 #include "chrome/browser/certificate_viewer.h" |
| 19 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_dialogs.h" | 22 #include "chrome/browser/ui/browser_dialogs.h" |
| 23 #include "chrome/browser/ui/layout_constants.h" | 23 #include "chrome/browser/ui/layout_constants.h" |
| 24 #include "chrome/browser/ui/page_info/website_settings.h" | 24 #include "chrome/browser/ui/page_info/page_info.h" |
| 25 #include "chrome/browser/ui/views/collected_cookies_views.h" | 25 #include "chrome/browser/ui/views/collected_cookies_views.h" |
| 26 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | 26 #include "chrome/browser/ui/views/harmony/layout_delegate.h" |
| 27 #include "chrome/browser/ui/views/page_info/chosen_object_row.h" | 27 #include "chrome/browser/ui/views/page_info/chosen_object_row.h" |
| 28 #include "chrome/browser/ui/views/page_info/non_accessible_image_view.h" | 28 #include "chrome/browser/ui/views/page_info/non_accessible_image_view.h" |
| 29 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" | 29 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "chrome/grit/chromium_strings.h" | 31 #include "chrome/grit/chromium_strings.h" |
| 32 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
| 33 #include "chrome/grit/theme_resources.h" | 33 #include "chrome/grit/theme_resources.h" |
| 34 #include "components/content_settings/core/common/content_settings_types.h" | 34 #include "components/content_settings/core/common/content_settings_types.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 61 #include "url/gurl.h" | 61 #include "url/gurl.h" |
| 62 | 62 |
| 63 namespace { | 63 namespace { |
| 64 | 64 |
| 65 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's | 65 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's |
| 66 // never more than one website settings popup shown and that it's associated | 66 // never more than one website settings popup shown and that it's associated |
| 67 // with the current window. If this assumption fails in the future, we'll need | 67 // with the current window. If this assumption fails in the future, we'll need |
| 68 // to return a weak pointer from ShowPopup so callers can associate it with the | 68 // to return a weak pointer from ShowPopup so callers can associate it with the |
| 69 // current window (or other context) and check if the popup they care about is | 69 // current window (or other context) and check if the popup they care about is |
| 70 // showing. | 70 // showing. |
| 71 WebsiteSettingsPopupView::PopupType g_shown_popup_type = | 71 PageInfoPopupView::PopupType g_shown_popup_type = PageInfoPopupView::POPUP_NONE; |
| 72 WebsiteSettingsPopupView::POPUP_NONE; | |
| 73 | 72 |
| 74 // General constants ----------------------------------------------------------- | 73 // General constants ----------------------------------------------------------- |
| 75 | 74 |
| 76 // Popup width constraints. | 75 // Popup width constraints. |
| 77 const int kMinPopupWidth = 320; | 76 const int kMinPopupWidth = 320; |
| 78 const int kMaxPopupWidth = 1000; | 77 const int kMaxPopupWidth = 1000; |
| 79 | 78 |
| 80 // Security Section (PopupHeaderView) ------------------------------------------ | 79 // Security Section (PopupHeaderView) ------------------------------------------ |
| 81 | 80 |
| 82 // Margin and padding values for the |PopupHeaderView|. | 81 // Margin and padding values for the |PopupHeaderView|. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 views::ColumnSet* column_set = layout->AddColumnSet(id); | 116 views::ColumnSet* column_set = layout->AddColumnSet(id); |
| 118 column_set->AddPaddingColumn(0, margin); | 117 column_set->AddPaddingColumn(0, margin); |
| 119 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 118 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| 120 views::GridLayout::USE_PREF, 0, 0); | 119 views::GridLayout::USE_PREF, 0, 0); |
| 121 column_set->AddPaddingColumn(0, margin); | 120 column_set->AddPaddingColumn(0, margin); |
| 122 } | 121 } |
| 123 | 122 |
| 124 } // namespace | 123 } // namespace |
| 125 | 124 |
| 126 // |PopupHeaderView| is the UI element (view) that represents the header of the | 125 // |PopupHeaderView| is the UI element (view) that represents the header of the |
| 127 // |WebsiteSettingsPopupView|. The header shows the status of the site's | 126 // |PageInfoPopupView|. The header shows the status of the site's |
| 128 // identity check and the name of the site's identity. | 127 // identity check and the name of the site's identity. |
| 129 class PopupHeaderView : public views::View { | 128 class PopupHeaderView : public views::View { |
| 130 public: | 129 public: |
| 131 PopupHeaderView(views::ButtonListener* button_listener, | 130 PopupHeaderView(views::ButtonListener* button_listener, |
| 132 views::StyledLabelListener* styled_label_listener, | 131 views::StyledLabelListener* styled_label_listener, |
| 133 int side_margin); | 132 int side_margin); |
| 134 ~PopupHeaderView() override; | 133 ~PopupHeaderView() override; |
| 135 | 134 |
| 136 // Sets the security summary for the current page. | 135 // Sets the security summary for the current page. |
| 137 void SetSummary(const base::string16& summary_text); | 136 void SetSummary(const base::string16& summary_text); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 153 // A container for the styled label with a link for resetting cert decisions. | 152 // A container for the styled label with a link for resetting cert decisions. |
| 154 // This is only shown sometimes, so we use a container to keep track of | 153 // This is only shown sometimes, so we use a container to keep track of |
| 155 // where to place it (if needed). | 154 // where to place it (if needed). |
| 156 views::View* reset_decisions_label_container_; | 155 views::View* reset_decisions_label_container_; |
| 157 views::StyledLabel* reset_decisions_label_; | 156 views::StyledLabel* reset_decisions_label_; |
| 158 | 157 |
| 159 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); | 158 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); |
| 160 }; | 159 }; |
| 161 | 160 |
| 162 // Website Settings are not supported for internal Chrome pages and extension | 161 // Website Settings are not supported for internal Chrome pages and extension |
| 163 // pages. Instead of the |WebsiteSettingsPopupView|, the | 162 // pages. Instead of the |PageInfoPopupView|, the |
| 164 // |InternalPageInfoPopupView| is displayed. | 163 // |InternalPageInfoPopupView| is displayed. |
| 165 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { | 164 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { |
| 166 public: | 165 public: |
| 167 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be | 166 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be |
| 168 // provided to ensure this bubble is closed when the parent closes. | 167 // provided to ensure this bubble is closed when the parent closes. |
| 169 InternalPageInfoPopupView(views::View* anchor_view, | 168 InternalPageInfoPopupView(views::View* anchor_view, |
| 170 gfx::NativeView parent_window, | 169 gfx::NativeView parent_window, |
| 171 const GURL& url); | 170 const GURL& url); |
| 172 ~InternalPageInfoPopupView() override; | 171 ~InternalPageInfoPopupView() override; |
| 173 | 172 |
| 174 // views::BubbleDialogDelegateView: | 173 // views::BubbleDialogDelegateView: |
| 175 void OnWidgetDestroying(views::Widget* widget) override; | 174 void OnWidgetDestroying(views::Widget* widget) override; |
| 176 int GetDialogButtons() const override; | 175 int GetDialogButtons() const override; |
| 177 | 176 |
| 178 private: | 177 private: |
| 179 friend class WebsiteSettingsPopupView; | 178 friend class PageInfoPopupView; |
| 180 | 179 |
| 181 // Used around icon and inside bubble border. | 180 // Used around icon and inside bubble border. |
| 182 static constexpr int kSpacing = 12; | 181 static constexpr int kSpacing = 12; |
| 183 | 182 |
| 184 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | 183 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); |
| 185 }; | 184 }; |
| 186 | 185 |
| 187 //////////////////////////////////////////////////////////////////////////////// | 186 //////////////////////////////////////////////////////////////////////////////// |
| 188 // Popup Header | 187 // Popup Header |
| 189 //////////////////////////////////////////////////////////////////////////////// | 188 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 277 |
| 279 //////////////////////////////////////////////////////////////////////////////// | 278 //////////////////////////////////////////////////////////////////////////////// |
| 280 // InternalPageInfoPopupView | 279 // InternalPageInfoPopupView |
| 281 //////////////////////////////////////////////////////////////////////////////// | 280 //////////////////////////////////////////////////////////////////////////////// |
| 282 | 281 |
| 283 InternalPageInfoPopupView::InternalPageInfoPopupView( | 282 InternalPageInfoPopupView::InternalPageInfoPopupView( |
| 284 views::View* anchor_view, | 283 views::View* anchor_view, |
| 285 gfx::NativeView parent_window, | 284 gfx::NativeView parent_window, |
| 286 const GURL& url) | 285 const GURL& url) |
| 287 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { | 286 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { |
| 288 g_shown_popup_type = WebsiteSettingsPopupView::POPUP_INTERNAL_PAGE; | 287 g_shown_popup_type = PageInfoPopupView::POPUP_INTERNAL_PAGE; |
| 289 set_parent_window(parent_window); | 288 set_parent_window(parent_window); |
| 290 | 289 |
| 291 int text = IDS_PAGE_INFO_INTERNAL_PAGE; | 290 int text = IDS_PAGE_INFO_INTERNAL_PAGE; |
| 292 int icon = IDR_PRODUCT_LOGO_16; | 291 int icon = IDR_PRODUCT_LOGO_16; |
| 293 if (url.SchemeIs(extensions::kExtensionScheme)) { | 292 if (url.SchemeIs(extensions::kExtensionScheme)) { |
| 294 text = IDS_PAGE_INFO_EXTENSION_PAGE; | 293 text = IDS_PAGE_INFO_EXTENSION_PAGE; |
| 295 icon = IDR_PLUGINS_FAVICON; | 294 icon = IDR_PLUGINS_FAVICON; |
| 296 } else if (url.SchemeIs(content::kViewSourceScheme)) { | 295 } else if (url.SchemeIs(content::kViewSourceScheme)) { |
| 297 text = IDS_PAGE_INFO_VIEW_SOURCE_PAGE; | 296 text = IDS_PAGE_INFO_VIEW_SOURCE_PAGE; |
| 298 // view-source scheme uses the same icon as chrome:// pages. | 297 // view-source scheme uses the same icon as chrome:// pages. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 319 label->SetAllowCharacterBreak(true); | 318 label->SetAllowCharacterBreak(true); |
| 320 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 319 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 321 AddChildView(label); | 320 AddChildView(label); |
| 322 | 321 |
| 323 views::BubbleDialogDelegateView::CreateBubble(this); | 322 views::BubbleDialogDelegateView::CreateBubble(this); |
| 324 } | 323 } |
| 325 | 324 |
| 326 InternalPageInfoPopupView::~InternalPageInfoPopupView() {} | 325 InternalPageInfoPopupView::~InternalPageInfoPopupView() {} |
| 327 | 326 |
| 328 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { | 327 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 329 g_shown_popup_type = WebsiteSettingsPopupView::POPUP_NONE; | 328 g_shown_popup_type = PageInfoPopupView::POPUP_NONE; |
| 330 } | 329 } |
| 331 | 330 |
| 332 int InternalPageInfoPopupView::GetDialogButtons() const { | 331 int InternalPageInfoPopupView::GetDialogButtons() const { |
| 333 return ui::DIALOG_BUTTON_NONE; | 332 return ui::DIALOG_BUTTON_NONE; |
| 334 } | 333 } |
| 335 | 334 |
| 336 //////////////////////////////////////////////////////////////////////////////// | 335 //////////////////////////////////////////////////////////////////////////////// |
| 337 // WebsiteSettingsPopupView | 336 // PageInfoPopupView |
| 338 //////////////////////////////////////////////////////////////////////////////// | 337 //////////////////////////////////////////////////////////////////////////////// |
| 339 | 338 |
| 340 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() {} | 339 PageInfoPopupView::~PageInfoPopupView() {} |
| 341 | 340 |
| 342 // static | 341 // static |
| 343 void WebsiteSettingsPopupView::ShowPopup( | 342 void PageInfoPopupView::ShowPopup( |
| 344 views::View* anchor_view, | 343 views::View* anchor_view, |
| 345 const gfx::Rect& anchor_rect, | 344 const gfx::Rect& anchor_rect, |
| 346 Profile* profile, | 345 Profile* profile, |
| 347 content::WebContents* web_contents, | 346 content::WebContents* web_contents, |
| 348 const GURL& url, | 347 const GURL& url, |
| 349 const security_state::SecurityInfo& security_info) { | 348 const security_state::SecurityInfo& security_info) { |
| 350 gfx::NativeView parent_window = | 349 gfx::NativeView parent_window = |
| 351 anchor_view ? nullptr : web_contents->GetNativeView(); | 350 anchor_view ? nullptr : web_contents->GetNativeView(); |
| 352 if (url.SchemeIs(content::kChromeUIScheme) || | 351 if (url.SchemeIs(content::kChromeUIScheme) || |
| 353 url.SchemeIs(content::kChromeDevToolsScheme) || | 352 url.SchemeIs(content::kChromeDevToolsScheme) || |
| 354 url.SchemeIs(extensions::kExtensionScheme) || | 353 url.SchemeIs(extensions::kExtensionScheme) || |
| 355 url.SchemeIs(content::kViewSourceScheme)) { | 354 url.SchemeIs(content::kViewSourceScheme)) { |
| 356 // Use the concrete type so that |SetAnchorRect| can be called as a friend. | 355 // Use the concrete type so that |SetAnchorRect| can be called as a friend. |
| 357 InternalPageInfoPopupView* popup = | 356 InternalPageInfoPopupView* popup = |
| 358 new InternalPageInfoPopupView(anchor_view, parent_window, url); | 357 new InternalPageInfoPopupView(anchor_view, parent_window, url); |
| 359 if (!anchor_view) | 358 if (!anchor_view) |
| 360 popup->SetAnchorRect(anchor_rect); | 359 popup->SetAnchorRect(anchor_rect); |
| 361 popup->GetWidget()->Show(); | 360 popup->GetWidget()->Show(); |
| 362 return; | 361 return; |
| 363 } | 362 } |
| 364 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView( | 363 PageInfoPopupView* popup = new PageInfoPopupView( |
| 365 anchor_view, parent_window, profile, web_contents, url, security_info); | 364 anchor_view, parent_window, profile, web_contents, url, security_info); |
| 366 if (!anchor_view) | 365 if (!anchor_view) |
| 367 popup->SetAnchorRect(anchor_rect); | 366 popup->SetAnchorRect(anchor_rect); |
| 368 popup->GetWidget()->Show(); | 367 popup->GetWidget()->Show(); |
| 369 } | 368 } |
| 370 | 369 |
| 371 // static | 370 // static |
| 372 WebsiteSettingsPopupView::PopupType | 371 PageInfoPopupView::PopupType PageInfoPopupView::GetShownPopupType() { |
| 373 WebsiteSettingsPopupView::GetShownPopupType() { | |
| 374 return g_shown_popup_type; | 372 return g_shown_popup_type; |
| 375 } | 373 } |
| 376 | 374 |
| 377 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | 375 PageInfoPopupView::PageInfoPopupView( |
| 378 views::View* anchor_view, | 376 views::View* anchor_view, |
| 379 gfx::NativeView parent_window, | 377 gfx::NativeView parent_window, |
| 380 Profile* profile, | 378 Profile* profile, |
| 381 content::WebContents* web_contents, | 379 content::WebContents* web_contents, |
| 382 const GURL& url, | 380 const GURL& url, |
| 383 const security_state::SecurityInfo& security_info) | 381 const security_state::SecurityInfo& security_info) |
| 384 : content::WebContentsObserver(web_contents), | 382 : content::WebContentsObserver(web_contents), |
| 385 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 383 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
| 386 profile_(profile), | 384 profile_(profile), |
| 387 header_(nullptr), | 385 header_(nullptr), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 433 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 436 // In non-material, titles are inset from the dialog margin. Ensure the | 434 // In non-material, titles are inset from the dialog margin. Ensure the |
| 437 // horizontal insets match. | 435 // horizontal insets match. |
| 438 set_title_margins( | 436 set_title_margins( |
| 439 gfx::Insets(LayoutDelegate::Get()->GetMetric( | 437 gfx::Insets(LayoutDelegate::Get()->GetMetric( |
| 440 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), | 438 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), |
| 441 side_margin, 0, side_margin)); | 439 side_margin, 0, side_margin)); |
| 442 } | 440 } |
| 443 views::BubbleDialogDelegateView::CreateBubble(this); | 441 views::BubbleDialogDelegateView::CreateBubble(this); |
| 444 | 442 |
| 445 presenter_.reset(new WebsiteSettings( | 443 presenter_.reset(new PageInfo( |
| 446 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), | 444 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), |
| 447 web_contents, url, security_info)); | 445 web_contents, url, security_info)); |
| 448 } | 446 } |
| 449 | 447 |
| 450 void WebsiteSettingsPopupView::RenderFrameDeleted( | 448 void PageInfoPopupView::RenderFrameDeleted( |
| 451 content::RenderFrameHost* render_frame_host) { | 449 content::RenderFrameHost* render_frame_host) { |
| 452 if (render_frame_host == web_contents()->GetMainFrame()) | 450 if (render_frame_host == web_contents()->GetMainFrame()) |
| 453 GetWidget()->Close(); | 451 GetWidget()->Close(); |
| 454 } | 452 } |
| 455 | 453 |
| 456 void WebsiteSettingsPopupView::WebContentsDestroyed() { | 454 void PageInfoPopupView::WebContentsDestroyed() { |
| 457 weak_factory_.InvalidateWeakPtrs(); | 455 weak_factory_.InvalidateWeakPtrs(); |
| 458 } | 456 } |
| 459 | 457 |
| 460 void WebsiteSettingsPopupView::OnPermissionChanged( | 458 void PageInfoPopupView::OnPermissionChanged( |
| 461 const WebsiteSettingsUI::PermissionInfo& permission) { | 459 const PageInfoUI::PermissionInfo& permission) { |
| 462 presenter_->OnSitePermissionChanged(permission.type, permission.setting); | 460 presenter_->OnSitePermissionChanged(permission.type, permission.setting); |
| 463 // The menu buttons for the permissions might have longer strings now, so we | 461 // The menu buttons for the permissions might have longer strings now, so we |
| 464 // need to layout and size the whole bubble. | 462 // need to layout and size the whole bubble. |
| 465 Layout(); | 463 Layout(); |
| 466 SizeToContents(); | 464 SizeToContents(); |
| 467 } | 465 } |
| 468 | 466 |
| 469 void WebsiteSettingsPopupView::OnChosenObjectDeleted( | 467 void PageInfoPopupView::OnChosenObjectDeleted( |
| 470 const WebsiteSettingsUI::ChosenObjectInfo& info) { | 468 const PageInfoUI::ChosenObjectInfo& info) { |
| 471 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); | 469 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); |
| 472 } | 470 } |
| 473 | 471 |
| 474 base::string16 WebsiteSettingsPopupView::GetWindowTitle() const { | 472 base::string16 PageInfoPopupView::GetWindowTitle() const { |
| 475 return summary_text_; | 473 return summary_text_; |
| 476 } | 474 } |
| 477 | 475 |
| 478 bool WebsiteSettingsPopupView::ShouldShowCloseButton() const { | 476 bool PageInfoPopupView::ShouldShowCloseButton() const { |
| 479 return true; | 477 return true; |
| 480 } | 478 } |
| 481 | 479 |
| 482 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { | 480 void PageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 483 g_shown_popup_type = POPUP_NONE; | 481 g_shown_popup_type = POPUP_NONE; |
| 484 presenter_->OnUIClosing(); | 482 presenter_->OnUIClosing(); |
| 485 } | 483 } |
| 486 | 484 |
| 487 int WebsiteSettingsPopupView::GetDialogButtons() const { | 485 int PageInfoPopupView::GetDialogButtons() const { |
| 488 return ui::DIALOG_BUTTON_NONE; | 486 return ui::DIALOG_BUTTON_NONE; |
| 489 } | 487 } |
| 490 | 488 |
| 491 const gfx::FontList& WebsiteSettingsPopupView::GetTitleFontList() const { | 489 const gfx::FontList& PageInfoPopupView::GetTitleFontList() const { |
| 492 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | 490 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( |
| 493 kSummaryFontSizeDelta); | 491 kSummaryFontSizeDelta); |
| 494 } | 492 } |
| 495 | 493 |
| 496 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button, | 494 void PageInfoPopupView::ButtonPressed(views::Button* button, |
| 497 const ui::Event& event) { | 495 const ui::Event& event) { |
| 498 DCHECK_EQ(BUTTON_CLOSE, button->id()); | 496 DCHECK_EQ(BUTTON_CLOSE, button->id()); |
| 499 GetWidget()->Close(); | 497 GetWidget()->Close(); |
| 500 } | 498 } |
| 501 | 499 |
| 502 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | 500 void PageInfoPopupView::LinkClicked(views::Link* source, int event_flags) { |
| 503 int event_flags) { | |
| 504 // The popup closes automatically when the collected cookies dialog or the | 501 // The popup closes automatically when the collected cookies dialog or the |
| 505 // certificate viewer opens. So delay handling of the link clicked to avoid | 502 // certificate viewer opens. So delay handling of the link clicked to avoid |
| 506 // a crash in the base class which needs to complete the mouse event handling. | 503 // a crash in the base class which needs to complete the mouse event handling. |
| 507 content::BrowserThread::PostTask( | 504 content::BrowserThread::PostTask( |
| 508 content::BrowserThread::UI, FROM_HERE, | 505 content::BrowserThread::UI, FROM_HERE, |
| 509 base::Bind(&WebsiteSettingsPopupView::HandleLinkClickedAsync, | 506 base::Bind(&PageInfoPopupView::HandleLinkClickedAsync, |
| 510 weak_factory_.GetWeakPtr(), source)); | 507 weak_factory_.GetWeakPtr(), source)); |
| 511 } | 508 } |
| 512 | 509 |
| 513 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() const { | 510 gfx::Size PageInfoPopupView::GetPreferredSize() const { |
| 514 if (header_ == nullptr && site_settings_view_ == nullptr) | 511 if (header_ == nullptr && site_settings_view_ == nullptr) |
| 515 return views::View::GetPreferredSize(); | 512 return views::View::GetPreferredSize(); |
| 516 | 513 |
| 517 int height = 0; | 514 int height = 0; |
| 518 if (header_) | 515 if (header_) |
| 519 height += header_->GetPreferredSize().height() + kHeaderMarginBottom; | 516 height += header_->GetPreferredSize().height() + kHeaderMarginBottom; |
| 520 if (separator_) | 517 if (separator_) |
| 521 height += separator_->GetPreferredSize().height(); | 518 height += separator_->GetPreferredSize().height(); |
| 522 | 519 |
| 523 if (site_settings_view_) | 520 if (site_settings_view_) |
| 524 height += site_settings_view_->GetPreferredSize().height(); | 521 height += site_settings_view_->GetPreferredSize().height(); |
| 525 | 522 |
| 526 int width = kMinPopupWidth; | 523 int width = kMinPopupWidth; |
| 527 if (site_settings_view_) | 524 if (site_settings_view_) |
| 528 width = std::max(width, site_settings_view_->GetPreferredSize().width()); | 525 width = std::max(width, site_settings_view_->GetPreferredSize().width()); |
| 529 width = std::min(width, kMaxPopupWidth); | 526 width = std::min(width, kMaxPopupWidth); |
| 530 return gfx::Size(width, height); | 527 return gfx::Size(width, height); |
| 531 } | 528 } |
| 532 | 529 |
| 533 void WebsiteSettingsPopupView::SetCookieInfo( | 530 void PageInfoPopupView::SetCookieInfo(const CookieInfoList& cookie_info_list) { |
| 534 const CookieInfoList& cookie_info_list) { | |
| 535 // |cookie_info_list| should only ever have 2 items: first- and third-party | 531 // |cookie_info_list| should only ever have 2 items: first- and third-party |
| 536 // cookies. | 532 // cookies. |
| 537 DCHECK_EQ(cookie_info_list.size(), 2u); | 533 DCHECK_EQ(cookie_info_list.size(), 2u); |
| 538 int total_allowed = 0; | 534 int total_allowed = 0; |
| 539 for (const auto& i : cookie_info_list) | 535 for (const auto& i : cookie_info_list) |
| 540 total_allowed += i.allowed; | 536 total_allowed += i.allowed; |
| 541 base::string16 label_text = l10n_util::GetPluralStringFUTF16( | 537 base::string16 label_text = l10n_util::GetPluralStringFUTF16( |
| 542 IDS_WEBSITE_SETTINGS_NUM_COOKIES, total_allowed); | 538 IDS_WEBSITE_SETTINGS_NUM_COOKIES, total_allowed); |
| 543 | 539 |
| 544 if (!cookie_dialog_link_) { | 540 if (!cookie_dialog_link_) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 560 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 556 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 561 views::GridLayout::FIXED, kPermissionIconColumnWidth, | 557 views::GridLayout::FIXED, kPermissionIconColumnWidth, |
| 562 0); | 558 0); |
| 563 column_set->AddPaddingColumn(0, kPermissionImageSpacing); | 559 column_set->AddPaddingColumn(0, kPermissionImageSpacing); |
| 564 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | 560 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, |
| 565 0, views::GridLayout::USE_PREF, 0, 0); | 561 0, views::GridLayout::USE_PREF, 0, 0); |
| 566 | 562 |
| 567 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); | 563 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); |
| 568 | 564 |
| 569 layout->StartRow(1, cookies_view_column); | 565 layout->StartRow(1, cookies_view_column); |
| 570 WebsiteSettingsUI::PermissionInfo info; | 566 PageInfoUI::PermissionInfo info; |
| 571 info.type = CONTENT_SETTINGS_TYPE_COOKIES; | 567 info.type = CONTENT_SETTINGS_TYPE_COOKIES; |
| 572 info.setting = CONTENT_SETTING_ALLOW; | 568 info.setting = CONTENT_SETTING_ALLOW; |
| 573 info.is_incognito = | 569 info.is_incognito = |
| 574 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) | 570 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) |
| 575 ->IsOffTheRecord(); | 571 ->IsOffTheRecord(); |
| 576 views::ImageView* icon = new NonAccessibleImageView(); | 572 views::ImageView* icon = new NonAccessibleImageView(); |
| 577 const gfx::Image& image = WebsiteSettingsUI::GetPermissionIcon(info); | 573 const gfx::Image& image = PageInfoUI::GetPermissionIcon(info); |
| 578 icon->SetImage(image.ToImageSkia()); | 574 icon->SetImage(image.ToImageSkia()); |
| 579 layout->AddView( | 575 layout->AddView( |
| 580 icon, 1, 2, views::GridLayout::FILL, | 576 icon, 1, 2, views::GridLayout::FILL, |
| 581 // TODO: The vertical alignment may change to CENTER once Harmony is | 577 // TODO: The vertical alignment may change to CENTER once Harmony is |
| 582 // implemented. See https://crbug.com/512442#c48 | 578 // implemented. See https://crbug.com/512442#c48 |
| 583 views::GridLayout::LEADING); | 579 views::GridLayout::LEADING); |
| 584 | 580 |
| 585 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 581 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 586 const gfx::FontList& font_list = rb.GetFontListWithDelta(1); | 582 const gfx::FontList& font_list = rb.GetFontListWithDelta(1); |
| 587 views::Label* cookies_label = new views::Label( | 583 views::Label* cookies_label = new views::Label( |
| 588 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA), | 584 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA), |
| 589 font_list); | 585 font_list); |
| 590 layout->AddView(cookies_label); | 586 layout->AddView(cookies_label); |
| 591 layout->StartRow(1, cookies_view_column); | 587 layout->StartRow(1, cookies_view_column); |
| 592 layout->SkipColumns(1); | 588 layout->SkipColumns(1); |
| 593 | 589 |
| 594 layout->AddView(cookie_dialog_link_); | 590 layout->AddView(cookie_dialog_link_); |
| 595 | 591 |
| 596 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); | 592 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); |
| 597 } | 593 } |
| 598 | 594 |
| 599 layout->Layout(cookies_view_); | 595 layout->Layout(cookies_view_); |
| 600 SizeToContents(); | 596 SizeToContents(); |
| 601 } | 597 } |
| 602 | 598 |
| 603 void WebsiteSettingsPopupView::SetPermissionInfo( | 599 void PageInfoPopupView::SetPermissionInfo( |
| 604 const PermissionInfoList& permission_info_list, | 600 const PermissionInfoList& permission_info_list, |
| 605 ChosenObjectInfoList chosen_object_info_list) { | 601 ChosenObjectInfoList chosen_object_info_list) { |
| 606 // When a permission is changed, WebsiteSettings::OnSitePermissionChanged() | 602 // When a permission is changed, PageInfo::OnSitePermissionChanged() |
| 607 // calls this method with updated permissions. However, PermissionSelectorRow | 603 // calls this method with updated permissions. However, PermissionSelectorRow |
| 608 // will have already updated its state, so it's already reflected in the UI. | 604 // will have already updated its state, so it's already reflected in the UI. |
| 609 // In addition, if a permission is set to the default setting, WebsiteSettings | 605 // In addition, if a permission is set to the default setting, PageInfo |
| 610 // removes it from |permission_info_list|, but the button should remain. | 606 // removes it from |permission_info_list|, but the button should remain. |
| 611 if (permissions_view_) | 607 if (permissions_view_) |
| 612 return; | 608 return; |
| 613 | 609 |
| 614 permissions_view_ = new views::View(); | 610 permissions_view_ = new views::View(); |
| 615 views::GridLayout* layout = new views::GridLayout(permissions_view_); | 611 views::GridLayout* layout = new views::GridLayout(permissions_view_); |
| 616 permissions_view_->SetLayoutManager(layout); | 612 permissions_view_->SetLayoutManager(layout); |
| 617 | 613 |
| 618 site_settings_view_->AddChildView(permissions_view_); | 614 site_settings_view_->AddChildView(permissions_view_); |
| 619 | 615 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 views::View* link_section = new views::View(); | 662 views::View* link_section = new views::View(); |
| 667 const int kLinkMarginTop = 4; | 663 const int kLinkMarginTop = 4; |
| 668 link_section->SetLayoutManager(new views::BoxLayout( | 664 link_section->SetLayoutManager(new views::BoxLayout( |
| 669 views::BoxLayout::kHorizontal, 0, kLinkMarginTop, 0)); | 665 views::BoxLayout::kHorizontal, 0, kLinkMarginTop, 0)); |
| 670 link_section->AddChildView(site_settings_link); | 666 link_section->AddChildView(site_settings_link); |
| 671 site_settings_view_->AddChildView(link_section); | 667 site_settings_view_->AddChildView(link_section); |
| 672 | 668 |
| 673 SizeToContents(); | 669 SizeToContents(); |
| 674 } | 670 } |
| 675 | 671 |
| 676 void WebsiteSettingsPopupView::SetIdentityInfo( | 672 void PageInfoPopupView::SetIdentityInfo(const IdentityInfo& identity_info) { |
| 677 const IdentityInfo& identity_info) { | 673 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = |
| 678 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = | |
| 679 identity_info.GetSecurityDescription(); | 674 identity_info.GetSecurityDescription(); |
| 680 | 675 |
| 681 summary_text_ = security_description->summary; | 676 summary_text_ = security_description->summary; |
| 682 GetWidget()->UpdateWindowTitle(); | 677 GetWidget()->UpdateWindowTitle(); |
| 683 | 678 |
| 684 if (identity_info.certificate) { | 679 if (identity_info.certificate) { |
| 685 certificate_ = identity_info.certificate; | 680 certificate_ = identity_info.certificate; |
| 686 | 681 |
| 687 if (identity_info.show_ssl_decision_revoke_button) | 682 if (identity_info.show_ssl_decision_revoke_button) |
| 688 header_->AddResetDecisionsLabel(); | 683 header_->AddResetDecisionsLabel(); |
| 689 } | 684 } |
| 690 | 685 |
| 691 header_->SetDetails(security_description->details); | 686 header_->SetDetails(security_description->details); |
| 692 | 687 |
| 693 Layout(); | 688 Layout(); |
| 694 SizeToContents(); | 689 SizeToContents(); |
| 695 } | 690 } |
| 696 | 691 |
| 697 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView(int side_margin) { | 692 views::View* PageInfoPopupView::CreateSiteSettingsView(int side_margin) { |
| 698 views::View* site_settings_view = new views::View(); | 693 views::View* site_settings_view = new views::View(); |
| 699 views::BoxLayout* box_layout = | 694 views::BoxLayout* box_layout = |
| 700 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0); | 695 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0); |
| 701 site_settings_view->SetLayoutManager(box_layout); | 696 site_settings_view->SetLayoutManager(box_layout); |
| 702 box_layout->set_cross_axis_alignment( | 697 box_layout->set_cross_axis_alignment( |
| 703 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); | 698 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); |
| 704 | 699 |
| 705 // Add cookies view. | 700 // Add cookies view. |
| 706 cookies_view_ = new views::View(); | 701 cookies_view_ = new views::View(); |
| 707 site_settings_view->AddChildView(cookies_view_); | 702 site_settings_view->AddChildView(cookies_view_); |
| 708 | 703 |
| 709 return site_settings_view; | 704 return site_settings_view; |
| 710 } | 705 } |
| 711 | 706 |
| 712 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { | 707 void PageInfoPopupView::HandleLinkClickedAsync(views::Link* source) { |
| 713 // Both switch cases require accessing web_contents(), so we check it here. | 708 // Both switch cases require accessing web_contents(), so we check it here. |
| 714 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) | 709 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) |
| 715 return; | 710 return; |
| 716 switch (source->id()) { | 711 switch (source->id()) { |
| 717 case LINK_SITE_SETTINGS: | 712 case LINK_SITE_SETTINGS: |
| 718 // TODO(crbug.com/655876): This opens the general Content Settings pane, | 713 // TODO(crbug.com/655876): This opens the general Content Settings pane, |
| 719 // which is OK for now. But on Android, it opens a page specific to a | 714 // which is OK for now. But on Android, it opens a page specific to a |
| 720 // given origin that shows all of the settings for that origin. If/when | 715 // given origin that shows all of the settings for that origin. If/when |
| 721 // that's available on desktop we should link to that here, too. | 716 // that's available on desktop we should link to that here, too. |
| 722 web_contents()->OpenURL(content::OpenURLParams( | 717 web_contents()->OpenURL(content::OpenURLParams( |
| 723 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), | 718 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), |
| 724 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 719 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
| 725 false)); | 720 false)); |
| 726 presenter_->RecordWebsiteSettingsAction( | 721 presenter_->RecordPageInfoAction( |
| 727 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); | 722 PageInfo::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); |
| 728 break; | 723 break; |
| 729 case LINK_COOKIE_DIALOG: | 724 case LINK_COOKIE_DIALOG: |
| 730 // Count how often the Collected Cookies dialog is opened. | 725 // Count how often the Collected Cookies dialog is opened. |
| 731 presenter_->RecordWebsiteSettingsAction( | 726 presenter_->RecordPageInfoAction( |
| 732 WebsiteSettings::WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED); | 727 PageInfo::WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED); |
| 733 new CollectedCookiesViews(web_contents()); | 728 new CollectedCookiesViews(web_contents()); |
| 734 break; | 729 break; |
| 735 default: | 730 default: |
| 736 NOTREACHED(); | 731 NOTREACHED(); |
| 737 } | 732 } |
| 738 } | 733 } |
| 739 | 734 |
| 740 void WebsiteSettingsPopupView::StyledLabelLinkClicked(views::StyledLabel* label, | 735 void PageInfoPopupView::StyledLabelLinkClicked(views::StyledLabel* label, |
| 741 const gfx::Range& range, | 736 const gfx::Range& range, |
| 742 int event_flags) { | 737 int event_flags) { |
| 743 switch (label->id()) { | 738 switch (label->id()) { |
| 744 case STYLED_LABEL_SECURITY_DETAILS: | 739 case STYLED_LABEL_SECURITY_DETAILS: |
| 745 web_contents()->OpenURL(content::OpenURLParams( | 740 web_contents()->OpenURL(content::OpenURLParams( |
| 746 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), | 741 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), |
| 747 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 742 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
| 748 false)); | 743 false)); |
| 749 presenter_->RecordWebsiteSettingsAction( | 744 presenter_->RecordPageInfoAction( |
| 750 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); | 745 PageInfo::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
| 751 break; | 746 break; |
| 752 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 747 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
| 753 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 748 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
| 754 GetWidget()->Close(); | 749 GetWidget()->Close(); |
| 755 break; | 750 break; |
| 756 default: | 751 default: |
| 757 NOTREACHED(); | 752 NOTREACHED(); |
| 758 } | 753 } |
| 759 } | 754 } |
| OLD | NEW |