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

Side by Side Diff: chrome/browser/ui/views/page_info/page_info_popup_view.cc

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

Powered by Google App Engine
This is Rietveld 408576698