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/page_info/page_info_bubble_view.h" | 5 #include "chrome/browser/ui/views/page_info/page_info_bubble_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "ui/views/controls/button/md_text_button.h" | 51 #include "ui/views/controls/button/md_text_button.h" |
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_manager.h" | 58 #include "ui/views/layout/layout_manager.h" |
59 #include "ui/views/view.h" | 59 #include "ui/views/view.h" |
60 #include "ui/views/widget/widget.h" | 60 #include "ui/views/widget/widget.h" |
| 61 #include "ui/views/widget/widget_observer.h" |
61 #include "url/gurl.h" | 62 #include "url/gurl.h" |
62 | 63 |
63 namespace { | 64 namespace { |
64 | 65 |
65 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's | 66 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's |
66 // never more than one page info bubble shown and that it's associated | 67 // never more than one page info bubble shown and that it's associated |
67 // with the current window. If this assumption fails in the future, we'll need | 68 // with the current window. If this assumption fails in the future, we'll need |
68 // to return a weak pointer from ShowBubble so callers can associate it with the | 69 // to return a weak pointer from ShowBubble so callers can associate it with the |
69 // current window (or other context) and check if the bubble they care about is | 70 // current window (or other context) and check if the bubble they care about is |
70 // showing. | 71 // showing. |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 381 |
381 //////////////////////////////////////////////////////////////////////////////// | 382 //////////////////////////////////////////////////////////////////////////////// |
382 // PageInfoBubbleView | 383 // PageInfoBubbleView |
383 //////////////////////////////////////////////////////////////////////////////// | 384 //////////////////////////////////////////////////////////////////////////////// |
384 | 385 |
385 PageInfoBubbleView::~PageInfoBubbleView() {} | 386 PageInfoBubbleView::~PageInfoBubbleView() {} |
386 | 387 |
387 // static | 388 // static |
388 void PageInfoBubbleView::ShowBubble( | 389 void PageInfoBubbleView::ShowBubble( |
389 views::View* anchor_view, | 390 views::View* anchor_view, |
| 391 views::WidgetObserver* widget_observer, |
390 const gfx::Rect& anchor_rect, | 392 const gfx::Rect& anchor_rect, |
391 Profile* profile, | 393 Profile* profile, |
392 content::WebContents* web_contents, | 394 content::WebContents* web_contents, |
393 const GURL& url, | 395 const GURL& url, |
394 const security_state::SecurityInfo& security_info) { | 396 const security_state::SecurityInfo& security_info) { |
395 gfx::NativeView parent_window = | 397 gfx::NativeView parent_window = |
396 anchor_view ? nullptr : web_contents->GetNativeView(); | 398 anchor_view ? nullptr : web_contents->GetNativeView(); |
397 if (url.SchemeIs(content::kChromeUIScheme) || | 399 if (url.SchemeIs(content::kChromeUIScheme) || |
398 url.SchemeIs(content::kChromeDevToolsScheme) || | 400 url.SchemeIs(content::kChromeDevToolsScheme) || |
399 url.SchemeIs(extensions::kExtensionScheme) || | 401 url.SchemeIs(extensions::kExtensionScheme) || |
400 url.SchemeIs(content::kViewSourceScheme)) { | 402 url.SchemeIs(content::kViewSourceScheme)) { |
401 // Use the concrete type so that |SetAnchorRect| can be called as a friend. | 403 // Use the concrete type so that |SetAnchorRect| can be called as a friend. |
402 InternalPageInfoBubbleView* bubble = | 404 InternalPageInfoBubbleView* bubble = |
403 new InternalPageInfoBubbleView(anchor_view, parent_window, url); | 405 new InternalPageInfoBubbleView(anchor_view, parent_window, url); |
404 if (!anchor_view) | 406 if (!anchor_view) |
405 bubble->SetAnchorRect(anchor_rect); | 407 bubble->SetAnchorRect(anchor_rect); |
| 408 if (widget_observer) |
| 409 bubble->GetWidget()->AddObserver(widget_observer); |
406 bubble->GetWidget()->Show(); | 410 bubble->GetWidget()->Show(); |
407 return; | 411 return; |
408 } | 412 } |
409 PageInfoBubbleView* bubble = new PageInfoBubbleView( | 413 PageInfoBubbleView* bubble = new PageInfoBubbleView( |
410 anchor_view, parent_window, profile, web_contents, url, security_info); | 414 anchor_view, parent_window, profile, web_contents, url, security_info); |
411 if (!anchor_view) | 415 if (!anchor_view) |
412 bubble->SetAnchorRect(anchor_rect); | 416 bubble->SetAnchorRect(anchor_rect); |
| 417 if (widget_observer) |
| 418 bubble->GetWidget()->AddObserver(widget_observer); |
413 bubble->GetWidget()->Show(); | 419 bubble->GetWidget()->Show(); |
414 } | 420 } |
415 | 421 |
416 // static | 422 // static |
417 PageInfoBubbleView::BubbleType PageInfoBubbleView::GetShownBubbleType() { | 423 PageInfoBubbleView::BubbleType PageInfoBubbleView::GetShownBubbleType() { |
418 return g_shown_bubble_type; | 424 return g_shown_bubble_type; |
419 } | 425 } |
420 | 426 |
421 PageInfoBubbleView::PageInfoBubbleView( | 427 PageInfoBubbleView::PageInfoBubbleView( |
422 views::View* anchor_view, | 428 views::View* anchor_view, |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); | 791 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); |
786 break; | 792 break; |
787 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 793 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
788 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 794 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
789 GetWidget()->Close(); | 795 GetWidget()->Close(); |
790 break; | 796 break; |
791 default: | 797 default: |
792 NOTREACHED(); | 798 NOTREACHED(); |
793 } | 799 } |
794 } | 800 } |
OLD | NEW |