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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 views::Label* status_; | 134 views::Label* status_; |
| 135 | 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); | 136 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 // Website Settings are not supported for internal Chrome pages. Instead of the | 139 // Website Settings are not supported for internal Chrome pages. Instead of the |
| 140 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is | 140 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is |
| 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 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be |
| 145 // provided to ensure this bubble is closed when the parent closes. | |
| 146 InternalPageInfoPopupView(views::View* anchor_view, | |
| 147 gfx::NativeView parent_window); | |
| 145 ~InternalPageInfoPopupView() override; | 148 ~InternalPageInfoPopupView() override; |
| 146 | 149 |
| 147 // views::BubbleDelegateView: | 150 // views::BubbleDelegateView: |
| 148 void OnWidgetDestroying(views::Widget* widget) override; | 151 void OnWidgetDestroying(views::Widget* widget) override; |
| 149 | 152 |
| 150 private: | 153 private: |
| 154 friend class WebsiteSettingsPopupView; | |
| 155 | |
| 151 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | 156 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); |
| 152 }; | 157 }; |
| 153 | 158 |
| 154 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
| 155 // Popup Header | 160 // Popup Header |
| 156 //////////////////////////////////////////////////////////////////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// |
| 157 | 162 |
| 158 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) | 163 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) |
| 159 : name_(nullptr), status_(nullptr) { | 164 : name_(nullptr), status_(nullptr) { |
| 160 views::GridLayout* layout = new views::GridLayout(this); | 165 views::GridLayout* layout = new views::GridLayout(this); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 void PopupHeaderView::SetIdentityStatus(const base::string16& status, | 227 void PopupHeaderView::SetIdentityStatus(const base::string16& status, |
| 223 SkColor text_color) { | 228 SkColor text_color) { |
| 224 status_->SetText(status); | 229 status_->SetText(status); |
| 225 status_->SetEnabledColor(text_color); | 230 status_->SetEnabledColor(text_color); |
| 226 } | 231 } |
| 227 | 232 |
| 228 //////////////////////////////////////////////////////////////////////////////// | 233 //////////////////////////////////////////////////////////////////////////////// |
| 229 // InternalPageInfoPopupView | 234 // InternalPageInfoPopupView |
| 230 //////////////////////////////////////////////////////////////////////////////// | 235 //////////////////////////////////////////////////////////////////////////////// |
| 231 | 236 |
| 232 InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view) | 237 InternalPageInfoPopupView::InternalPageInfoPopupView( |
| 238 views::View* anchor_view, | |
| 239 gfx::NativeView parent_window) | |
| 233 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { | 240 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { |
| 241 set_parent_window(parent_window); | |
| 242 | |
| 234 // Compensate for built-in vertical padding in the anchor view's image. | 243 // Compensate for built-in vertical padding in the anchor view's image. |
| 235 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, | 244 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, |
| 236 kLocationIconVerticalMargin, 0)); | 245 kLocationIconVerticalMargin, 0)); |
| 237 | 246 |
| 238 const int kSpacing = 4; | 247 const int kSpacing = 4; |
| 239 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, | 248 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, |
| 240 kSpacing, kSpacing)); | 249 kSpacing, kSpacing)); |
| 241 views::ImageView* icon_view = new views::ImageView(); | 250 views::ImageView* icon_view = new views::ImageView(); |
| 242 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 251 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 243 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26)); | 252 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26)); |
| 244 AddChildView(icon_view); | 253 AddChildView(icon_view); |
| 245 | 254 |
| 246 views::Label* label = | 255 views::Label* label = |
| 247 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE)); | 256 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE)); |
| 248 label->SetMultiLine(true); | 257 label->SetMultiLine(true); |
| 249 label->SetAllowCharacterBreak(true); | 258 label->SetAllowCharacterBreak(true); |
| 250 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 259 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 251 AddChildView(label); | 260 AddChildView(label); |
| 252 | 261 |
| 253 views::BubbleDelegateView::CreateBubble(this)->Show(); | 262 views::BubbleDelegateView::CreateBubble(this); |
| 254 SizeToContents(); | |
|
msw
2015/08/17 17:31:45
Is removing these calls okay? (no regressions?)
jackhou1
2015/08/18 01:20:53
Tests pass. Tried it on my Windows machine, no reg
msw
2015/08/18 02:40:32
Acknowledged.
| |
| 255 } | 263 } |
| 256 | 264 |
| 257 InternalPageInfoPopupView::~InternalPageInfoPopupView() { | 265 InternalPageInfoPopupView::~InternalPageInfoPopupView() { |
| 258 } | 266 } |
| 259 | 267 |
| 260 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { | 268 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 261 is_popup_showing = false; | 269 is_popup_showing = false; |
| 262 } | 270 } |
| 263 | 271 |
| 264 //////////////////////////////////////////////////////////////////////////////// | 272 //////////////////////////////////////////////////////////////////////////////// |
| 265 // WebsiteSettingsPopupView | 273 // WebsiteSettingsPopupView |
| 266 //////////////////////////////////////////////////////////////////////////////// | 274 //////////////////////////////////////////////////////////////////////////////// |
| 267 | 275 |
| 268 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | 276 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { |
| 269 } | 277 } |
| 270 | 278 |
| 271 // static | 279 // static |
| 272 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, | 280 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, |
|
msw
2015/08/17 17:31:45
nit: maybe merge this into the new function, and l
jackhou1
2015/08/18 01:20:53
Done. And updated c/b/ui/views/frame/browser_view.
| |
| 273 Profile* profile, | 281 Profile* profile, |
| 274 content::WebContents* web_contents, | 282 content::WebContents* web_contents, |
| 275 const GURL& url, | 283 const GURL& url, |
| 276 const content::SSLStatus& ssl) { | 284 const content::SSLStatus& ssl) { |
| 277 is_popup_showing = true; | 285 is_popup_showing = true; |
| 286 views::BubbleDelegateView* popup = nullptr; | |
| 278 if (InternalChromePage(url)) { | 287 if (InternalChromePage(url)) { |
| 279 new InternalPageInfoPopupView(anchor_view); | 288 popup = new InternalPageInfoPopupView(anchor_view, nullptr); |
| 280 } else { | 289 } else { |
| 281 new WebsiteSettingsPopupView(anchor_view, profile, web_contents, url, ssl); | 290 popup = new WebsiteSettingsPopupView(anchor_view, nullptr, profile, |
| 291 web_contents, url, ssl); | |
| 292 } | |
| 293 popup->GetWidget()->Show(); | |
| 294 } | |
| 295 | |
| 296 // static | |
| 297 void WebsiteSettingsPopupView::ShowPopupAtRect( | |
| 298 const gfx::Rect& anchor_rect, | |
| 299 Profile* profile, | |
| 300 content::WebContents* web_contents, | |
| 301 const GURL& url, | |
| 302 const content::SSLStatus& ssl) { | |
| 303 is_popup_showing = true; | |
| 304 if (InternalChromePage(url)) { | |
| 305 // Use the concrete type so that SetAnchorRect() can be called as a friend. | |
| 306 InternalPageInfoPopupView* popup = | |
| 307 new InternalPageInfoPopupView(nullptr, web_contents->GetNativeView()); | |
| 308 popup->SetAnchorRect(anchor_rect); | |
| 309 popup->GetWidget()->Show(); | |
| 310 } else { | |
| 311 WebsiteSettingsPopupView* popup = | |
| 312 new WebsiteSettingsPopupView(nullptr, web_contents->GetNativeView(), | |
| 313 profile, web_contents, url, ssl); | |
| 314 popup->SetAnchorRect(anchor_rect); | |
| 315 popup->GetWidget()->Show(); | |
| 282 } | 316 } |
| 283 } | 317 } |
| 284 | 318 |
| 285 // static | 319 // static |
| 286 bool WebsiteSettingsPopupView::IsPopupShowing() { | 320 bool WebsiteSettingsPopupView::IsPopupShowing() { |
| 287 return is_popup_showing; | 321 return is_popup_showing; |
| 288 } | 322 } |
| 289 | 323 |
| 290 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | 324 WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
| 291 views::View* anchor_view, | 325 views::View* anchor_view, |
| 326 gfx::NativeView parent_window, | |
| 292 Profile* profile, | 327 Profile* profile, |
| 293 content::WebContents* web_contents, | 328 content::WebContents* web_contents, |
| 294 const GURL& url, | 329 const GURL& url, |
| 295 const content::SSLStatus& ssl) | 330 const content::SSLStatus& ssl) |
| 296 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 331 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
| 297 web_contents_(web_contents), | 332 web_contents_(web_contents), |
| 298 header_(nullptr), | 333 header_(nullptr), |
| 299 tabbed_pane_(nullptr), | 334 tabbed_pane_(nullptr), |
| 300 permissions_tab_(nullptr), | 335 permissions_tab_(nullptr), |
| 301 site_data_content_(nullptr), | 336 site_data_content_(nullptr), |
| 302 cookie_dialog_link_(nullptr), | 337 cookie_dialog_link_(nullptr), |
| 303 permissions_content_(nullptr), | 338 permissions_content_(nullptr), |
| 304 connection_tab_(nullptr), | 339 connection_tab_(nullptr), |
| 305 identity_info_content_(nullptr), | 340 identity_info_content_(nullptr), |
| 306 certificate_dialog_link_(nullptr), | 341 certificate_dialog_link_(nullptr), |
| 307 reset_decisions_button_(nullptr), | 342 reset_decisions_button_(nullptr), |
| 308 help_center_content_(nullptr), | 343 help_center_content_(nullptr), |
| 309 cert_id_(0), | 344 cert_id_(0), |
| 310 help_center_link_(nullptr), | 345 help_center_link_(nullptr), |
| 311 connection_info_content_(nullptr), | 346 connection_info_content_(nullptr), |
| 312 weak_factory_(this) { | 347 weak_factory_(this) { |
| 348 set_parent_window(parent_window); | |
| 349 | |
| 313 // Compensate for built-in vertical padding in the anchor view's image. | 350 // Compensate for built-in vertical padding in the anchor view's image. |
| 314 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, | 351 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, |
| 315 kLocationIconVerticalMargin, 0)); | 352 kLocationIconVerticalMargin, 0)); |
| 316 | 353 |
| 317 views::GridLayout* layout = new views::GridLayout(this); | 354 views::GridLayout* layout = new views::GridLayout(this); |
| 318 SetLayoutManager(layout); | 355 SetLayoutManager(layout); |
| 319 const int content_column = 0; | 356 const int content_column = 0; |
| 320 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | 357 views::ColumnSet* column_set = layout->AddColumnSet(content_column); |
| 321 column_set->AddColumn(views::GridLayout::FILL, | 358 column_set->AddColumn(views::GridLayout::FILL, |
| 322 views::GridLayout::FILL, | 359 views::GridLayout::FILL, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 347 tabbed_pane_->AddTabAtIndex( | 384 tabbed_pane_->AddTabAtIndex( |
| 348 TAB_ID_CONNECTION, | 385 TAB_ID_CONNECTION, |
| 349 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), | 386 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), |
| 350 connection_tab_); | 387 connection_tab_); |
| 351 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS); | 388 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS); |
| 352 tabbed_pane_->set_listener(this); | 389 tabbed_pane_->set_listener(this); |
| 353 | 390 |
| 354 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, | 391 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, |
| 355 kPopupMarginBottom, kPopupMarginRight)); | 392 kPopupMarginBottom, kPopupMarginRight)); |
| 356 | 393 |
| 357 views::BubbleDelegateView::CreateBubble(this)->Show(); | 394 views::BubbleDelegateView::CreateBubble(this); |
| 358 SizeToContents(); | |
| 359 | 395 |
| 360 presenter_.reset(new WebsiteSettings( | 396 presenter_.reset(new WebsiteSettings( |
| 361 this, profile, | 397 this, profile, |
| 362 TabSpecificContentSettings::FromWebContents(web_contents), | 398 TabSpecificContentSettings::FromWebContents(web_contents), |
| 363 InfoBarService::FromWebContents(web_contents), url, ssl, | 399 InfoBarService::FromWebContents(web_contents), url, ssl, |
| 364 content::CertStore::GetInstance())); | 400 content::CertStore::GetInstance())); |
| 365 } | 401 } |
| 366 | 402 |
| 367 void WebsiteSettingsPopupView::OnPermissionChanged( | 403 void WebsiteSettingsPopupView::OnPermissionChanged( |
| 368 const WebsiteSettingsUI::PermissionInfo& permission) { | 404 const WebsiteSettingsUI::PermissionInfo& permission) { |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 // desktop we should link to that here, too. | 838 // desktop we should link to that here, too. |
| 803 web_contents_->OpenURL(content::OpenURLParams( | 839 web_contents_->OpenURL(content::OpenURLParams( |
| 804 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), | 840 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), |
| 805 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); | 841 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); |
| 806 presenter_->RecordWebsiteSettingsAction( | 842 presenter_->RecordWebsiteSettingsAction( |
| 807 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); | 843 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); |
| 808 } else { | 844 } else { |
| 809 NOTREACHED(); | 845 NOTREACHED(); |
| 810 } | 846 } |
| 811 } | 847 } |
| OLD | NEW |