| 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/page_info_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> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 page info popup shown and that it's associated | 66 // never more than one page info 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 PageInfoPopupView::PopupType g_shown_popup_type = PageInfoPopupView::POPUP_NONE; | 71 PageInfoBubbleView::PopupType g_shown_popup_type = |
| 72 PageInfoBubbleView::POPUP_NONE; |
| 72 | 73 |
| 73 // General constants ----------------------------------------------------------- | 74 // General constants ----------------------------------------------------------- |
| 74 | 75 |
| 75 // Popup width constraints. | 76 // Popup width constraints. |
| 76 const int kMinPopupWidth = 320; | 77 const int kMinPopupWidth = 320; |
| 77 const int kMaxPopupWidth = 1000; | 78 const int kMaxPopupWidth = 1000; |
| 78 | 79 |
| 79 // Security Section (PopupHeaderView) ------------------------------------------ | 80 // Security Section (PopupHeaderView) ------------------------------------------ |
| 80 | 81 |
| 81 // Margin and padding values for the |PopupHeaderView|. | 82 // Margin and padding values for the |PopupHeaderView|. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 views::ColumnSet* column_set = layout->AddColumnSet(id); | 117 views::ColumnSet* column_set = layout->AddColumnSet(id); |
| 117 column_set->AddPaddingColumn(0, margin); | 118 column_set->AddPaddingColumn(0, margin); |
| 118 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 119 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| 119 views::GridLayout::USE_PREF, 0, 0); | 120 views::GridLayout::USE_PREF, 0, 0); |
| 120 column_set->AddPaddingColumn(0, margin); | 121 column_set->AddPaddingColumn(0, margin); |
| 121 } | 122 } |
| 122 | 123 |
| 123 } // namespace | 124 } // namespace |
| 124 | 125 |
| 125 // |PopupHeaderView| is the UI element (view) that represents the header of the | 126 // |PopupHeaderView| is the UI element (view) that represents the header of the |
| 126 // |PageInfoPopupView|. The header shows the status of the site's | 127 // |PageInfoBubbleView|. The header shows the status of the site's |
| 127 // identity check and the name of the site's identity. | 128 // identity check and the name of the site's identity. |
| 128 class PopupHeaderView : public views::View { | 129 class PopupHeaderView : public views::View { |
| 129 public: | 130 public: |
| 130 PopupHeaderView(views::ButtonListener* button_listener, | 131 PopupHeaderView(views::ButtonListener* button_listener, |
| 131 views::StyledLabelListener* styled_label_listener, | 132 views::StyledLabelListener* styled_label_listener, |
| 132 int side_margin); | 133 int side_margin); |
| 133 ~PopupHeaderView() override; | 134 ~PopupHeaderView() override; |
| 134 | 135 |
| 135 // Sets the security summary for the current page. | 136 // Sets the security summary for the current page. |
| 136 void SetSummary(const base::string16& summary_text); | 137 void SetSummary(const base::string16& summary_text); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 151 | 152 |
| 152 // A container for the styled label with a link for resetting cert decisions. | 153 // A container for the styled label with a link for resetting cert decisions. |
| 153 // This is only shown sometimes, so we use a container to keep track of | 154 // This is only shown sometimes, so we use a container to keep track of |
| 154 // where to place it (if needed). | 155 // where to place it (if needed). |
| 155 views::View* reset_decisions_label_container_; | 156 views::View* reset_decisions_label_container_; |
| 156 views::StyledLabel* reset_decisions_label_; | 157 views::StyledLabel* reset_decisions_label_; |
| 157 | 158 |
| 158 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); | 159 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 // The regular PageInfoPopupView is not supported for internal Chrome pages and | 162 // The regular PageInfoBubbleView is not supported for internal Chrome pages and |
| 162 // extension pages. Instead of the |PageInfoPopupView|, the | 163 // extension pages. Instead of the |PageInfoBubbleView|, the |
| 163 // |InternalPageInfoPopupView| is displayed. | 164 // |InternalPageInfoBubbleView| is displayed. |
| 164 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { | 165 class InternalPageInfoBubbleView : public views::BubbleDialogDelegateView { |
| 165 public: | 166 public: |
| 166 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be | 167 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be |
| 167 // provided to ensure this bubble is closed when the parent closes. | 168 // provided to ensure this bubble is closed when the parent closes. |
| 168 InternalPageInfoPopupView(views::View* anchor_view, | 169 InternalPageInfoBubbleView(views::View* anchor_view, |
| 169 gfx::NativeView parent_window, | 170 gfx::NativeView parent_window, |
| 170 const GURL& url); | 171 const GURL& url); |
| 171 ~InternalPageInfoPopupView() override; | 172 ~InternalPageInfoBubbleView() override; |
| 172 | 173 |
| 173 // views::BubbleDialogDelegateView: | 174 // views::BubbleDialogDelegateView: |
| 174 void OnWidgetDestroying(views::Widget* widget) override; | 175 void OnWidgetDestroying(views::Widget* widget) override; |
| 175 int GetDialogButtons() const override; | 176 int GetDialogButtons() const override; |
| 176 | 177 |
| 177 private: | 178 private: |
| 178 friend class PageInfoPopupView; | 179 friend class PageInfoBubbleView; |
| 179 | 180 |
| 180 // Used around icon and inside bubble border. | 181 // Used around icon and inside bubble border. |
| 181 static constexpr int kSpacing = 12; | 182 static constexpr int kSpacing = 12; |
| 182 | 183 |
| 183 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | 184 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoBubbleView); |
| 184 }; | 185 }; |
| 185 | 186 |
| 186 //////////////////////////////////////////////////////////////////////////////// | 187 //////////////////////////////////////////////////////////////////////////////// |
| 187 // Popup Header | 188 // Popup Header |
| 188 //////////////////////////////////////////////////////////////////////////////// | 189 //////////////////////////////////////////////////////////////////////////////// |
| 189 | 190 |
| 190 PopupHeaderView::PopupHeaderView( | 191 PopupHeaderView::PopupHeaderView( |
| 191 views::ButtonListener* button_listener, | 192 views::ButtonListener* button_listener, |
| 192 views::StyledLabelListener* styled_label_listener, | 193 views::StyledLabelListener* styled_label_listener, |
| 193 int side_margin) | 194 int side_margin) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 reset_decisions_label_container_->AddChildView(reset_decisions_label_); | 270 reset_decisions_label_container_->AddChildView(reset_decisions_label_); |
| 270 | 271 |
| 271 // Now that it contains a label, the container needs padding at the top. | 272 // Now that it contains a label, the container needs padding at the top. |
| 272 reset_decisions_label_container_->SetBorder( | 273 reset_decisions_label_container_->SetBorder( |
| 273 views::CreateEmptyBorder(8, 0, 0, 0)); | 274 views::CreateEmptyBorder(8, 0, 0, 0)); |
| 274 | 275 |
| 275 InvalidateLayout(); | 276 InvalidateLayout(); |
| 276 } | 277 } |
| 277 | 278 |
| 278 //////////////////////////////////////////////////////////////////////////////// | 279 //////////////////////////////////////////////////////////////////////////////// |
| 279 // InternalPageInfoPopupView | 280 // InternalPageInfoBubbleView |
| 280 //////////////////////////////////////////////////////////////////////////////// | 281 //////////////////////////////////////////////////////////////////////////////// |
| 281 | 282 |
| 282 InternalPageInfoPopupView::InternalPageInfoPopupView( | 283 InternalPageInfoBubbleView::InternalPageInfoBubbleView( |
| 283 views::View* anchor_view, | 284 views::View* anchor_view, |
| 284 gfx::NativeView parent_window, | 285 gfx::NativeView parent_window, |
| 285 const GURL& url) | 286 const GURL& url) |
| 286 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { | 287 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { |
| 287 g_shown_popup_type = PageInfoPopupView::POPUP_INTERNAL_PAGE; | 288 g_shown_popup_type = PageInfoBubbleView::POPUP_INTERNAL_PAGE; |
| 288 set_parent_window(parent_window); | 289 set_parent_window(parent_window); |
| 289 | 290 |
| 290 int text = IDS_PAGE_INFO_INTERNAL_PAGE; | 291 int text = IDS_PAGE_INFO_INTERNAL_PAGE; |
| 291 int icon = IDR_PRODUCT_LOGO_16; | 292 int icon = IDR_PRODUCT_LOGO_16; |
| 292 if (url.SchemeIs(extensions::kExtensionScheme)) { | 293 if (url.SchemeIs(extensions::kExtensionScheme)) { |
| 293 text = IDS_PAGE_INFO_EXTENSION_PAGE; | 294 text = IDS_PAGE_INFO_EXTENSION_PAGE; |
| 294 icon = IDR_PLUGINS_FAVICON; | 295 icon = IDR_PLUGINS_FAVICON; |
| 295 } else if (url.SchemeIs(content::kViewSourceScheme)) { | 296 } else if (url.SchemeIs(content::kViewSourceScheme)) { |
| 296 text = IDS_PAGE_INFO_VIEW_SOURCE_PAGE; | 297 text = IDS_PAGE_INFO_VIEW_SOURCE_PAGE; |
| 297 // view-source scheme uses the same icon as chrome:// pages. | 298 // view-source scheme uses the same icon as chrome:// pages. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 317 | 318 |
| 318 views::Label* label = new views::Label(l10n_util::GetStringUTF16(text)); | 319 views::Label* label = new views::Label(l10n_util::GetStringUTF16(text)); |
| 319 label->SetMultiLine(true); | 320 label->SetMultiLine(true); |
| 320 label->SetAllowCharacterBreak(true); | 321 label->SetAllowCharacterBreak(true); |
| 321 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 322 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 322 AddChildView(label); | 323 AddChildView(label); |
| 323 | 324 |
| 324 views::BubbleDialogDelegateView::CreateBubble(this); | 325 views::BubbleDialogDelegateView::CreateBubble(this); |
| 325 } | 326 } |
| 326 | 327 |
| 327 InternalPageInfoPopupView::~InternalPageInfoPopupView() {} | 328 InternalPageInfoBubbleView::~InternalPageInfoBubbleView() {} |
| 328 | 329 |
| 329 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { | 330 void InternalPageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) { |
| 330 g_shown_popup_type = PageInfoPopupView::POPUP_NONE; | 331 g_shown_popup_type = PageInfoBubbleView::POPUP_NONE; |
| 331 } | 332 } |
| 332 | 333 |
| 333 int InternalPageInfoPopupView::GetDialogButtons() const { | 334 int InternalPageInfoBubbleView::GetDialogButtons() const { |
| 334 return ui::DIALOG_BUTTON_NONE; | 335 return ui::DIALOG_BUTTON_NONE; |
| 335 } | 336 } |
| 336 | 337 |
| 337 //////////////////////////////////////////////////////////////////////////////// | 338 //////////////////////////////////////////////////////////////////////////////// |
| 338 // PageInfoPopupView | 339 // PageInfoBubbleView |
| 339 //////////////////////////////////////////////////////////////////////////////// | 340 //////////////////////////////////////////////////////////////////////////////// |
| 340 | 341 |
| 341 PageInfoPopupView::~PageInfoPopupView() {} | 342 PageInfoBubbleView::~PageInfoBubbleView() {} |
| 342 | 343 |
| 343 // static | 344 // static |
| 344 void PageInfoPopupView::ShowPopup( | 345 void PageInfoBubbleView::ShowPopup( |
| 345 views::View* anchor_view, | 346 views::View* anchor_view, |
| 346 const gfx::Rect& anchor_rect, | 347 const gfx::Rect& anchor_rect, |
| 347 Profile* profile, | 348 Profile* profile, |
| 348 content::WebContents* web_contents, | 349 content::WebContents* web_contents, |
| 349 const GURL& url, | 350 const GURL& url, |
| 350 const security_state::SecurityInfo& security_info) { | 351 const security_state::SecurityInfo& security_info) { |
| 351 gfx::NativeView parent_window = | 352 gfx::NativeView parent_window = |
| 352 anchor_view ? nullptr : web_contents->GetNativeView(); | 353 anchor_view ? nullptr : web_contents->GetNativeView(); |
| 353 if (url.SchemeIs(content::kChromeUIScheme) || | 354 if (url.SchemeIs(content::kChromeUIScheme) || |
| 354 url.SchemeIs(content::kChromeDevToolsScheme) || | 355 url.SchemeIs(content::kChromeDevToolsScheme) || |
| 355 url.SchemeIs(extensions::kExtensionScheme) || | 356 url.SchemeIs(extensions::kExtensionScheme) || |
| 356 url.SchemeIs(content::kViewSourceScheme)) { | 357 url.SchemeIs(content::kViewSourceScheme)) { |
| 357 // Use the concrete type so that |SetAnchorRect| can be called as a friend. | 358 // Use the concrete type so that |SetAnchorRect| can be called as a friend. |
| 358 InternalPageInfoPopupView* popup = | 359 InternalPageInfoBubbleView* popup = |
| 359 new InternalPageInfoPopupView(anchor_view, parent_window, url); | 360 new InternalPageInfoBubbleView(anchor_view, parent_window, url); |
| 360 if (!anchor_view) | 361 if (!anchor_view) |
| 361 popup->SetAnchorRect(anchor_rect); | 362 popup->SetAnchorRect(anchor_rect); |
| 362 popup->GetWidget()->Show(); | 363 popup->GetWidget()->Show(); |
| 363 return; | 364 return; |
| 364 } | 365 } |
| 365 PageInfoPopupView* popup = new PageInfoPopupView( | 366 PageInfoBubbleView* popup = new PageInfoBubbleView( |
| 366 anchor_view, parent_window, profile, web_contents, url, security_info); | 367 anchor_view, parent_window, profile, web_contents, url, security_info); |
| 367 if (!anchor_view) | 368 if (!anchor_view) |
| 368 popup->SetAnchorRect(anchor_rect); | 369 popup->SetAnchorRect(anchor_rect); |
| 369 popup->GetWidget()->Show(); | 370 popup->GetWidget()->Show(); |
| 370 } | 371 } |
| 371 | 372 |
| 372 // static | 373 // static |
| 373 PageInfoPopupView::PopupType PageInfoPopupView::GetShownPopupType() { | 374 PageInfoBubbleView::PopupType PageInfoBubbleView::GetShownPopupType() { |
| 374 return g_shown_popup_type; | 375 return g_shown_popup_type; |
| 375 } | 376 } |
| 376 | 377 |
| 377 PageInfoPopupView::PageInfoPopupView( | 378 PageInfoBubbleView::PageInfoBubbleView( |
| 378 views::View* anchor_view, | 379 views::View* anchor_view, |
| 379 gfx::NativeView parent_window, | 380 gfx::NativeView parent_window, |
| 380 Profile* profile, | 381 Profile* profile, |
| 381 content::WebContents* web_contents, | 382 content::WebContents* web_contents, |
| 382 const GURL& url, | 383 const GURL& url, |
| 383 const security_state::SecurityInfo& security_info) | 384 const security_state::SecurityInfo& security_info) |
| 384 : content::WebContentsObserver(web_contents), | 385 : content::WebContentsObserver(web_contents), |
| 385 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 386 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
| 386 profile_(profile), | 387 profile_(profile), |
| 387 header_(nullptr), | 388 header_(nullptr), |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), | 441 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), |
| 441 side_margin, 0, side_margin)); | 442 side_margin, 0, side_margin)); |
| 442 } | 443 } |
| 443 views::BubbleDialogDelegateView::CreateBubble(this); | 444 views::BubbleDialogDelegateView::CreateBubble(this); |
| 444 | 445 |
| 445 presenter_.reset(new PageInfo( | 446 presenter_.reset(new PageInfo( |
| 446 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), | 447 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), |
| 447 web_contents, url, security_info)); | 448 web_contents, url, security_info)); |
| 448 } | 449 } |
| 449 | 450 |
| 450 void PageInfoPopupView::RenderFrameDeleted( | 451 void PageInfoBubbleView::RenderFrameDeleted( |
| 451 content::RenderFrameHost* render_frame_host) { | 452 content::RenderFrameHost* render_frame_host) { |
| 452 if (render_frame_host == web_contents()->GetMainFrame()) | 453 if (render_frame_host == web_contents()->GetMainFrame()) |
| 453 GetWidget()->Close(); | 454 GetWidget()->Close(); |
| 454 } | 455 } |
| 455 | 456 |
| 456 void PageInfoPopupView::WebContentsDestroyed() { | 457 void PageInfoBubbleView::WebContentsDestroyed() { |
| 457 weak_factory_.InvalidateWeakPtrs(); | 458 weak_factory_.InvalidateWeakPtrs(); |
| 458 } | 459 } |
| 459 | 460 |
| 460 void PageInfoPopupView::OnPermissionChanged( | 461 void PageInfoBubbleView::OnPermissionChanged( |
| 461 const PageInfoUI::PermissionInfo& permission) { | 462 const PageInfoUI::PermissionInfo& permission) { |
| 462 presenter_->OnSitePermissionChanged(permission.type, permission.setting); | 463 presenter_->OnSitePermissionChanged(permission.type, permission.setting); |
| 463 // The menu buttons for the permissions might have longer strings now, so we | 464 // The menu buttons for the permissions might have longer strings now, so we |
| 464 // need to layout and size the whole bubble. | 465 // need to layout and size the whole bubble. |
| 465 Layout(); | 466 Layout(); |
| 466 SizeToContents(); | 467 SizeToContents(); |
| 467 } | 468 } |
| 468 | 469 |
| 469 void PageInfoPopupView::OnChosenObjectDeleted( | 470 void PageInfoBubbleView::OnChosenObjectDeleted( |
| 470 const PageInfoUI::ChosenObjectInfo& info) { | 471 const PageInfoUI::ChosenObjectInfo& info) { |
| 471 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); | 472 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); |
| 472 } | 473 } |
| 473 | 474 |
| 474 base::string16 PageInfoPopupView::GetWindowTitle() const { | 475 base::string16 PageInfoBubbleView::GetWindowTitle() const { |
| 475 return summary_text_; | 476 return summary_text_; |
| 476 } | 477 } |
| 477 | 478 |
| 478 bool PageInfoPopupView::ShouldShowCloseButton() const { | 479 bool PageInfoBubbleView::ShouldShowCloseButton() const { |
| 479 return true; | 480 return true; |
| 480 } | 481 } |
| 481 | 482 |
| 482 void PageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { | 483 void PageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) { |
| 483 g_shown_popup_type = POPUP_NONE; | 484 g_shown_popup_type = POPUP_NONE; |
| 484 presenter_->OnUIClosing(); | 485 presenter_->OnUIClosing(); |
| 485 } | 486 } |
| 486 | 487 |
| 487 int PageInfoPopupView::GetDialogButtons() const { | 488 int PageInfoBubbleView::GetDialogButtons() const { |
| 488 return ui::DIALOG_BUTTON_NONE; | 489 return ui::DIALOG_BUTTON_NONE; |
| 489 } | 490 } |
| 490 | 491 |
| 491 const gfx::FontList& PageInfoPopupView::GetTitleFontList() const { | 492 const gfx::FontList& PageInfoBubbleView::GetTitleFontList() const { |
| 492 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | 493 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( |
| 493 kSummaryFontSizeDelta); | 494 kSummaryFontSizeDelta); |
| 494 } | 495 } |
| 495 | 496 |
| 496 void PageInfoPopupView::ButtonPressed(views::Button* button, | 497 void PageInfoBubbleView::ButtonPressed(views::Button* button, |
| 497 const ui::Event& event) { | 498 const ui::Event& event) { |
| 498 DCHECK_EQ(BUTTON_CLOSE, button->id()); | 499 DCHECK_EQ(BUTTON_CLOSE, button->id()); |
| 499 GetWidget()->Close(); | 500 GetWidget()->Close(); |
| 500 } | 501 } |
| 501 | 502 |
| 502 void PageInfoPopupView::LinkClicked(views::Link* source, int event_flags) { | 503 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { |
| 503 // The popup closes automatically when the collected cookies dialog or the | 504 // The popup closes automatically when the collected cookies dialog or the |
| 504 // certificate viewer opens. So delay handling of the link clicked to avoid | 505 // certificate viewer opens. So delay handling of the link clicked to avoid |
| 505 // a crash in the base class which needs to complete the mouse event handling. | 506 // a crash in the base class which needs to complete the mouse event handling. |
| 506 content::BrowserThread::PostTask( | 507 content::BrowserThread::PostTask( |
| 507 content::BrowserThread::UI, FROM_HERE, | 508 content::BrowserThread::UI, FROM_HERE, |
| 508 base::Bind(&PageInfoPopupView::HandleLinkClickedAsync, | 509 base::Bind(&PageInfoBubbleView::HandleLinkClickedAsync, |
| 509 weak_factory_.GetWeakPtr(), source)); | 510 weak_factory_.GetWeakPtr(), source)); |
| 510 } | 511 } |
| 511 | 512 |
| 512 gfx::Size PageInfoPopupView::GetPreferredSize() const { | 513 gfx::Size PageInfoBubbleView::GetPreferredSize() const { |
| 513 if (header_ == nullptr && site_settings_view_ == nullptr) | 514 if (header_ == nullptr && site_settings_view_ == nullptr) |
| 514 return views::View::GetPreferredSize(); | 515 return views::View::GetPreferredSize(); |
| 515 | 516 |
| 516 int height = 0; | 517 int height = 0; |
| 517 if (header_) | 518 if (header_) |
| 518 height += header_->GetPreferredSize().height() + kHeaderMarginBottom; | 519 height += header_->GetPreferredSize().height() + kHeaderMarginBottom; |
| 519 if (separator_) | 520 if (separator_) |
| 520 height += separator_->GetPreferredSize().height(); | 521 height += separator_->GetPreferredSize().height(); |
| 521 | 522 |
| 522 if (site_settings_view_) | 523 if (site_settings_view_) |
| 523 height += site_settings_view_->GetPreferredSize().height(); | 524 height += site_settings_view_->GetPreferredSize().height(); |
| 524 | 525 |
| 525 int width = kMinPopupWidth; | 526 int width = kMinPopupWidth; |
| 526 if (site_settings_view_) | 527 if (site_settings_view_) |
| 527 width = std::max(width, site_settings_view_->GetPreferredSize().width()); | 528 width = std::max(width, site_settings_view_->GetPreferredSize().width()); |
| 528 width = std::min(width, kMaxPopupWidth); | 529 width = std::min(width, kMaxPopupWidth); |
| 529 return gfx::Size(width, height); | 530 return gfx::Size(width, height); |
| 530 } | 531 } |
| 531 | 532 |
| 532 void PageInfoPopupView::SetCookieInfo(const CookieInfoList& cookie_info_list) { | 533 void PageInfoBubbleView::SetCookieInfo(const CookieInfoList& cookie_info_list) { |
| 533 // |cookie_info_list| should only ever have 2 items: first- and third-party | 534 // |cookie_info_list| should only ever have 2 items: first- and third-party |
| 534 // cookies. | 535 // cookies. |
| 535 DCHECK_EQ(cookie_info_list.size(), 2u); | 536 DCHECK_EQ(cookie_info_list.size(), 2u); |
| 536 int total_allowed = 0; | 537 int total_allowed = 0; |
| 537 for (const auto& i : cookie_info_list) | 538 for (const auto& i : cookie_info_list) |
| 538 total_allowed += i.allowed; | 539 total_allowed += i.allowed; |
| 539 base::string16 label_text = l10n_util::GetPluralStringFUTF16( | 540 base::string16 label_text = l10n_util::GetPluralStringFUTF16( |
| 540 IDS_PAGE_INFO_NUM_COOKIES, total_allowed); | 541 IDS_PAGE_INFO_NUM_COOKIES, total_allowed); |
| 541 | 542 |
| 542 if (!cookie_dialog_link_) { | 543 if (!cookie_dialog_link_) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 590 |
| 590 layout->AddView(cookie_dialog_link_); | 591 layout->AddView(cookie_dialog_link_); |
| 591 | 592 |
| 592 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); | 593 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); |
| 593 } | 594 } |
| 594 | 595 |
| 595 layout->Layout(cookies_view_); | 596 layout->Layout(cookies_view_); |
| 596 SizeToContents(); | 597 SizeToContents(); |
| 597 } | 598 } |
| 598 | 599 |
| 599 void PageInfoPopupView::SetPermissionInfo( | 600 void PageInfoBubbleView::SetPermissionInfo( |
| 600 const PermissionInfoList& permission_info_list, | 601 const PermissionInfoList& permission_info_list, |
| 601 ChosenObjectInfoList chosen_object_info_list) { | 602 ChosenObjectInfoList chosen_object_info_list) { |
| 602 // When a permission is changed, PageInfo::OnSitePermissionChanged() | 603 // When a permission is changed, PageInfo::OnSitePermissionChanged() |
| 603 // calls this method with updated permissions. However, PermissionSelectorRow | 604 // calls this method with updated permissions. However, PermissionSelectorRow |
| 604 // will have already updated its state, so it's already reflected in the UI. | 605 // will have already updated its state, so it's already reflected in the UI. |
| 605 // In addition, if a permission is set to the default setting, PageInfo | 606 // In addition, if a permission is set to the default setting, PageInfo |
| 606 // removes it from |permission_info_list|, but the button should remain. | 607 // removes it from |permission_info_list|, but the button should remain. |
| 607 if (permissions_view_) | 608 if (permissions_view_) |
| 608 return; | 609 return; |
| 609 | 610 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 views::View* link_section = new views::View(); | 663 views::View* link_section = new views::View(); |
| 663 const int kLinkMarginTop = 4; | 664 const int kLinkMarginTop = 4; |
| 664 link_section->SetLayoutManager(new views::BoxLayout( | 665 link_section->SetLayoutManager(new views::BoxLayout( |
| 665 views::BoxLayout::kHorizontal, 0, kLinkMarginTop, 0)); | 666 views::BoxLayout::kHorizontal, 0, kLinkMarginTop, 0)); |
| 666 link_section->AddChildView(site_settings_link); | 667 link_section->AddChildView(site_settings_link); |
| 667 site_settings_view_->AddChildView(link_section); | 668 site_settings_view_->AddChildView(link_section); |
| 668 | 669 |
| 669 SizeToContents(); | 670 SizeToContents(); |
| 670 } | 671 } |
| 671 | 672 |
| 672 void PageInfoPopupView::SetIdentityInfo(const IdentityInfo& identity_info) { | 673 void PageInfoBubbleView::SetIdentityInfo(const IdentityInfo& identity_info) { |
| 673 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = | 674 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = |
| 674 identity_info.GetSecurityDescription(); | 675 identity_info.GetSecurityDescription(); |
| 675 | 676 |
| 676 summary_text_ = security_description->summary; | 677 summary_text_ = security_description->summary; |
| 677 GetWidget()->UpdateWindowTitle(); | 678 GetWidget()->UpdateWindowTitle(); |
| 678 | 679 |
| 679 if (identity_info.certificate) { | 680 if (identity_info.certificate) { |
| 680 certificate_ = identity_info.certificate; | 681 certificate_ = identity_info.certificate; |
| 681 | 682 |
| 682 if (identity_info.show_ssl_decision_revoke_button) | 683 if (identity_info.show_ssl_decision_revoke_button) |
| 683 header_->AddResetDecisionsLabel(); | 684 header_->AddResetDecisionsLabel(); |
| 684 } | 685 } |
| 685 | 686 |
| 686 header_->SetDetails(security_description->details); | 687 header_->SetDetails(security_description->details); |
| 687 | 688 |
| 688 Layout(); | 689 Layout(); |
| 689 SizeToContents(); | 690 SizeToContents(); |
| 690 } | 691 } |
| 691 | 692 |
| 692 views::View* PageInfoPopupView::CreateSiteSettingsView(int side_margin) { | 693 views::View* PageInfoBubbleView::CreateSiteSettingsView(int side_margin) { |
| 693 views::View* site_settings_view = new views::View(); | 694 views::View* site_settings_view = new views::View(); |
| 694 views::BoxLayout* box_layout = | 695 views::BoxLayout* box_layout = |
| 695 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0); | 696 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0); |
| 696 site_settings_view->SetLayoutManager(box_layout); | 697 site_settings_view->SetLayoutManager(box_layout); |
| 697 box_layout->set_cross_axis_alignment( | 698 box_layout->set_cross_axis_alignment( |
| 698 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); | 699 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); |
| 699 | 700 |
| 700 // Add cookies view. | 701 // Add cookies view. |
| 701 cookies_view_ = new views::View(); | 702 cookies_view_ = new views::View(); |
| 702 site_settings_view->AddChildView(cookies_view_); | 703 site_settings_view->AddChildView(cookies_view_); |
| 703 | 704 |
| 704 return site_settings_view; | 705 return site_settings_view; |
| 705 } | 706 } |
| 706 | 707 |
| 707 void PageInfoPopupView::HandleLinkClickedAsync(views::Link* source) { | 708 void PageInfoBubbleView::HandleLinkClickedAsync(views::Link* source) { |
| 708 // Both switch cases require accessing web_contents(), so we check it here. | 709 // Both switch cases require accessing web_contents(), so we check it here. |
| 709 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) | 710 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) |
| 710 return; | 711 return; |
| 711 switch (source->id()) { | 712 switch (source->id()) { |
| 712 case LINK_SITE_SETTINGS: | 713 case LINK_SITE_SETTINGS: |
| 713 // TODO(crbug.com/655876): This opens the general Content Settings pane, | 714 // TODO(crbug.com/655876): This opens the general Content Settings pane, |
| 714 // which is OK for now. But on Android, it opens a page specific to a | 715 // which is OK for now. But on Android, it opens a page specific to a |
| 715 // given origin that shows all of the settings for that origin. If/when | 716 // given origin that shows all of the settings for that origin. If/when |
| 716 // that's available on desktop we should link to that here, too. | 717 // that's available on desktop we should link to that here, too. |
| 717 web_contents()->OpenURL(content::OpenURLParams( | 718 web_contents()->OpenURL(content::OpenURLParams( |
| 718 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), | 719 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), |
| 719 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 720 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
| 720 false)); | 721 false)); |
| 721 presenter_->RecordPageInfoAction( | 722 presenter_->RecordPageInfoAction( |
| 722 PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); | 723 PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); |
| 723 break; | 724 break; |
| 724 case LINK_COOKIE_DIALOG: | 725 case LINK_COOKIE_DIALOG: |
| 725 // Count how often the Collected Cookies dialog is opened. | 726 // Count how often the Collected Cookies dialog is opened. |
| 726 presenter_->RecordPageInfoAction( | 727 presenter_->RecordPageInfoAction( |
| 727 PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); | 728 PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); |
| 728 new CollectedCookiesViews(web_contents()); | 729 new CollectedCookiesViews(web_contents()); |
| 729 break; | 730 break; |
| 730 default: | 731 default: |
| 731 NOTREACHED(); | 732 NOTREACHED(); |
| 732 } | 733 } |
| 733 } | 734 } |
| 734 | 735 |
| 735 void PageInfoPopupView::StyledLabelLinkClicked(views::StyledLabel* label, | 736 void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label, |
| 736 const gfx::Range& range, | 737 const gfx::Range& range, |
| 737 int event_flags) { | 738 int event_flags) { |
| 738 switch (label->id()) { | 739 switch (label->id()) { |
| 739 case STYLED_LABEL_SECURITY_DETAILS: | 740 case STYLED_LABEL_SECURITY_DETAILS: |
| 740 web_contents()->OpenURL(content::OpenURLParams( | 741 web_contents()->OpenURL(content::OpenURLParams( |
| 741 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), | 742 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), |
| 742 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 743 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
| 743 false)); | 744 false)); |
| 744 presenter_->RecordPageInfoAction( | 745 presenter_->RecordPageInfoAction( |
| 745 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); | 746 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); |
| 746 break; | 747 break; |
| 747 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 748 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
| 748 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 749 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
| 749 GetWidget()->Close(); | 750 GetWidget()->Close(); |
| 750 break; | 751 break; |
| 751 default: | 752 default: |
| 752 NOTREACHED(); | 753 NOTREACHED(); |
| 753 } | 754 } |
| 754 } | 755 } |
| OLD | NEW |