| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_bubble_view.h" | 5 #include "chrome/browser/ui/views/page_info_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/certificate_viewer.h" | 8 #include "chrome/browser/certificate_viewer.h" |
| 9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
| 10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 y += size.height(); | 467 y += size.height(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 // Make sure the image is not truncated if the text doesn't contain much. | 470 // Make sure the image is not truncated if the text doesn't contain much. |
| 471 y = std::max(y, (2 * kVerticalSectionPadding) + image_height); | 471 y = std::max(y, (2 * kVerticalSectionPadding) + image_height); |
| 472 return gfx::Size(width, y); | 472 return gfx::Size(width, y); |
| 473 } | 473 } |
| 474 | 474 |
| 475 namespace browser { | 475 namespace browser { |
| 476 | 476 |
| 477 void ShowPageInfoBubble(gfx::NativeWindow parent, | 477 void ShowPageInfoBubble(BrowserView* browser_view, |
| 478 Profile* profile, | 478 Profile* profile, |
| 479 const GURL& url, | 479 const GURL& url, |
| 480 const NavigationEntry::SSLStatus& ssl, | 480 const NavigationEntry::SSLStatus& ssl, |
| 481 bool show_history) { | 481 bool show_history) { |
| 482 // Find where to point the bubble at. | 482 // Find where to point the bubble at. |
| 483 BrowserView* browser_view = | |
| 484 BrowserView::GetBrowserViewForNativeWindow(parent); | |
| 485 gfx::Point point; | 483 gfx::Point point; |
| 486 if (base::i18n::IsRTL()) { | 484 if (base::i18n::IsRTL()) { |
| 487 int width = browser_view->toolbar()->location_bar()->width(); | 485 int width = browser_view->toolbar()->location_bar()->width(); |
| 488 point = gfx::Point(width - kIconHorizontalOffset, 0); | 486 point = gfx::Point(width - kIconHorizontalOffset, 0); |
| 489 } | 487 } |
| 490 point.Offset(0, kIconVerticalOffset); | 488 point.Offset(0, kIconVerticalOffset); |
| 491 views::View::ConvertPointToScreen(browser_view->toolbar()->location_bar(), | 489 views::View::ConvertPointToScreen(browser_view->toolbar()->location_bar(), |
| 492 &point); | 490 &point); |
| 493 gfx::Rect bounds = browser_view->toolbar()->location_bar()->bounds(); | 491 gfx::Rect bounds = browser_view->toolbar()->location_bar()->bounds(); |
| 494 bounds.set_origin(point); | 492 bounds.set_origin(point); |
| 495 bounds.set_width(kIconHorizontalOffset); | 493 bounds.set_width(kIconHorizontalOffset); |
| 496 | 494 |
| 497 // Show the bubble. If the bubble already exist - it will be closed first. | 495 // Show the bubble. If the bubble already exist - it will be closed first. |
| 498 PageInfoBubbleView* page_info_bubble = | 496 PageInfoBubbleView* page_info_bubble = |
| 499 new PageInfoBubbleView(parent, profile, url, ssl, show_history); | 497 new PageInfoBubbleView(browser_view->GetNativeHandle(), |
| 498 profile, url, ssl, show_history); |
| 500 Bubble* bubble = | 499 Bubble* bubble = |
| 501 Bubble::Show(browser_view->GetWidget(), bounds, | 500 Bubble::Show(browser_view->GetWidget(), bounds, |
| 502 views::BubbleBorder::TOP_LEFT, | 501 views::BubbleBorder::TOP_LEFT, |
| 503 page_info_bubble, page_info_bubble); | 502 page_info_bubble, page_info_bubble); |
| 504 page_info_bubble->set_bubble(bubble); | 503 page_info_bubble->set_bubble(bubble); |
| 505 } | 504 } |
| 506 | 505 |
| 507 } | 506 } |
| OLD | NEW |