Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/zoom_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc |
| index def41333f35393d2c6636058b6993c21a3e16eca..97ba3de06ab5967b6c61f8050281217ef72bd3e6 100644 |
| --- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc |
| @@ -8,11 +8,11 @@ |
| #include "base/i18n/rtl.h" |
| #include "base/strings/stringprintf.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/platform_util.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| #include "chrome/browser/ui/browser_tabstrip.h" |
| #include "chrome/browser/ui/browser_window.h" |
| -#include "chrome/browser/ui/views/frame/browser_view.h" |
| #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
| #include "chrome/common/extensions/api/extension_action/action_info.h" |
| @@ -26,6 +26,7 @@ |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/material_design/material_design_controller.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +#include "ui/base/ui_features.h" |
| #include "ui/gfx/favicon_size.h" |
| #include "ui/views/controls/button/image_button.h" |
| #include "ui/views/controls/button/md_text_button.h" |
| @@ -34,19 +35,26 @@ |
| #include "ui/views/layout/layout_constants.h" |
| #include "ui/views/widget/widget.h" |
| +#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| +#include "chrome/browser/ui/views/frame/browser_view.h" |
| +#endif |
| + |
| // static |
| ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = nullptr; |
| // static |
| void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
| + const gfx::Point& anchor_point, |
| DisplayReason reason) { |
| Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| DCHECK(browser && browser->window() && |
| browser->exclusive_access_manager()->fullscreen_controller()); |
| - BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| - bool is_fullscreen = browser_view->IsFullscreen(); |
| views::View* anchor_view = nullptr; |
| + ImmersiveModeController* immersive_mode_controller = nullptr; |
| + bool is_fullscreen = browser->window()->IsFullscreen(); |
| +#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| + BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| if (!is_fullscreen || |
| browser_view->immersive_mode_controller()->IsRevealed()) { |
| if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| @@ -54,6 +62,8 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
| else |
| anchor_view = browser_view->GetLocationBarView()->zoom_view(); |
| } |
| + immersive_mode_controller = browser_view->immersive_mode_controller(); |
| +#endif |
| // Find the extension that initiated the zoom change, if any. |
| zoom::ZoomController* zoom_controller = |
| @@ -73,8 +83,8 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
| // bubble must be closed and a new one created. |
| CloseCurrentBubble(); |
| - zoom_bubble_ = new ZoomBubbleView(anchor_view, web_contents, reason, |
| - browser_view->immersive_mode_controller()); |
| + zoom_bubble_ = new ZoomBubbleView(anchor_view, anchor_point, web_contents, |
| + reason, immersive_mode_controller); |
| // If the zoom change was initiated by an extension, capture the relevent |
| // information from it. |
| @@ -84,6 +94,7 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
| ->extension()); |
| } |
| +#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| // If we do not have an anchor view, parent the bubble to the content area. |
| if (!anchor_view) |
| zoom_bubble_->set_parent_window(web_contents->GetNativeView()); |
| @@ -94,10 +105,18 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
| zoom_bubble_widget->AddObserver( |
| browser_view->GetLocationBarView()->zoom_view()); |
| } |
| +#else |
| + gfx::NativeView parent = |
| + platform_util::GetViewForWindow(browser->window()->GetNativeWindow()); |
| + DCHECK(parent); |
| + zoom_bubble_->set_arrow(views::BubbleBorder::TOP_RIGHT); |
| + zoom_bubble_->set_parent_window(parent); |
| + views::BubbleDialogDelegateView::CreateBubble(zoom_bubble_); |
| +#endif |
| // Adjust for fullscreen after creation as it relies on the content size. |
| if (is_fullscreen) |
| - zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen()); |
| + zoom_bubble_->AdjustForFullscreen(browser->window()->GetBounds()); |
| zoom_bubble_->ShowForReason(reason); |
| } |
| @@ -113,19 +132,30 @@ ZoomBubbleView* ZoomBubbleView::GetZoomBubble() { |
| return zoom_bubble_; |
| } |
| +void ZoomBubbleView::Refresh() { |
| + zoom::ZoomController* zoom_controller = |
| + zoom::ZoomController::FromWebContents(web_contents_); |
| + int zoom_percent = zoom_controller->GetZoomPercent(); |
| + label_->SetText(l10n_util::GetStringFUTF16( |
| + IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); |
| + StartTimerIfNecessary(); |
| +} |
| + |
| ZoomBubbleView::ZoomBubbleView( |
| views::View* anchor_view, |
| + const gfx::Point& anchor_point, |
| content::WebContents* web_contents, |
| DisplayReason reason, |
| ImmersiveModeController* immersive_mode_controller) |
| - : LocationBarBubbleDelegateView(anchor_view, web_contents), |
| + : LocationBarBubbleDelegateView(anchor_view, anchor_point, web_contents), |
| image_button_(nullptr), |
| label_(nullptr), |
| web_contents_(web_contents), |
| auto_close_(reason == AUTOMATIC), |
| immersive_mode_controller_(immersive_mode_controller) { |
| set_notify_enter_exit_on_child(true); |
| - immersive_mode_controller_->AddObserver(this); |
| + if (immersive_mode_controller_) |
| + immersive_mode_controller_->AddObserver(this); |
| UseCompactMargins(); |
| } |
| @@ -186,8 +216,7 @@ void ZoomBubbleView::Init() { |
| int zoom_percent = zoom_controller->GetZoomPercent(); |
| label_ = new views::Label(l10n_util::GetStringFUTF16( |
| IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); |
| - label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| - ui::ResourceBundle::MediumFont)); |
| + label_->SetFontList(GetTitleFontList()); |
|
msw
2017/04/24 18:53:39
aside: when updating the bubble appearance in a fo
varkha
2017/04/26 04:52:59
Not sure. The new mocks still show this not above
|
| grid_layout->AddView(label_); |
| // Second row. |
| @@ -249,15 +278,6 @@ void ZoomBubbleView::OnExtensionIconImageChanged( |
| image_button_->SchedulePaint(); |
| } |
| -void ZoomBubbleView::Refresh() { |
| - zoom::ZoomController* zoom_controller = |
| - zoom::ZoomController::FromWebContents(web_contents_); |
| - int zoom_percent = zoom_controller->GetZoomPercent(); |
| - label_->SetText(l10n_util::GetStringFUTF16( |
| - IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); |
| - StartTimerIfNecessary(); |
| -} |
| - |
| void ZoomBubbleView::SetExtensionInfo(const extensions::Extension* extension) { |
| DCHECK(extension); |
| extension_info_.id = extension->id(); |