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 <vector> | 10 #include <vector> |
(...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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 339 |
339 //////////////////////////////////////////////////////////////////////////////// | 340 //////////////////////////////////////////////////////////////////////////////// |
340 // PageInfoBubbleView | 341 // PageInfoBubbleView |
341 //////////////////////////////////////////////////////////////////////////////// | 342 //////////////////////////////////////////////////////////////////////////////// |
342 | 343 |
343 PageInfoBubbleView::~PageInfoBubbleView() {} | 344 PageInfoBubbleView::~PageInfoBubbleView() {} |
344 | 345 |
345 // static | 346 // static |
346 void PageInfoBubbleView::ShowBubble( | 347 void PageInfoBubbleView::ShowBubble( |
347 views::View* anchor_view, | 348 views::View* anchor_view, |
| 349 views::WidgetObserver* widget_observer, |
348 const gfx::Rect& anchor_rect, | 350 const gfx::Rect& anchor_rect, |
349 Profile* profile, | 351 Profile* profile, |
350 content::WebContents* web_contents, | 352 content::WebContents* web_contents, |
351 const GURL& url, | 353 const GURL& url, |
352 const security_state::SecurityInfo& security_info) { | 354 const security_state::SecurityInfo& security_info) { |
353 gfx::NativeView parent_window = | 355 gfx::NativeView parent_window = |
354 anchor_view ? nullptr : web_contents->GetNativeView(); | 356 anchor_view ? nullptr : web_contents->GetNativeView(); |
355 if (url.SchemeIs(content::kChromeUIScheme) || | 357 if (url.SchemeIs(content::kChromeUIScheme) || |
356 url.SchemeIs(content::kChromeDevToolsScheme) || | 358 url.SchemeIs(content::kChromeDevToolsScheme) || |
357 url.SchemeIs(extensions::kExtensionScheme) || | 359 url.SchemeIs(extensions::kExtensionScheme) || |
358 url.SchemeIs(content::kViewSourceScheme)) { | 360 url.SchemeIs(content::kViewSourceScheme)) { |
359 // Use the concrete type so that |SetAnchorRect| can be called as a friend. | 361 // Use the concrete type so that |SetAnchorRect| can be called as a friend. |
360 InternalPageInfoBubbleView* bubble = | 362 InternalPageInfoBubbleView* bubble = |
361 new InternalPageInfoBubbleView(anchor_view, parent_window, url); | 363 new InternalPageInfoBubbleView(anchor_view, parent_window, url); |
362 if (!anchor_view) | 364 if (!anchor_view) |
363 bubble->SetAnchorRect(anchor_rect); | 365 bubble->SetAnchorRect(anchor_rect); |
| 366 if (widget_observer) |
| 367 bubble->GetWidget()->AddObserver(widget_observer); |
364 bubble->GetWidget()->Show(); | 368 bubble->GetWidget()->Show(); |
365 return; | 369 return; |
366 } | 370 } |
367 PageInfoBubbleView* bubble = new PageInfoBubbleView( | 371 PageInfoBubbleView* bubble = new PageInfoBubbleView( |
368 anchor_view, parent_window, profile, web_contents, url, security_info); | 372 anchor_view, parent_window, profile, web_contents, url, security_info); |
369 if (!anchor_view) | 373 if (!anchor_view) |
370 bubble->SetAnchorRect(anchor_rect); | 374 bubble->SetAnchorRect(anchor_rect); |
| 375 if (widget_observer) |
| 376 bubble->GetWidget()->AddObserver(widget_observer); |
371 bubble->GetWidget()->Show(); | 377 bubble->GetWidget()->Show(); |
372 } | 378 } |
373 | 379 |
374 // static | 380 // static |
375 PageInfoBubbleView::BubbleType PageInfoBubbleView::GetShownBubbleType() { | 381 PageInfoBubbleView::BubbleType PageInfoBubbleView::GetShownBubbleType() { |
376 return g_shown_bubble_type; | 382 return g_shown_bubble_type; |
377 } | 383 } |
378 | 384 |
379 PageInfoBubbleView::PageInfoBubbleView( | 385 PageInfoBubbleView::PageInfoBubbleView( |
380 views::View* anchor_view, | 386 views::View* anchor_view, |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); | 753 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); |
748 break; | 754 break; |
749 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 755 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
750 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 756 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
751 GetWidget()->Close(); | 757 GetWidget()->Close(); |
752 break; | 758 break; |
753 default: | 759 default: |
754 NOTREACHED(); | 760 NOTREACHED(); |
755 } | 761 } |
756 } | 762 } |
OLD | NEW |