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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "ui/views/controls/image_view.h" | 52 #include "ui/views/controls/image_view.h" |
53 #include "ui/views/controls/label.h" | 53 #include "ui/views/controls/label.h" |
54 #include "ui/views/controls/link.h" | 54 #include "ui/views/controls/link.h" |
55 #include "ui/views/controls/styled_label.h" | 55 #include "ui/views/controls/styled_label.h" |
56 #include "ui/views/layout/box_layout.h" | 56 #include "ui/views/layout/box_layout.h" |
57 #include "ui/views/layout/grid_layout.h" | 57 #include "ui/views/layout/grid_layout.h" |
58 #include "ui/views/layout/layout_constants.h" | 58 #include "ui/views/layout/layout_constants.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 "ui/views/widget/widget_observer.h" |
62 #include "url/gurl.h" | 63 #include "url/gurl.h" |
63 | 64 |
64 namespace { | 65 namespace { |
65 | 66 |
66 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's | 67 // 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 | 68 // never more than one website settings popup shown and that it's associated |
68 // with the current window. If this assumption fails in the future, we'll need | 69 // 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 | 70 // 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 | 71 // current window (or other context) and check if the popup they care about is |
71 // showing. | 72 // showing. |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 //////////////////////////////////////////////////////////////////////////////// | 348 //////////////////////////////////////////////////////////////////////////////// |
348 // WebsiteSettingsPopupView | 349 // WebsiteSettingsPopupView |
349 //////////////////////////////////////////////////////////////////////////////// | 350 //////////////////////////////////////////////////////////////////////////////// |
350 | 351 |
351 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | 352 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { |
352 } | 353 } |
353 | 354 |
354 // static | 355 // static |
355 void WebsiteSettingsPopupView::ShowPopup( | 356 void WebsiteSettingsPopupView::ShowPopup( |
356 views::View* anchor_view, | 357 views::View* anchor_view, |
| 358 views::WidgetObserver* widget_observer, |
357 const gfx::Rect& anchor_rect, | 359 const gfx::Rect& anchor_rect, |
358 Profile* profile, | 360 Profile* profile, |
359 content::WebContents* web_contents, | 361 content::WebContents* web_contents, |
360 const GURL& url, | 362 const GURL& url, |
361 const security_state::SecurityInfo& security_info) { | 363 const security_state::SecurityInfo& security_info) { |
362 gfx::NativeView parent_window = | 364 gfx::NativeView parent_window = |
363 anchor_view ? nullptr : web_contents->GetNativeView(); | 365 anchor_view ? nullptr : web_contents->GetNativeView(); |
364 if (url.SchemeIs(content::kChromeUIScheme) || | 366 if (url.SchemeIs(content::kChromeUIScheme) || |
365 url.SchemeIs(content::kChromeDevToolsScheme) || | 367 url.SchemeIs(content::kChromeDevToolsScheme) || |
366 url.SchemeIs(extensions::kExtensionScheme) || | 368 url.SchemeIs(extensions::kExtensionScheme) || |
367 url.SchemeIs(content::kViewSourceScheme)) { | 369 url.SchemeIs(content::kViewSourceScheme)) { |
368 // Use the concrete type so that |SetAnchorRect| can be called as a friend. | 370 // Use the concrete type so that |SetAnchorRect| can be called as a friend. |
369 InternalPageInfoPopupView* popup = | 371 InternalPageInfoPopupView* popup = |
370 new InternalPageInfoPopupView(anchor_view, parent_window, url); | 372 new InternalPageInfoPopupView(anchor_view, parent_window, url); |
371 if (!anchor_view) | 373 if (!anchor_view) |
372 popup->SetAnchorRect(anchor_rect); | 374 popup->SetAnchorRect(anchor_rect); |
373 popup->GetWidget()->Show(); | 375 popup->GetWidget()->Show(); |
374 return; | 376 return; |
375 } | 377 } |
376 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView( | 378 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView( |
377 anchor_view, parent_window, profile, web_contents, url, security_info); | 379 anchor_view, parent_window, profile, web_contents, url, security_info); |
378 if (!anchor_view) | 380 if (!anchor_view) |
379 popup->SetAnchorRect(anchor_rect); | 381 popup->SetAnchorRect(anchor_rect); |
| 382 |
| 383 if (widget_observer) |
| 384 popup->GetWidget()->AddObserver(widget_observer); |
| 385 |
380 popup->GetWidget()->Show(); | 386 popup->GetWidget()->Show(); |
381 } | 387 } |
382 | 388 |
383 // static | 389 // static |
384 WebsiteSettingsPopupView::PopupType | 390 WebsiteSettingsPopupView::PopupType |
385 WebsiteSettingsPopupView::GetShownPopupType() { | 391 WebsiteSettingsPopupView::GetShownPopupType() { |
386 return g_shown_popup_type; | 392 return g_shown_popup_type; |
387 } | 393 } |
388 | 394 |
389 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | 395 WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); | 760 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
755 break; | 761 break; |
756 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 762 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
757 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 763 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
758 GetWidget()->Close(); | 764 GetWidget()->Close(); |
759 break; | 765 break; |
760 default: | 766 default: |
761 NOTREACHED(); | 767 NOTREACHED(); |
762 } | 768 } |
763 } | 769 } |
OLD | NEW |