| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" | 45 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
| 46 #include "ui/views/layout/box_layout.h" | 46 #include "ui/views/layout/box_layout.h" |
| 47 #include "ui/views/layout/grid_layout.h" | 47 #include "ui/views/layout/grid_layout.h" |
| 48 #include "ui/views/layout/layout_manager.h" | 48 #include "ui/views/layout/layout_manager.h" |
| 49 #include "ui/views/view.h" | 49 #include "ui/views/view.h" |
| 50 #include "ui/views/widget/widget.h" | 50 #include "ui/views/widget/widget.h" |
| 51 #include "url/gurl.h" | 51 #include "url/gurl.h" |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's |
| 56 // never more than one website settings popup shown and that it's associated |
| 57 // with the current window. If this assumption fails in the future, we'll need |
| 58 // to return a weak pointer from ShowPopup so callers can associate it with the |
| 59 // current window (or other context) and check if the popup they care about is |
| 60 // showing. |
| 61 bool is_popup_showing = false; |
| 62 |
| 55 // Padding values for sections on the connection tab. | 63 // Padding values for sections on the connection tab. |
| 56 const int kConnectionSectionPaddingBottom = 16; | 64 const int kConnectionSectionPaddingBottom = 16; |
| 57 const int kConnectionSectionPaddingLeft = 18; | 65 const int kConnectionSectionPaddingLeft = 18; |
| 58 const int kConnectionSectionPaddingTop = 16; | 66 const int kConnectionSectionPaddingTop = 16; |
| 59 const int kConnectionSectionPaddingRight = 18; | 67 const int kConnectionSectionPaddingRight = 18; |
| 60 | 68 |
| 61 // The text color that is used for the site identity status text, if the site's | 69 // The text color that is used for the site identity status text, if the site's |
| 62 // identity was sucessfully verified. | 70 // identity was sucessfully verified. |
| 63 const int kIdentityVerifiedTextColor = 0xFF298a27; | 71 const int kIdentityVerifiedTextColor = 0xFF298a27; |
| 64 | 72 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 }; | 141 }; |
| 134 | 142 |
| 135 // Website Settings are not supported for internal Chrome pages. Instead of the | 143 // Website Settings are not supported for internal Chrome pages. Instead of the |
| 136 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is | 144 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is |
| 137 // displayed. | 145 // displayed. |
| 138 class InternalPageInfoPopupView : public views::BubbleDelegateView { | 146 class InternalPageInfoPopupView : public views::BubbleDelegateView { |
| 139 public: | 147 public: |
| 140 explicit InternalPageInfoPopupView(views::View* anchor_view); | 148 explicit InternalPageInfoPopupView(views::View* anchor_view); |
| 141 virtual ~InternalPageInfoPopupView(); | 149 virtual ~InternalPageInfoPopupView(); |
| 142 | 150 |
| 151 // views::BubbleDelegateView: |
| 152 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
| 153 |
| 143 private: | 154 private: |
| 144 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | 155 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); |
| 145 }; | 156 }; |
| 146 | 157 |
| 147 //////////////////////////////////////////////////////////////////////////////// | 158 //////////////////////////////////////////////////////////////////////////////// |
| 148 // Popup Header | 159 // Popup Header |
| 149 //////////////////////////////////////////////////////////////////////////////// | 160 //////////////////////////////////////////////////////////////////////////////// |
| 150 | 161 |
| 151 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) | 162 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) |
| 152 : name_(NULL), status_(NULL) { | 163 : name_(NULL), status_(NULL) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 252 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 242 AddChildView(label); | 253 AddChildView(label); |
| 243 | 254 |
| 244 views::BubbleDelegateView::CreateBubble(this)->Show(); | 255 views::BubbleDelegateView::CreateBubble(this)->Show(); |
| 245 SizeToContents(); | 256 SizeToContents(); |
| 246 } | 257 } |
| 247 | 258 |
| 248 InternalPageInfoPopupView::~InternalPageInfoPopupView() { | 259 InternalPageInfoPopupView::~InternalPageInfoPopupView() { |
| 249 } | 260 } |
| 250 | 261 |
| 262 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 263 is_popup_showing = false; |
| 264 } |
| 265 |
| 251 //////////////////////////////////////////////////////////////////////////////// | 266 //////////////////////////////////////////////////////////////////////////////// |
| 252 // WebsiteSettingsPopupView | 267 // WebsiteSettingsPopupView |
| 253 //////////////////////////////////////////////////////////////////////////////// | 268 //////////////////////////////////////////////////////////////////////////////// |
| 254 | 269 |
| 255 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | 270 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { |
| 256 } | 271 } |
| 257 | 272 |
| 258 // static | 273 // static |
| 259 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, | 274 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, |
| 260 Profile* profile, | 275 Profile* profile, |
| 261 content::WebContents* web_contents, | 276 content::WebContents* web_contents, |
| 262 const GURL& url, | 277 const GURL& url, |
| 263 const content::SSLStatus& ssl, | 278 const content::SSLStatus& ssl, |
| 264 Browser* browser) { | 279 Browser* browser) { |
| 280 is_popup_showing = true; |
| 265 if (InternalChromePage(url)) { | 281 if (InternalChromePage(url)) { |
| 266 new InternalPageInfoPopupView(anchor_view); | 282 new InternalPageInfoPopupView(anchor_view); |
| 267 } else { | 283 } else { |
| 268 new WebsiteSettingsPopupView(anchor_view, profile, web_contents, url, ssl, | 284 new WebsiteSettingsPopupView(anchor_view, profile, web_contents, url, ssl, |
| 269 browser); | 285 browser); |
| 270 } | 286 } |
| 271 } | 287 } |
| 272 | 288 |
| 289 // static |
| 290 bool WebsiteSettingsPopupView::IsPopupShowing() { |
| 291 return is_popup_showing; |
| 292 } |
| 293 |
| 273 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | 294 WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
| 274 views::View* anchor_view, | 295 views::View* anchor_view, |
| 275 Profile* profile, | 296 Profile* profile, |
| 276 content::WebContents* web_contents, | 297 content::WebContents* web_contents, |
| 277 const GURL& url, | 298 const GURL& url, |
| 278 const content::SSLStatus& ssl, | 299 const content::SSLStatus& ssl, |
| 279 Browser* browser) | 300 Browser* browser) |
| 280 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 301 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
| 281 web_contents_(web_contents), | 302 web_contents_(web_contents), |
| 282 browser_(browser), | 303 browser_(browser), |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 369 } |
| 349 | 370 |
| 350 void WebsiteSettingsPopupView::OnPermissionChanged( | 371 void WebsiteSettingsPopupView::OnPermissionChanged( |
| 351 PermissionSelectorView* permission_selector) { | 372 PermissionSelectorView* permission_selector) { |
| 352 DCHECK(permission_selector); | 373 DCHECK(permission_selector); |
| 353 presenter_->OnSitePermissionChanged(permission_selector->type(), | 374 presenter_->OnSitePermissionChanged(permission_selector->type(), |
| 354 permission_selector->current_setting()); | 375 permission_selector->current_setting()); |
| 355 } | 376 } |
| 356 | 377 |
| 357 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { | 378 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 379 is_popup_showing = false; |
| 358 presenter_->OnUIClosing(); | 380 presenter_->OnUIClosing(); |
| 359 } | 381 } |
| 360 | 382 |
| 361 void WebsiteSettingsPopupView::ButtonPressed( | 383 void WebsiteSettingsPopupView::ButtonPressed( |
| 362 views::Button* button, | 384 views::Button* button, |
| 363 const ui::Event& event) { | 385 const ui::Event& event) { |
| 364 GetWidget()->Close(); | 386 GetWidget()->Close(); |
| 365 } | 387 } |
| 366 | 388 |
| 367 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | 389 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 web_contents_, signed_certificate_timestamp_ids_); | 805 web_contents_, signed_certificate_timestamp_ids_); |
| 784 } else if (source == help_center_link_) { | 806 } else if (source == help_center_link_) { |
| 785 browser_->OpenURL(content::OpenURLParams( | 807 browser_->OpenURL(content::OpenURLParams( |
| 786 GURL(chrome::kPageInfoHelpCenterURL), | 808 GURL(chrome::kPageInfoHelpCenterURL), |
| 787 content::Referrer(), | 809 content::Referrer(), |
| 788 NEW_FOREGROUND_TAB, | 810 NEW_FOREGROUND_TAB, |
| 789 content::PAGE_TRANSITION_LINK, | 811 content::PAGE_TRANSITION_LINK, |
| 790 false)); | 812 false)); |
| 791 } | 813 } |
| 792 } | 814 } |
| OLD | NEW |