Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " | 5 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 // displayed. | 141 // displayed. |
| 142 class InternalPageInfoPopupView : public views::BubbleDelegateView { | 142 class InternalPageInfoPopupView : public views::BubbleDelegateView { |
| 143 public: | 143 public: |
| 144 explicit InternalPageInfoPopupView(views::View* anchor_view); | 144 explicit InternalPageInfoPopupView(views::View* anchor_view); |
| 145 ~InternalPageInfoPopupView() override; | 145 ~InternalPageInfoPopupView() override; |
| 146 | 146 |
| 147 // views::BubbleDelegateView: | 147 // views::BubbleDelegateView: |
| 148 void OnWidgetDestroying(views::Widget* widget) override; | 148 void OnWidgetDestroying(views::Widget* widget) override; |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 friend class WebsiteSettingsPopupView; | |
| 152 | |
| 151 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | 153 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); |
| 152 }; | 154 }; |
| 153 | 155 |
| 154 //////////////////////////////////////////////////////////////////////////////// | 156 //////////////////////////////////////////////////////////////////////////////// |
| 155 // Popup Header | 157 // Popup Header |
| 156 //////////////////////////////////////////////////////////////////////////////// | 158 //////////////////////////////////////////////////////////////////////////////// |
| 157 | 159 |
| 158 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) | 160 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) |
| 159 : name_(nullptr), status_(nullptr) { | 161 : name_(nullptr), status_(nullptr) { |
| 160 views::GridLayout* layout = new views::GridLayout(this); | 162 views::GridLayout* layout = new views::GridLayout(this); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26)); | 245 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26)); |
| 244 AddChildView(icon_view); | 246 AddChildView(icon_view); |
| 245 | 247 |
| 246 views::Label* label = | 248 views::Label* label = |
| 247 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE)); | 249 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE)); |
| 248 label->SetMultiLine(true); | 250 label->SetMultiLine(true); |
| 249 label->SetAllowCharacterBreak(true); | 251 label->SetAllowCharacterBreak(true); |
| 250 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 252 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 251 AddChildView(label); | 253 AddChildView(label); |
| 252 | 254 |
| 253 views::BubbleDelegateView::CreateBubble(this)->Show(); | 255 views::BubbleDelegateView::CreateBubble(this); |
| 254 SizeToContents(); | |
| 255 } | 256 } |
| 256 | 257 |
| 257 InternalPageInfoPopupView::~InternalPageInfoPopupView() { | 258 InternalPageInfoPopupView::~InternalPageInfoPopupView() { |
| 258 } | 259 } |
| 259 | 260 |
| 260 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { | 261 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 261 is_popup_showing = false; | 262 is_popup_showing = false; |
| 262 } | 263 } |
| 263 | 264 |
| 264 //////////////////////////////////////////////////////////////////////////////// | 265 //////////////////////////////////////////////////////////////////////////////// |
| 265 // WebsiteSettingsPopupView | 266 // WebsiteSettingsPopupView |
| 266 //////////////////////////////////////////////////////////////////////////////// | 267 //////////////////////////////////////////////////////////////////////////////// |
| 267 | 268 |
| 268 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | 269 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { |
| 269 } | 270 } |
| 270 | 271 |
| 271 // static | 272 // static |
| 272 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, | 273 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, |
| 273 Profile* profile, | 274 Profile* profile, |
| 274 content::WebContents* web_contents, | 275 content::WebContents* web_contents, |
| 275 const GURL& url, | 276 const GURL& url, |
| 276 const content::SSLStatus& ssl) { | 277 const content::SSLStatus& ssl) { |
| 277 is_popup_showing = true; | 278 is_popup_showing = true; |
| 279 views::BubbleDelegateView* popup = nullptr; | |
| 278 if (InternalChromePage(url)) { | 280 if (InternalChromePage(url)) { |
| 279 new InternalPageInfoPopupView(anchor_view); | 281 popup = new InternalPageInfoPopupView(anchor_view); |
| 280 } else { | 282 } else { |
| 281 new WebsiteSettingsPopupView(anchor_view, profile, web_contents, url, ssl); | 283 popup = new WebsiteSettingsPopupView(anchor_view, profile, web_contents, |
| 284 url, ssl); | |
| 282 } | 285 } |
| 286 popup->GetWidget()->Show(); | |
| 283 } | 287 } |
| 284 | 288 |
| 285 // static | 289 // static |
| 290 views::BubbleDelegateView* WebsiteSettingsPopupView::ShowPopupAtRect( | |
| 291 const gfx::Rect& anchor_rect, | |
| 292 Profile* profile, | |
| 293 content::WebContents* web_contents, | |
| 294 const GURL& url, | |
| 295 const content::SSLStatus& ssl) { | |
| 296 is_popup_showing = true; | |
| 297 if (InternalChromePage(url)) { | |
| 298 InternalPageInfoPopupView* popup = new InternalPageInfoPopupView(nullptr); | |
| 299 popup->SetAnchorRect(anchor_rect); | |
| 300 popup->GetWidget()->Show(); | |
| 301 return popup; | |
| 302 } | |
| 303 | |
| 304 WebsiteSettingsPopupView* popup = | |
| 305 new WebsiteSettingsPopupView(nullptr, profile, web_contents, url, ssl); | |
| 306 popup->SetAnchorRect(anchor_rect); | |
| 307 popup->GetWidget()->Show(); | |
| 308 return popup; | |
| 309 } | |
| 310 | |
| 311 // static | |
| 286 bool WebsiteSettingsPopupView::IsPopupShowing() { | 312 bool WebsiteSettingsPopupView::IsPopupShowing() { |
| 287 return is_popup_showing; | 313 return is_popup_showing; |
| 288 } | 314 } |
| 289 | 315 |
| 290 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | 316 WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
| 291 views::View* anchor_view, | 317 views::View* anchor_view, |
| 292 Profile* profile, | 318 Profile* profile, |
| 293 content::WebContents* web_contents, | 319 content::WebContents* web_contents, |
| 294 const GURL& url, | 320 const GURL& url, |
| 295 const content::SSLStatus& ssl) | 321 const content::SSLStatus& ssl) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 tabbed_pane_->AddTabAtIndex( | 373 tabbed_pane_->AddTabAtIndex( |
| 348 TAB_ID_CONNECTION, | 374 TAB_ID_CONNECTION, |
| 349 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), | 375 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), |
| 350 connection_tab_); | 376 connection_tab_); |
| 351 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS); | 377 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS); |
| 352 tabbed_pane_->set_listener(this); | 378 tabbed_pane_->set_listener(this); |
| 353 | 379 |
| 354 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, | 380 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, |
| 355 kPopupMarginBottom, kPopupMarginRight)); | 381 kPopupMarginBottom, kPopupMarginRight)); |
| 356 | 382 |
| 357 views::BubbleDelegateView::CreateBubble(this)->Show(); | 383 views::BubbleDelegateView::CreateBubble(this); |
| 358 SizeToContents(); | |
| 359 | 384 |
| 360 presenter_.reset(new WebsiteSettings( | 385 presenter_.reset(new WebsiteSettings( |
| 361 this, profile, | 386 this, profile, |
| 362 TabSpecificContentSettings::FromWebContents(web_contents), | 387 TabSpecificContentSettings::FromWebContents(web_contents), |
| 363 InfoBarService::FromWebContents(web_contents), url, ssl, | 388 InfoBarService::FromWebContents(web_contents), url, ssl, |
| 364 content::CertStore::GetInstance())); | 389 content::CertStore::GetInstance())); |
| 365 } | 390 } |
| 366 | 391 |
| 367 void WebsiteSettingsPopupView::OnPermissionChanged( | 392 void WebsiteSettingsPopupView::OnPermissionChanged( |
| 368 const WebsiteSettingsUI::PermissionInfo& permission) { | 393 const WebsiteSettingsUI::PermissionInfo& permission) { |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 778 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { | 803 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { |
| 779 if (source == cookie_dialog_link_) { | 804 if (source == cookie_dialog_link_) { |
| 780 // Count how often the Collected Cookies dialog is opened. | 805 // Count how often the Collected Cookies dialog is opened. |
| 781 presenter_->RecordWebsiteSettingsAction( | 806 presenter_->RecordWebsiteSettingsAction( |
| 782 WebsiteSettings::WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED); | 807 WebsiteSettings::WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED); |
| 783 | 808 |
| 784 if (web_contents_ != NULL) | 809 if (web_contents_ != NULL) |
| 785 new CollectedCookiesViews(web_contents_); | 810 new CollectedCookiesViews(web_contents_); |
| 786 } else if (source == certificate_dialog_link_) { | 811 } else if (source == certificate_dialog_link_) { |
| 787 gfx::NativeWindow parent = GetAnchorView() ? | 812 gfx::NativeWindow parent = GetAnchorView() ? |
| 788 GetAnchorView()->GetWidget()->GetNativeWindow() : nullptr; | 813 GetAnchorView()->GetWidget()->GetNativeWindow() : nullptr; |
|
tapted
2015/08/17 05:15:03
... But stuff like this might need an update to su
jackhou1
2015/08/17 05:42:36
Acknowledged.
| |
| 789 presenter_->RecordWebsiteSettingsAction( | 814 presenter_->RecordWebsiteSettingsAction( |
| 790 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); | 815 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); |
| 791 ShowCertificateViewerByID(web_contents_, parent, cert_id_); | 816 ShowCertificateViewerByID(web_contents_, parent, cert_id_); |
| 792 } else if (source == help_center_link_) { | 817 } else if (source == help_center_link_) { |
| 793 web_contents_->OpenURL(content::OpenURLParams( | 818 web_contents_->OpenURL(content::OpenURLParams( |
| 794 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), | 819 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), |
| 795 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); | 820 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); |
| 796 presenter_->RecordWebsiteSettingsAction( | 821 presenter_->RecordWebsiteSettingsAction( |
| 797 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); | 822 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
| 798 } else if (source == site_settings_link_) { | 823 } else if (source == site_settings_link_) { |
| 799 // TODO(palmer): This opens the general Content Settings pane, which is OK | 824 // TODO(palmer): This opens the general Content Settings pane, which is OK |
| 800 // for now. But on Android, it opens a page specific to a given origin that | 825 // for now. But on Android, it opens a page specific to a given origin that |
| 801 // shows all of the settings for that origin. If/when that's available on | 826 // shows all of the settings for that origin. If/when that's available on |
| 802 // desktop we should link to that here, too. | 827 // desktop we should link to that here, too. |
| 803 web_contents_->OpenURL(content::OpenURLParams( | 828 web_contents_->OpenURL(content::OpenURLParams( |
| 804 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), | 829 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), |
| 805 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); | 830 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); |
| 806 presenter_->RecordWebsiteSettingsAction( | 831 presenter_->RecordWebsiteSettingsAction( |
| 807 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); | 832 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); |
| 808 } else { | 833 } else { |
| 809 NOTREACHED(); | 834 NOTREACHED(); |
| 810 } | 835 } |
| 811 } | 836 } |
| OLD | NEW |