| Index: chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm b/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm
|
| index 35aded4deb17a31eaccb49243bcf916fcff7edaf..0b806763daf4cfd16d27d9b6be759bb259cb240a 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm
|
| +++ b/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm
|
| @@ -9,6 +9,8 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "chrome/app/chrome_command_ids.h"
|
| #include "chrome/app/vector_icons/vector_icons.h"
|
| +#include "chrome/browser/ui/browser_dialogs.h"
|
| +#import "chrome/browser/ui/cocoa/browser_window_controller.h"
|
| #import "chrome/browser/ui/cocoa/l10n_util.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
|
| @@ -19,11 +21,17 @@
|
| #include "components/zoom/zoom_controller.h"
|
| #include "ui/base/cocoa/cocoa_base_utils.h"
|
| #include "ui/base/l10n/l10n_util_mac.h"
|
| +#include "ui/base/material_design/material_design_controller.h"
|
| +#import "ui/gfx/mac/coordinate_conversion.h"
|
|
|
| ZoomDecoration::ZoomDecoration(LocationBarViewMac* owner)
|
| : owner_(owner), bubble_(nullptr), vector_icon_(nullptr) {}
|
|
|
| ZoomDecoration::~ZoomDecoration() {
|
| + if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
|
| + CloseBubble();
|
| + return;
|
| + }
|
| [bubble_ closeWithoutAnimation];
|
| bubble_.delegate = nil;
|
| }
|
| @@ -32,7 +40,7 @@ bool ZoomDecoration::UpdateIfNecessary(zoom::ZoomController* zoom_controller,
|
| bool default_zoom_changed,
|
| bool location_bar_is_dark) {
|
| if (!ShouldShowDecoration()) {
|
| - if (!IsVisible() && !bubble_)
|
| + if (!IsVisible() && !IsBubbleShown())
|
| return false;
|
|
|
| HideUI();
|
| @@ -77,6 +85,22 @@ void ZoomDecoration::ShowBubble(BOOL auto_close) {
|
| const NSRect frame =
|
| [[field cell] frameForDecoration:this inFrame:[field bounds]];
|
|
|
| + if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
|
| + NSWindow* window = [web_contents->GetNativeView() window];
|
| + if (!window) {
|
| + // The tab isn't active right now.
|
| + return;
|
| + }
|
| + BrowserWindowController* browser_window_controller =
|
| + [BrowserWindowController browserWindowControllerForWindow:window];
|
| + NSPoint anchor = [browser_window_controller bookmarkBubblePoint];
|
| + gfx::Point anchor_point = gfx::ScreenPointFromNSPoint(
|
| + ui::ConvertPointFromWindowToScreen(window, anchor));
|
| + chrome::ShowZoomBubbleViewsAtPoint(web_contents, anchor_point,
|
| + auto_close == NO /* user_action */);
|
| + return;
|
| + }
|
| +
|
| // Find point for bubble's arrow in screen coordinates.
|
| NSPoint anchor = GetBubblePointInFrame(frame);
|
| anchor = [field convertPoint:anchor toView:nil];
|
| @@ -88,11 +112,15 @@ void ZoomDecoration::ShowBubble(BOOL auto_close) {
|
| }
|
|
|
| void ZoomDecoration::CloseBubble() {
|
| + if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
|
| + chrome::CloseZoomBubbleViews();
|
| + return;
|
| + }
|
| [bubble_ close];
|
| }
|
|
|
| void ZoomDecoration::HideUI() {
|
| - [bubble_ close];
|
| + CloseBubble();
|
| SetVisible(false);
|
| }
|
|
|
| @@ -113,7 +141,10 @@ void ZoomDecoration::UpdateUI(zoom::ZoomController* zoom_controller,
|
|
|
| tooltip_.reset([tooltip_string retain]);
|
|
|
| - [bubble_ onZoomChanged];
|
| + if (ui::MaterialDesignController::IsSecondaryUiMaterial())
|
| + chrome::RefreshZoomBubbleViews();
|
| + else
|
| + [bubble_ onZoomChanged];
|
| }
|
|
|
| NSPoint ZoomDecoration::GetBubblePointInFrame(NSRect frame) {
|
| @@ -133,10 +164,16 @@ bool ZoomDecoration::IsAtDefaultZoom() const {
|
| return zoomController && zoomController->IsAtDefaultZoom();
|
| }
|
|
|
| +bool ZoomDecoration::IsBubbleShown() const {
|
| + return (ui::MaterialDesignController::IsSecondaryUiMaterial() &&
|
| + chrome::IsZoomBubbleViewsShown()) ||
|
| + bubble_;
|
| +}
|
| +
|
| bool ZoomDecoration::ShouldShowDecoration() const {
|
| return owner_->GetWebContents() != NULL &&
|
| - !owner_->GetToolbarModel()->input_in_progress() &&
|
| - (bubble_ || !IsAtDefaultZoom());
|
| + !owner_->GetToolbarModel()->input_in_progress() &&
|
| + (IsBubbleShown() || !IsAtDefaultZoom());
|
| }
|
|
|
| bool ZoomDecoration::AcceptsMousePress() {
|
| @@ -144,10 +181,15 @@ bool ZoomDecoration::AcceptsMousePress() {
|
| }
|
|
|
| bool ZoomDecoration::OnMousePressed(NSRect frame, NSPoint location) {
|
| - if (bubble_)
|
| + if (IsBubbleShown()) {
|
| CloseBubble();
|
| - else
|
| - ShowBubble(YES);
|
| + } else {
|
| + // With Material Design enabled the zoom bubble is no longer auto-closed
|
| + // when activated with a mouse click.
|
| + const BOOL auto_close =
|
| + !ui::MaterialDesignController::IsSecondaryUiMaterial();
|
| + ShowBubble(auto_close);
|
| + }
|
| return true;
|
| }
|
|
|
| @@ -160,8 +202,10 @@ content::WebContents* ZoomDecoration::GetWebContents() {
|
| }
|
|
|
| void ZoomDecoration::OnClose() {
|
| - bubble_.delegate = nil;
|
| - bubble_ = nil;
|
| + if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) {
|
| + bubble_.delegate = nil;
|
| + bubble_ = nil;
|
| + }
|
|
|
| // If the page is at default zoom then hiding the zoom decoration
|
| // was suppressed while the bubble was open. Now that the bubble is
|
|
|