| 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/location_bar/zoom_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, | 39 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
| 40 DisplayReason reason) { | 40 DisplayReason reason) { |
| 41 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 41 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 42 DCHECK(browser && browser->window() && | 42 DCHECK(browser && browser->window() && |
| 43 browser->exclusive_access_manager()->fullscreen_controller()); | 43 browser->exclusive_access_manager()->fullscreen_controller()); |
| 44 | 44 |
| 45 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 45 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 46 bool is_fullscreen = browser_view->IsFullscreen(); | 46 bool is_fullscreen = browser_view->IsFullscreen(); |
| 47 bool anchor_to_view = !is_fullscreen || | 47 bool anchor_to_view = !is_fullscreen || |
| 48 browser_view->immersive_mode_controller()->IsRevealed(); | 48 browser_view->immersive_mode_controller()->IsRevealed(); |
| 49 views::View* anchor_view = anchor_to_view ? | 49 ZoomView* anchor_view = anchor_to_view ? |
| 50 browser_view->GetLocationBarView()->zoom_view() : NULL; | 50 browser_view->GetLocationBarView()->zoom_view() : NULL; |
| 51 | 51 |
| 52 // Find the extension that initiated the zoom change, if any. | 52 // Find the extension that initiated the zoom change, if any. |
| 53 ui_zoom::ZoomController* zoom_controller = | 53 ui_zoom::ZoomController* zoom_controller = |
| 54 ui_zoom::ZoomController::FromWebContents(web_contents); | 54 ui_zoom::ZoomController::FromWebContents(web_contents); |
| 55 const ui_zoom::ZoomRequestClient* client = zoom_controller->last_client(); | 55 const ui_zoom::ZoomRequestClient* client = zoom_controller->last_client(); |
| 56 | 56 |
| 57 // If the bubble is already showing in this window and the zoom change was not | 57 // If the bubble is already showing in this window and the zoom change was not |
| 58 // initiated by an extension, then the bubble can be reused and only the label | 58 // initiated by an extension, then the bubble can be reused and only the label |
| 59 // text needs to be updated. | 59 // text needs to be updated. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 75 if (client) { | 75 if (client) { |
| 76 zoom_bubble_->SetExtensionInfo( | 76 zoom_bubble_->SetExtensionInfo( |
| 77 static_cast<const extensions::ExtensionZoomRequestClient*>(client) | 77 static_cast<const extensions::ExtensionZoomRequestClient*>(client) |
| 78 ->extension()); | 78 ->extension()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // If we do not have an anchor view, parent the bubble to the content area. | 81 // If we do not have an anchor view, parent the bubble to the content area. |
| 82 if (!anchor_to_view) | 82 if (!anchor_to_view) |
| 83 zoom_bubble_->set_parent_window(web_contents->GetNativeView()); | 83 zoom_bubble_->set_parent_window(web_contents->GetNativeView()); |
| 84 | 84 |
| 85 views::BubbleDelegateView::CreateBubble(zoom_bubble_); | 85 views::Widget* zoom_bubble_widget = |
| 86 views::BubbleDelegateView::CreateBubble(zoom_bubble_); |
| 87 if (anchor_view) |
| 88 zoom_bubble_widget->AddObserver(anchor_view); |
| 86 | 89 |
| 87 // Adjust for fullscreen after creation as it relies on the content size. | 90 // Adjust for fullscreen after creation as it relies on the content size. |
| 88 if (is_fullscreen) | 91 if (is_fullscreen) |
| 89 zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen()); | 92 zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen()); |
| 90 | 93 |
| 91 zoom_bubble_->ShowForReason(reason); | 94 zoom_bubble_->ShowForReason(reason); |
| 92 } | 95 } |
| 93 | 96 |
| 94 // static | 97 // static |
| 95 void ZoomBubbleView::CloseBubble() { | 98 void ZoomBubbleView::CloseBubble() { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 314 } |
| 312 } | 315 } |
| 313 | 316 |
| 314 void ZoomBubbleView::StopTimer() { | 317 void ZoomBubbleView::StopTimer() { |
| 315 timer_.Stop(); | 318 timer_.Stop(); |
| 316 } | 319 } |
| 317 | 320 |
| 318 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} | 321 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} |
| 319 | 322 |
| 320 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} | 323 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} |
| OLD | NEW |