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 InternalPageInfoPopupView(views::View* anchor_view, |
|
tapted
2015/08/17 06:00:49
nit: Maybe a comment here. E.g. it's not obvious t
jackhou1
2015/08/17 07:06:47
Done.
| |
| 145 gfx::NativeView parent_window); | |
| 145 ~InternalPageInfoPopupView() override; | 146 ~InternalPageInfoPopupView() override; |
| 146 | 147 |
| 147 // views::BubbleDelegateView: | 148 // views::BubbleDelegateView: |
| 148 void OnWidgetDestroying(views::Widget* widget) override; | 149 void OnWidgetDestroying(views::Widget* widget) override; |
| 149 | 150 |
| 150 private: | 151 private: |
| 152 friend class WebsiteSettingsPopupView; | |
| 153 | |
| 151 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | 154 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); |
| 152 }; | 155 }; |
| 153 | 156 |
| 154 //////////////////////////////////////////////////////////////////////////////// | 157 //////////////////////////////////////////////////////////////////////////////// |
| 155 // Popup Header | 158 // Popup Header |
| 156 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
| 157 | 160 |
| 158 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) | 161 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) |
| 159 : name_(nullptr), status_(nullptr) { | 162 : name_(nullptr), status_(nullptr) { |
| 160 views::GridLayout* layout = new views::GridLayout(this); | 163 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, | 225 void PopupHeaderView::SetIdentityStatus(const base::string16& status, |
| 223 SkColor text_color) { | 226 SkColor text_color) { |
| 224 status_->SetText(status); | 227 status_->SetText(status); |
| 225 status_->SetEnabledColor(text_color); | 228 status_->SetEnabledColor(text_color); |
| 226 } | 229 } |
| 227 | 230 |
| 228 //////////////////////////////////////////////////////////////////////////////// | 231 //////////////////////////////////////////////////////////////////////////////// |
| 229 // InternalPageInfoPopupView | 232 // InternalPageInfoPopupView |
| 230 //////////////////////////////////////////////////////////////////////////////// | 233 //////////////////////////////////////////////////////////////////////////////// |
| 231 | 234 |
| 232 InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view) | 235 InternalPageInfoPopupView::InternalPageInfoPopupView( |
| 236 views::View* anchor_view, | |
| 237 gfx::NativeView parent_window) | |
| 233 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { | 238 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { |
| 239 set_parent_window(parent_window); | |
| 240 | |
| 234 // Compensate for built-in vertical padding in the anchor view's image. | 241 // Compensate for built-in vertical padding in the anchor view's image. |
| 235 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, | 242 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, |
| 236 kLocationIconVerticalMargin, 0)); | 243 kLocationIconVerticalMargin, 0)); |
| 237 | 244 |
| 238 const int kSpacing = 4; | 245 const int kSpacing = 4; |
| 239 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, | 246 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, |
| 240 kSpacing, kSpacing)); | 247 kSpacing, kSpacing)); |
| 241 views::ImageView* icon_view = new views::ImageView(); | 248 views::ImageView* icon_view = new views::ImageView(); |
| 242 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 249 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 243 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26)); | 250 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26)); |
| 244 AddChildView(icon_view); | 251 AddChildView(icon_view); |
| 245 | 252 |
| 246 views::Label* label = | 253 views::Label* label = |
| 247 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE)); | 254 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE)); |
| 248 label->SetMultiLine(true); | 255 label->SetMultiLine(true); |
| 249 label->SetAllowCharacterBreak(true); | 256 label->SetAllowCharacterBreak(true); |
| 250 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 257 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 251 AddChildView(label); | 258 AddChildView(label); |
| 252 | 259 |
| 253 views::BubbleDelegateView::CreateBubble(this)->Show(); | 260 views::BubbleDelegateView::CreateBubble(this); |
| 254 SizeToContents(); | |
| 255 } | 261 } |
| 256 | 262 |
| 257 InternalPageInfoPopupView::~InternalPageInfoPopupView() { | 263 InternalPageInfoPopupView::~InternalPageInfoPopupView() { |
| 258 } | 264 } |
| 259 | 265 |
| 260 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { | 266 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 261 is_popup_showing = false; | 267 is_popup_showing = false; |
| 262 } | 268 } |
| 263 | 269 |
| 264 //////////////////////////////////////////////////////////////////////////////// | 270 //////////////////////////////////////////////////////////////////////////////// |
| 265 // WebsiteSettingsPopupView | 271 // WebsiteSettingsPopupView |
| 266 //////////////////////////////////////////////////////////////////////////////// | 272 //////////////////////////////////////////////////////////////////////////////// |
| 267 | 273 |
| 268 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | 274 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { |
| 269 } | 275 } |
| 270 | 276 |
| 271 // static | 277 // static |
| 272 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, | 278 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, |
| 273 Profile* profile, | 279 Profile* profile, |
| 274 content::WebContents* web_contents, | 280 content::WebContents* web_contents, |
| 275 const GURL& url, | 281 const GURL& url, |
| 276 const content::SSLStatus& ssl) { | 282 const content::SSLStatus& ssl) { |
| 277 is_popup_showing = true; | 283 is_popup_showing = true; |
| 284 views::BubbleDelegateView* popup = nullptr; | |
| 278 if (InternalChromePage(url)) { | 285 if (InternalChromePage(url)) { |
| 279 new InternalPageInfoPopupView(anchor_view); | 286 popup = new InternalPageInfoPopupView(anchor_view, nullptr); |
| 280 } else { | 287 } else { |
| 281 new WebsiteSettingsPopupView(anchor_view, profile, web_contents, url, ssl); | 288 popup = new WebsiteSettingsPopupView(anchor_view, nullptr, profile, |
| 289 web_contents, url, ssl); | |
| 290 } | |
| 291 popup->GetWidget()->Show(); | |
| 292 } | |
| 293 | |
| 294 // static | |
| 295 void WebsiteSettingsPopupView::ShowPopupAtRect( | |
|
tapted
2015/08/17 06:00:49
I *think* a helper function in an anonymous namesp
jackhou1
2015/08/17 06:19:13
I don't think ShowPopupAtRect would be able to cal
tapted
2015/08/17 06:30:57
Ah. good point :/. That does make sense of the rep
jackhou1
2015/08/17 06:56:31
Done.
| |
| 296 const gfx::Rect& anchor_rect, | |
| 297 Profile* profile, | |
| 298 content::WebContents* web_contents, | |
| 299 const GURL& url, | |
| 300 const content::SSLStatus& ssl) { | |
| 301 is_popup_showing = true; | |
| 302 if (InternalChromePage(url)) { | |
| 303 InternalPageInfoPopupView* popup = | |
| 304 new InternalPageInfoPopupView(nullptr, web_contents->GetNativeView()); | |
| 305 popup->SetAnchorRect(anchor_rect); | |
| 306 popup->GetWidget()->Show(); | |
| 307 } else { | |
| 308 WebsiteSettingsPopupView* popup = | |
| 309 new WebsiteSettingsPopupView(nullptr, web_contents->GetNativeView(), | |
| 310 profile, web_contents, url, ssl); | |
| 311 popup->SetAnchorRect(anchor_rect); | |
| 312 popup->GetWidget()->Show(); | |
| 282 } | 313 } |
| 283 } | 314 } |
| 284 | 315 |
| 285 // static | 316 // static |
| 286 bool WebsiteSettingsPopupView::IsPopupShowing() { | 317 bool WebsiteSettingsPopupView::IsPopupShowing() { |
| 287 return is_popup_showing; | 318 return is_popup_showing; |
| 288 } | 319 } |
| 289 | 320 |
| 290 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | 321 WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
| 291 views::View* anchor_view, | 322 views::View* anchor_view, |
| 323 gfx::NativeView parent_window, | |
| 292 Profile* profile, | 324 Profile* profile, |
| 293 content::WebContents* web_contents, | 325 content::WebContents* web_contents, |
| 294 const GURL& url, | 326 const GURL& url, |
| 295 const content::SSLStatus& ssl) | 327 const content::SSLStatus& ssl) |
| 296 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 328 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
| 297 web_contents_(web_contents), | 329 web_contents_(web_contents), |
| 298 header_(nullptr), | 330 header_(nullptr), |
| 299 tabbed_pane_(nullptr), | 331 tabbed_pane_(nullptr), |
| 300 permissions_tab_(nullptr), | 332 permissions_tab_(nullptr), |
| 301 site_data_content_(nullptr), | 333 site_data_content_(nullptr), |
| 302 cookie_dialog_link_(nullptr), | 334 cookie_dialog_link_(nullptr), |
| 303 permissions_content_(nullptr), | 335 permissions_content_(nullptr), |
| 304 connection_tab_(nullptr), | 336 connection_tab_(nullptr), |
| 305 identity_info_content_(nullptr), | 337 identity_info_content_(nullptr), |
| 306 certificate_dialog_link_(nullptr), | 338 certificate_dialog_link_(nullptr), |
| 307 reset_decisions_button_(nullptr), | 339 reset_decisions_button_(nullptr), |
| 308 help_center_content_(nullptr), | 340 help_center_content_(nullptr), |
| 309 cert_id_(0), | 341 cert_id_(0), |
| 310 help_center_link_(nullptr), | 342 help_center_link_(nullptr), |
| 311 connection_info_content_(nullptr), | 343 connection_info_content_(nullptr), |
| 312 weak_factory_(this) { | 344 weak_factory_(this) { |
| 345 set_parent_window(parent_window); | |
| 346 | |
| 313 // Compensate for built-in vertical padding in the anchor view's image. | 347 // Compensate for built-in vertical padding in the anchor view's image. |
| 314 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, | 348 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, |
| 315 kLocationIconVerticalMargin, 0)); | 349 kLocationIconVerticalMargin, 0)); |
| 316 | 350 |
| 317 views::GridLayout* layout = new views::GridLayout(this); | 351 views::GridLayout* layout = new views::GridLayout(this); |
| 318 SetLayoutManager(layout); | 352 SetLayoutManager(layout); |
| 319 const int content_column = 0; | 353 const int content_column = 0; |
| 320 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | 354 views::ColumnSet* column_set = layout->AddColumnSet(content_column); |
| 321 column_set->AddColumn(views::GridLayout::FILL, | 355 column_set->AddColumn(views::GridLayout::FILL, |
| 322 views::GridLayout::FILL, | 356 views::GridLayout::FILL, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 347 tabbed_pane_->AddTabAtIndex( | 381 tabbed_pane_->AddTabAtIndex( |
| 348 TAB_ID_CONNECTION, | 382 TAB_ID_CONNECTION, |
| 349 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), | 383 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), |
| 350 connection_tab_); | 384 connection_tab_); |
| 351 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS); | 385 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS); |
| 352 tabbed_pane_->set_listener(this); | 386 tabbed_pane_->set_listener(this); |
| 353 | 387 |
| 354 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, | 388 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, |
| 355 kPopupMarginBottom, kPopupMarginRight)); | 389 kPopupMarginBottom, kPopupMarginRight)); |
| 356 | 390 |
| 357 views::BubbleDelegateView::CreateBubble(this)->Show(); | 391 views::BubbleDelegateView::CreateBubble(this); |
| 358 SizeToContents(); | |
| 359 | 392 |
| 360 presenter_.reset(new WebsiteSettings( | 393 presenter_.reset(new WebsiteSettings( |
| 361 this, profile, | 394 this, profile, |
| 362 TabSpecificContentSettings::FromWebContents(web_contents), | 395 TabSpecificContentSettings::FromWebContents(web_contents), |
| 363 InfoBarService::FromWebContents(web_contents), url, ssl, | 396 InfoBarService::FromWebContents(web_contents), url, ssl, |
| 364 content::CertStore::GetInstance())); | 397 content::CertStore::GetInstance())); |
| 365 } | 398 } |
| 366 | 399 |
| 367 void WebsiteSettingsPopupView::OnPermissionChanged( | 400 void WebsiteSettingsPopupView::OnPermissionChanged( |
| 368 const WebsiteSettingsUI::PermissionInfo& permission) { | 401 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. | 835 // desktop we should link to that here, too. |
| 803 web_contents_->OpenURL(content::OpenURLParams( | 836 web_contents_->OpenURL(content::OpenURLParams( |
| 804 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), | 837 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), |
| 805 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); | 838 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); |
| 806 presenter_->RecordWebsiteSettingsAction( | 839 presenter_->RecordWebsiteSettingsAction( |
| 807 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); | 840 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); |
| 808 } else { | 841 } else { |
| 809 NOTREACHED(); | 842 NOTREACHED(); |
| 810 } | 843 } |
| 811 } | 844 } |
| OLD | NEW |