Commit 275f0f4c authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac: Remove unused PageInfoBubbleDecoration and permission bubble bits.

Bug: 832676
Change-Id: I4664d3052a0131ab591b166c1a725f042b55b6b0
Reviewed-on: https://chromium-review.googlesource.com/1240513
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593678}
parent b7636abd
......@@ -185,8 +185,6 @@ jumbo_split_static_library("ui") {
"cocoa/location_bar/location_bar_decoration.mm",
"cocoa/location_bar/location_bar_view_mac.h",
"cocoa/location_bar/location_bar_view_mac.mm",
"cocoa/location_bar/page_info_bubble_decoration.h",
"cocoa/location_bar/page_info_bubble_decoration.mm",
"cocoa/location_bar/zoom_decoration.h",
"cocoa/location_bar/zoom_decoration.mm",
"cocoa/main_menu_item.h",
......@@ -206,8 +204,6 @@ jumbo_split_static_library("ui") {
"cocoa/omnibox/omnibox_popup_view_mac.mm",
"cocoa/omnibox/omnibox_view_mac.h",
"cocoa/omnibox/omnibox_view_mac.mm",
"cocoa/permission_bubble/chooser_bubble_ui_views_mac.mm",
"cocoa/permission_bubble/permission_prompt_impl_views_mac.mm",
"cocoa/rect_path_utils.h",
"cocoa/rect_path_utils.mm",
"cocoa/restart_browser.h",
......@@ -3109,10 +3105,6 @@ jumbo_split_static_library("ui") {
"views/relaunch_notification/get_app_menu_anchor_point.h",
"views/relaunch_notification/get_app_menu_anchor_point.mm",
]
# This source file is compiled out on Mac because there is a
# Mac-specific implementation of it.
sources -= [ "views/permission_bubble/permission_prompt_impl_views.cc" ]
} else {
sources += [
"views/create_application_shortcut_view.cc",
......
......@@ -9,12 +9,10 @@
#include "ui/gfx/native_widget_types.h"
namespace gfx {
class Point;
class Rect;
}
class Browser;
class ExtensionInstalledBubble;
namespace bubble_anchor_util {
......@@ -38,15 +36,6 @@ constexpr int kNoToolbarLeftOffset = 40;
gfx::Rect GetPageInfoAnchorRect(Browser* browser);
#if defined(OS_MACOSX)
// Returns the page info anchor rect for |browser|, which is assumed to have a
// Cocoa browser window.
gfx::Rect GetPageInfoAnchorRectCocoa(Browser* browser);
// Returns the anchor point for the extension installed bubble for |window|,
// which is assumed to be a Cocoa browser window.
gfx::Point GetExtensionInstalledAnchorPointCocoa(
gfx::NativeWindow window,
const ExtensionInstalledBubble* bubble);
// Returns the app menu anchor rect for |browser|, which is assumed to have a
// Cocoa browser window.
......
......@@ -2,29 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <utility>
#include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/bubble_anchor_util.h"
#include "chrome/browser/ui/cocoa/browser_dialogs_views_mac.h"
#include "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
#include "chrome/browser/ui/views/bubble_anchor_util_views.h"
#include "chrome/browser/ui/views/content_setting_bubble_contents.h"
#include "chrome/browser/ui/views/extensions/extension_installed_bubble_view.h"
#include "chrome/browser/ui/views/importer/import_lock_dialog_view.h"
#include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
#include "chrome/browser/ui/views/page_info/page_info_bubble_view.h"
#include "chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog.h"
#include "chrome/browser/ui/views/task_manager_view.h"
#include "chrome/browser/ui/views/update_recommended_message_box.h"
#include "components/constrained_window/constrained_window_views.h"
// This file provides definitions of desktop browser dialog-creation methods for
// Mac where a Cocoa browser is using Views dialogs. I.e. it is included in the
......@@ -34,76 +14,6 @@
namespace chrome {
void ShowPageInfoBubbleViews(Browser* browser,
content::WebContents* web_contents,
const GURL& virtual_url,
const security_state::SecurityInfo& security_info,
bubble_anchor_util::Anchor anchor) {
// Don't show the bubble again if it's already showing. A second click on the
// location icon in the omnibox will dismiss an open bubble. This behaviour is
// consistent with the non-Mac views implementation.
// Note that when the browser is toolkit-views, IsBubbleShowing() is checked
// earlier because the bubble is shown on mouse release (but dismissed on
// mouse pressed). A Cocoa browser does both on mouse pressed, so a check
// when showing is sufficient.
if (PageInfoBubbleView::GetShownBubbleType() !=
PageInfoBubbleView::BUBBLE_NONE) {
return;
}
bubble_anchor_util::AnchorConfiguration configuration =
bubble_anchor_util::GetPageInfoAnchorConfiguration(browser, anchor);
gfx::Rect anchor_rect =
configuration.anchor_view
? gfx::Rect()
: bubble_anchor_util::GetPageInfoAnchorRect(browser);
gfx::NativeWindow parent_window = browser->window()->GetNativeWindow();
views::BubbleDialogDelegateView* bubble =
PageInfoBubbleView::CreatePageInfoBubble(
configuration.anchor_view, anchor_rect, parent_window,
browser->profile(), web_contents, virtual_url, security_info);
bubble->GetWidget()->Show();
bubble->SetArrow(configuration.bubble_arrow);
KeepBubbleAnchored(bubble, GetPageInfoDecoration(parent_window));
}
void ShowBookmarkBubbleViewsAtPoint(const gfx::Point& anchor_point,
gfx::NativeView parent,
bookmarks::BookmarkBubbleObserver* observer,
Browser* browser,
const GURL& virtual_url,
bool already_bookmarked,
LocationBarDecoration* decoration) {
// The Views dialog may prompt for sign in.
std::unique_ptr<BubbleSyncPromoDelegate> delegate(
new BookmarkBubbleSignInDelegate(browser));
BookmarkBubbleView::ShowBubble(
nullptr, nullptr, gfx::Rect(anchor_point, gfx::Size()), parent, observer,
std::move(delegate), browser->profile(), virtual_url, already_bookmarked);
views::BubbleDialogDelegateView* bubble =
BookmarkBubbleView::bookmark_bubble();
KeepBubbleAnchored(bubble, decoration);
}
std::unique_ptr<BubbleUi> BuildViewsExtensionInstalledBubbleUi(
ExtensionInstalledBubble* bubble) {
return std::make_unique<ExtensionInstalledBubbleUi>(bubble);
}
void ShowZoomBubbleViewsAtPoint(content::WebContents* web_contents,
const gfx::Point& anchor_point,
bool user_action,
LocationBarDecoration* decoration) {
ZoomBubbleView::ShowBubble(web_contents, anchor_point,
user_action
? LocationBarBubbleDelegateView::USER_GESTURE
: LocationBarBubbleDelegateView::AUTOMATIC);
if (ZoomBubbleView::GetZoomBubble())
KeepBubbleAnchored(ZoomBubbleView::GetZoomBubble(), decoration);
}
void CloseZoomBubbleViews() {
ZoomBubbleView::CloseCurrentBubble();
}
......@@ -117,30 +27,4 @@ bool IsZoomBubbleViewsShown() {
return ZoomBubbleView::GetZoomBubble() != nullptr;
}
gfx::NativeWindow ContentSettingBubbleViewsBridge::Show(
gfx::NativeView parent_view,
ContentSettingBubbleModel* model,
content::WebContents* web_contents,
const gfx::Point& anchor,
LocationBarDecoration* decoration) {
ContentSettingBubbleContents* contents = new ContentSettingBubbleContents(
model, web_contents, nullptr, views::BubbleBorder::Arrow::TOP_RIGHT);
contents->set_parent_window(parent_view);
contents->SetAnchorRect(gfx::Rect(anchor, gfx::Size()));
views::Widget* widget =
views::BubbleDialogDelegateView::CreateBubble(contents);
widget->Show();
KeepBubbleAnchored(contents, decoration);
return widget->GetNativeWindow();
}
void ShowUpdateChromeDialogViews(gfx::NativeWindow parent) {
UpdateRecommendedMessageBox::Show(parent);
}
void ShowImportLockDialogViews(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback) {
return ImportLockDialogView::Show(parent, callback);
}
} // namespace chrome
......@@ -5,66 +5,8 @@
#ifndef CHROME_BROWSER_UI_COCOA_BROWSER_DIALOGS_VIEWS_MAC_H_
#define CHROME_BROWSER_UI_COCOA_BROWSER_DIALOGS_VIEWS_MAC_H_
#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
#include "chrome/browser/ui/bubble_anchor_util.h"
#include "ui/gfx/native_widget_types.h"
class Browser;
class BubbleUi;
class ContentSettingBubbleModel;
class ExtensionInstalledBubble;
class GURL;
class LocationBarDecoration;
namespace bookmarks {
class BookmarkBubbleObserver;
}
namespace content {
class WebContents;
}
namespace gfx {
class Point;
}
namespace security_state {
struct SecurityInfo;
}
namespace chrome {
// Shows a Views page info bubble on the given |browser|.
void ShowPageInfoBubbleViews(Browser* browser,
content::WebContents* web_contents,
const GURL& virtual_url,
const security_state::SecurityInfo& security_info,
bubble_anchor_util::Anchor anchor);
// Show a Views bookmark bubble at the given point. This occurs when the
// bookmark star is clicked or "Bookmark This Page..." is selected from a menu
// or via a key equivalent.
void ShowBookmarkBubbleViewsAtPoint(const gfx::Point& anchor_point,
gfx::NativeView parent,
bookmarks::BookmarkBubbleObserver* observer,
Browser* browser,
const GURL& url,
bool newly_bookmarked,
LocationBarDecoration* decoration);
// Builds the Views version of an Extension installed bubble.
std::unique_ptr<BubbleUi> BuildViewsExtensionInstalledBubbleUi(
ExtensionInstalledBubble* bubble);
// Shows a views zoom bubble at the |anchor_point|. This occurs when the zoom
// icon is clicked or when a shortcut key is pressed or whenever |web_contents|
// zoom factor changes. |user_action| is used to determine if the bubble will
// auto-close.
void ShowZoomBubbleViewsAtPoint(content::WebContents* web_contents,
const gfx::Point& anchor_point,
bool user_action,
LocationBarDecoration* decoration);
// Closes a views zoom bubble if currently shown.
void CloseZoomBubbleViews();
......@@ -74,27 +16,6 @@ void RefreshZoomBubbleViews();
// Returns true if views zoom bubble is currently shown.
bool IsZoomBubbleViewsShown();
// This is a class so that it can be friended from ContentSettingBubbleContents,
// which allows it to call SetAnchorRect().
class ContentSettingBubbleViewsBridge {
public:
static gfx::NativeWindow Show(gfx::NativeView parent_view,
ContentSettingBubbleModel* model,
content::WebContents* web_contents,
const gfx::Point& anchor,
LocationBarDecoration* decoration);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleViewsBridge);
};
// Shows the import lock dialog.
void ShowImportLockDialogViews(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback);
// Shows the first run bubble.
void ShowFirstRunBubbleViews(Browser* browser);
} // namespace chrome
#endif // CHROME_BROWSER_UI_COCOA_BROWSER_DIALOGS_VIEWS_MAC_H_
......@@ -487,7 +487,6 @@ void BrowserWindowCocoa::UpdateAlertState(TabAlertState alert_state) {
}
void BrowserWindowCocoa::ShowUpdateChromeDialog() {
chrome::ShowUpdateChromeDialogViews(GetNativeWindow());
}
void BrowserWindowCocoa::ShowBookmarkBubble(const GURL& url,
......
......@@ -12,15 +12,4 @@ class Browser;
// Returns true if |browser| has a visible location bar.
bool HasVisibleLocationBarForBrowser(Browser* browser);
// Returns a point screen coordinates at the bottom left of the location bar
// when location bar is present and a point near the left edge of the screen
// otherwise in order to not obscure the fullscreen request bubble.
NSPoint GetPageInfoAnchorPointForBrowser(Browser* browser);
// TODO(tapted): Remove this overload. It's needed for the unit tests for Cocoa
// permission bubbles to force an anchoring type, which can be removed once
// http://crbug.com/740827 is fixed.
NSPoint GetPageInfoAnchorPointForBrowser(Browser* browser,
bool has_location_bar);
#endif // CHROME_BROWSER_UI_COCOA_BUBBLE_ANCHOR_HELPER_H_
......@@ -28,34 +28,3 @@ bool HasVisibleLocationBarForBrowser(Browser* browser) {
browserWindowControllerForWindow:browser->window()->GetNativeWindow()];
return [[bwc fullscreenToolbarController] toolbarFraction] != 0;
}
NSPoint GetPageInfoAnchorPointForBrowser(Browser* browser) {
return GetPageInfoAnchorPointForBrowser(
browser, HasVisibleLocationBarForBrowser(browser));
}
NSPoint GetPageInfoAnchorPointForBrowser(Browser* browser,
bool has_location_bar) {
NSPoint anchor;
NSWindow* parentWindow = browser->window()->GetNativeWindow();
if (has_location_bar) {
BrowserWindowController* browserWindowController =
[BrowserWindowController browserWindowControllerForWindow:parentWindow];
LocationBarViewMac* location_bar =
[browserWindowController locationBarBridge];
anchor = location_bar->GetPageInfoBubblePoint();
} else {
// Position the bubble on the left of the screen if there is no page info
// button to point at.
NSRect contentFrame = [[parentWindow contentView] frame];
CGFloat x_offset =
NSMinX(contentFrame) + bubble_anchor_util::kNoToolbarLeftOffset;
if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) {
x_offset =
NSMaxX(contentFrame) - bubble_anchor_util::kNoToolbarLeftOffset;
}
anchor = NSMakePoint(x_offset, NSMaxY(contentFrame));
}
return ui::ConvertPointFromWindowToScreen(parentWindow, anchor);
}
......@@ -13,9 +13,6 @@ class BubbleDialogDelegateView;
class LocationBarDecoration;
// Returns the page info decoration in the omnibox.
LocationBarDecoration* GetPageInfoDecoration(gfx::NativeWindow window);
// Monitors |bubble|'s parent window for size changes, and updates the bubble
// anchor. The monitor will be deleted when |bubble| is closed. If |decoration|
// is provided, the decoration will be set to active in this function. It will
......
......@@ -12,7 +12,6 @@
#include "chrome/browser/ui/cocoa/l10n_util.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/location_bar/page_info_bubble_decoration.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/widget/widget_observer.h"
......@@ -75,13 +74,6 @@ class BubbleAnchorHelper final : public views::WidgetObserver {
} // namespace
LocationBarDecoration* GetPageInfoDecoration(gfx::NativeWindow window) {
BrowserWindowController* window_controller =
[BrowserWindowController browserWindowControllerForWindow:window];
LocationBarViewMac* location_bar = [window_controller locationBarBridge];
return location_bar ? location_bar->page_info_decoration() : nullptr;
}
void KeepBubbleAnchored(views::BubbleDialogDelegateView* bubble,
LocationBarDecoration* decoration) {
new BubbleAnchorHelper(bubble, decoration, OBSERVE_PARENT);
......
......@@ -25,48 +25,6 @@
namespace bubble_anchor_util {
gfx::Rect GetPageInfoAnchorRectCocoa(Browser* browser) {
// Note the Cocoa browser currently only offers anchor points, not rects.
return gfx::Rect(
gfx::ScreenPointFromNSPoint(GetPageInfoAnchorPointForBrowser(browser)),
gfx::Size());
}
gfx::Point GetExtensionInstalledAnchorPointCocoa(
gfx::NativeWindow window,
const ExtensionInstalledBubble* bubble) {
BrowserWindowController* window_controller =
[BrowserWindowController browserWindowControllerForWindow:window];
ToolbarController* toolbar_controller = [window_controller toolbarController];
NSPoint arrow_point;
switch (bubble->anchor_position()) {
case ExtensionInstalledBubble::ANCHOR_ACTION: {
BrowserActionsController* controller =
[toolbar_controller browserActionsController];
arrow_point = [controller popupPointForId:bubble->extension()->id()];
break;
}
case ExtensionInstalledBubble::ANCHOR_OMNIBOX: {
LocationBarViewMac* locationBarView =
[window_controller locationBarBridge];
arrow_point = locationBarView->GetPageInfoBubblePoint();
break;
}
case ExtensionInstalledBubble::ANCHOR_APP_MENU: {
arrow_point = [toolbar_controller appMenuBubblePoint];
break;
}
default: {
NOTREACHED();
break;
}
}
// Convert to screen coordinates.
arrow_point = ui::ConvertPointFromWindowToScreen(window, arrow_point);
return gfx::ScreenPointFromNSPoint(arrow_point);
}
gfx::Rect GetAppMenuAnchorRectCocoa(Browser* browser) {
NSWindow* window = browser->window()->GetNativeWindow();
BrowserWindowController* bwc = BrowserWindowControllerForWindow(window);
......@@ -76,14 +34,4 @@ gfx::Rect GetAppMenuAnchorRectCocoa(Browser* browser) {
gfx::Size());
}
#if !BUILDFLAG(MAC_VIEWS_BROWSER)
gfx::Rect GetPageInfoAnchorRect(Browser* browser) {
return GetPageInfoAnchorRectCocoa(browser);
}
views::View* GetPageInfoAnchorView(Browser* browser, Anchor anchor) {
return nullptr;
}
#endif
} // namespace bubble_anchor_util
......@@ -9,7 +9,6 @@
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/page_info_bubble_decoration.h"
#import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#import "chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -94,18 +93,6 @@ TEST_F(AutocompleteTextFieldCellTest, FocusedDisplay) {
// indicate that they should be omitted.
const CGFloat kVeryWide = 1000.0;
// TODO(shess): This really wants a |LocationBarViewMac|, but only a
// few methods reference it, so this works well enough. But
// something better would be nice.
PageInfoBubbleDecoration page_info_bubble_decoration(nullptr);
page_info_bubble_decoration.SetVisible(true);
page_info_bubble_decoration.SetImage(
[NSImage imageNamed:@"NSApplicationIcon"]);
page_info_bubble_decoration.SetLabel(@"Application");
[cell addLeadingDecoration:&page_info_bubble_decoration];
EXPECT_NE(page_info_bubble_decoration.GetWidthForSpace(kVeryWide),
LocationBarDecoration::kOmittedWidth);
// Make sure we're actually calling |DrawInFrame()|.
StrictMock<MockDecoration> mock_decoration;
mock_decoration.SetVisible(true);
......
......@@ -26,7 +26,6 @@
class CommandUpdater;
class LocationBarDecoration;
class Profile;
class PageInfoBubbleDecoration;
class ZoomDecoration;
class ZoomDecorationTest;
......@@ -101,9 +100,6 @@ class LocationBarViewMac : public LocationBar,
// associate bubble aims.
NSPoint GetBubblePointForDecoration(LocationBarDecoration* decoration) const;
// Get the point in window coordinates for the page info bubble anchor.
NSPoint GetPageInfoBubblePoint() const;
// When any image decorations change, call this to ensure everything is
// redrawn and laid out if necessary.
void OnDecorationsChanged();
......@@ -163,10 +159,6 @@ class LocationBarViewMac : public LocationBar,
// Returns true if the location bar is dark.
bool IsLocationBarDark() const;
PageInfoBubbleDecoration* page_info_decoration() const {
return page_info_decoration_.get();
}
ZoomDecoration* zoom_decoration() const { return zoom_decoration_.get(); }
Browser* browser() const { return browser_; }
......@@ -189,8 +181,6 @@ class LocationBarViewMac : public LocationBar,
void OnEditBookmarksEnabledChanged();
void UpdatePageInfoText();
// Updates visibility of the content settings icons based on the current
// tab contents state.
bool RefreshContentSettingsDecorations();
......@@ -199,13 +189,6 @@ class LocationBarViewMac : public LocationBar,
// Returns whether any updates were made.
bool UpdateZoomDecoration(bool default_zoom_changed);
// Animates |page_info_decoration_| in or out if applicable. Otherwise,
// show it without animation.
void AnimatePageInfoIfPossible(bool tab_changed);
// Returns true if the |page_info_decoration_| can animate for the |level|.
bool CanAnimateSecurityLevel(security_state::SecurityLevel level) const;
// Returns pointers to all of the LocationBarDecorations owned by this
// LocationBarViewMac. This helper function is used for positioning and
// re-positioning accessibility views.
......@@ -220,10 +203,6 @@ class LocationBarViewMac : public LocationBar,
AutocompleteTextField* field_; // owned by tab controller
// A decoration that shows an icon to the left of the address. If applicable,
// it'll also show information about the current page.
std::unique_ptr<PageInfoBubbleDecoration> page_info_decoration_;
// A zoom icon at the end of the omnibox, which shows at non-standard zoom
// levels.
std::unique_ptr<ZoomDecoration> zoom_decoration_;
......@@ -236,12 +215,6 @@ class LocationBarViewMac : public LocationBar,
// Indicates whether or not the location bar is currently visible.
bool location_bar_visible_;
// True if there's enough room for the omnibox to show the security verbose.
bool is_width_available_for_security_verbose_;
// The security level that's displayed on |page_info_decoration_|.
security_state::SecurityLevel security_level_;
DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac);
};
......
......@@ -28,7 +28,6 @@
#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"
#import "chrome/browser/ui/cocoa/location_bar/page_info_bubble_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h"
#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
......@@ -69,9 +68,6 @@ namespace {
const int kDefaultIconSize = 16;
// The minimum width the URL should have for the verbose state to be shown.
const int kMinURLWidth = 120;
// Color of the vector graphic icons when the location bar is dark.
// SkColorSetARGB(0xCC, 0xFF, 0xFF 0xFF);
const SkColor kMaterialDarkVectorIconColor = SK_ColorWHITE;
......@@ -89,12 +85,9 @@ LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field,
ChromeOmniboxEditController(command_updater),
omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)),
field_(field),
page_info_decoration_(new PageInfoBubbleDecoration(this)),
zoom_decoration_(new ZoomDecoration(this)),
browser_(browser),
location_bar_visible_(true),
is_width_available_for_security_verbose_(false),
security_level_(security_state::NONE) {
location_bar_visible_(true) {
edit_bookmarks_enabled_.Init(
bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged,
......@@ -240,10 +233,6 @@ NSPoint LocationBarViewMac::GetBubblePointForDecoration(
return [field_ bubblePointForDecoration:decoration];
}
NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const {
return [field_ bubblePointForDecoration:page_info_decoration_.get()];
}
void LocationBarViewMac::OnDecorationsChanged() {
// TODO(shess): The field-editor frame and cursor rects should not
// change, here.
......@@ -265,12 +254,8 @@ void LocationBarViewMac::Layout() {
// the constructor. I am still wrestling with how best to deal with
// right-hand decorations, which are not a static set.
[cell clearDecorations];
[cell addLeadingDecoration:page_info_decoration_.get()];
[cell addTrailingDecoration:zoom_decoration_.get()];
// By default only the location icon is visible.
page_info_decoration_->SetVisible(true);
// Get the keyword to use for keyword-search and hinting.
const base::string16 keyword = omnibox_view_->model()->keyword();
base::string16 short_name;
......@@ -280,26 +265,6 @@ void LocationBarViewMac::Layout() {
GetKeywordShortName(keyword, &is_extension_keyword);
}
const bool is_keyword_hint = omnibox_view_->model()->is_keyword_hint();
page_info_decoration_->SetFullLabel(nil);
CGFloat available_width =
[cell availableWidthInFrame:[[cell controlView] frame]];
is_width_available_for_security_verbose_ = available_width >= kMinURLWidth;
NSString* a11y_description = @"";
if (!keyword.empty() && !is_keyword_hint) {
} else if (!keyword.empty() && is_keyword_hint) {
} else {
UpdatePageInfoText();
}
[cell accessibilitySetOverrideValue:a11y_description
forAttribute:NSAccessibilityDescriptionAttribute];
if (!page_info_decoration_->IsVisible())
page_info_decoration_->ResetAnimation();
// These need to change anytime the layout changes.
// TODO(shess): Anytime the field editor might have changed, the
// cursor rects almost certainly should have changed. The tooltips
......@@ -327,7 +292,6 @@ void LocationBarViewMac::Update(const WebContents* contents) {
RefreshContentSettingsDecorations();
if (contents) {
omnibox_view_->OnTabChanged(contents);
AnimatePageInfoIfPossible(contents);
} else {
omnibox_view_->Update();
}
......@@ -340,24 +304,6 @@ void LocationBarViewMac::UpdateWithoutTabRestore() {
}
void LocationBarViewMac::UpdateLocationIcon() {
SkColor vector_icon_color = GetLocationBarIconColor();
gfx::ImageSkia image_skia;
if (GetPageInfoVerboseType() == PageInfoVerboseType::kEVCert) {
image_skia = gfx::CreateVectorIcon(toolbar::kHttpsValidIcon,
kDefaultIconSize, vector_icon_color);
} else {
// The view may return an icon asynchronously when certain flags are on,
// but the Cocoa implementation should just ignore them.
image_skia = omnibox_view_->GetIcon(kDefaultIconSize, vector_icon_color,
base::DoNothing());
}
NSImage* image = NSImageFromImageSkiaWithColorSpace(
image_skia, base::mac::GetSRGBColorSpace());
page_info_decoration_->SetImage(image);
page_info_decoration_->SetLabelColor(vector_icon_color);
Layout();
}
void LocationBarViewMac::UpdateColorsToMatchTheme() {
......@@ -377,7 +323,6 @@ void LocationBarViewMac::OnThemeChanged() {
}
void LocationBarViewMac::OnChanged() {
AnimatePageInfoIfPossible(false);
UpdateLocationIcon();
}
......@@ -487,30 +432,6 @@ void LocationBarViewMac::OnEditBookmarksEnabledChanged() {
OnChanged();
}
void LocationBarViewMac::UpdatePageInfoText() {
// Don't change the label if the bubble is in the process of animating
// out the old one.
if (page_info_decoration_->AnimatingOut())
return;
base::string16 label;
PageInfoVerboseType type = GetPageInfoVerboseType();
if (type == PageInfoVerboseType::kEVCert) {
label = GetToolbarModel()->GetSecureVerboseText();
} else if (type == PageInfoVerboseType::kExtension && GetWebContents()) {
label = extensions::ui_util::GetEnabledExtensionNameForUrl(
GetToolbarModel()->GetURL(), GetWebContents()->GetBrowserContext());
} else if (type == PageInfoVerboseType::kChrome) {
label = l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME);
} else if (type == PageInfoVerboseType::kSecurity &&
HasSecurityVerboseText()) {
if (is_width_available_for_security_verbose_)
label = GetToolbarModel()->GetSecureVerboseText();
}
page_info_decoration_->SetFullLabel(base::SysUTF16ToNSString(label));
}
bool LocationBarViewMac::RefreshContentSettingsDecorations() {
return false;
}
......@@ -525,50 +446,6 @@ bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) {
IsLocationBarDark());
}
void LocationBarViewMac::AnimatePageInfoIfPossible(bool tab_changed) {
using SecurityLevel = security_state::SecurityLevel;
SecurityLevel new_security_level = GetToolbarModel()->GetSecurityLevel(false);
bool is_new_security_level = security_level_ != new_security_level;
SecurityLevel old_security_level = security_level_;
security_level_ = new_security_level;
if (tab_changed)
page_info_decoration_->ResetAnimation();
// Animation is only applicable for the security verbose and if the icon
// isn't updated from a tab switch.
if (GetPageInfoVerboseType() != PageInfoVerboseType::kSecurity ||
!HasSecurityVerboseText() || tab_changed) {
page_info_decoration_->ShowWithoutAnimation();
return;
}
// Do not animate HTTP_SHOW_WARNING to DANGEROUS transitions because they look
// messy/confusing.
if (old_security_level == security_state::HTTP_SHOW_WARNING &&
security_level_ == security_state::DANGEROUS) {
page_info_decoration_->ShowWithoutAnimation();
return;
}
if (is_width_available_for_security_verbose_) {
if (!is_new_security_level && page_info_decoration_->HasAnimatedOut())
page_info_decoration_->AnimateIn(false);
else if (!CanAnimateSecurityLevel(new_security_level))
page_info_decoration_->ShowWithoutAnimation();
else if (is_new_security_level)
page_info_decoration_->AnimateIn();
} else {
page_info_decoration_->AnimateOut();
}
}
bool LocationBarViewMac::CanAnimateSecurityLevel(
security_state::SecurityLevel level) const {
return level == security_state::DANGEROUS ||
level == security_state::HTTP_SHOW_WARNING;
}
void LocationBarViewMac::UpdateAccessibilityView(
LocationBarDecoration* decoration) {
if (!decoration->IsVisible())
......@@ -617,7 +494,6 @@ std::vector<LocationBarDecoration*> LocationBarViewMac::GetDecorations() {
// TODO(ellyjones): page actions and keyword hints are not included right
// now. Keyword hints have no useful tooltip (issue 752592), and page actions
// are likewise.
decorations.push_back(page_info_decoration_.get());
decorations.push_back(zoom_decoration_.get());
return decorations;
}
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION_H_
#define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION_H_
#import <Cocoa/Cocoa.h>
#include "base/macros.h"
#include "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/animation/slide_animation.h"
// Draws the verbose state bubble, which contains the security icon and a label
// describing its security state. If an EV cert is available, the icon will be
// a lock and the label will contain the certificate's name. The
// |location_icon| is used to fulfill drag-related calls.
class LocationBarViewMac;
class LocationIconDecoration;
namespace {
class PageInfoBubbleDecorationTest;
}
namespace {
class LocationBarViewMacTest;
}
class PageInfoBubbleDecoration : public BubbleDecoration,
public gfx::AnimationDelegate {
public:
explicit PageInfoBubbleDecoration(LocationBarViewMac* owner);
~PageInfoBubbleDecoration() override;
// |GetWidthForSpace()| will set |full_label| as the label, if it
// fits, else it will set an elided version.
void SetFullLabel(NSString* full_label);
// Set the color of the label.
void SetLabelColor(SkColor color);
// Methods that animate in and out the chip. Virtual for testing.
virtual void AnimateIn(bool image_fade = true);
virtual void AnimateOut();
// Shows the chip without animation. Virtual for testing.
virtual void ShowWithoutAnimation();
// Returns true if the chip has fully animated in.
bool HasAnimatedIn() const;
// Returns true if the chip has fully animated out. Virtual for testing.
virtual bool HasAnimatedOut() const;
// Returns true if the chip is in the process of animating out. Virtual for
// testing.
virtual bool AnimatingOut() const;
// Resets the animation. Virtual for testing.
virtual void ResetAnimation();
// LocationBarDecoration:
CGFloat GetWidthForSpace(CGFloat width) override;
void DrawInFrame(NSRect frame, NSView* control_view) override;
bool IsDraggable() override;
NSPasteboard* GetDragPasteboard() override;
NSImage* GetDragImage() override;
NSRect GetDragImageFrame(NSRect frame) override;
bool OnMousePressed(NSRect frame, NSPoint location) override;
AcceptsPress AcceptsMousePress() override;
NSPoint GetBubblePointInFrame(NSRect frame) override;
NSString* GetToolTip() override;
NSString* GetAccessibilityLabel() override;
NSRect GetRealFocusRingBounds(NSRect apparent_frame) const override;
// BubbleDecoration:
NSColor* GetBackgroundBorderColor() override;
// gfx::AnimationDelegate:
void AnimationProgressed(const gfx::Animation* animation) override;
protected:
NSColor* GetDarkModeTextColor() override;
private:
friend class ::LocationBarViewMacTest;
friend class ::PageInfoBubbleDecorationTest;
// Returns the animation progress. If not in MD, the animation progress
// should always be 1.0.
CGFloat GetAnimationProgress() const;
// Helper method that calculates and returns the width of the label and icon
// within |width|.
CGFloat GetWidthForText(CGFloat width);
LocationIconDecoration* location_icon_; // weak, owned by location bar.
// The real label. BubbleDecoration's label may be elided.
base::scoped_nsobject<NSString> full_label_;
// The color of the label's text. The default color is kGoogleGreen700.
SkColor label_color_;
// True if the image should fade when the verbose animates in.
bool image_fade_;
// The animation of the decoration.
gfx::SlideAnimation animation_;
LocationBarViewMac* owner_; // weak
// Distance in points to inset the right edge of the focus ring by. This is
// used by |GetRealFocusRingBounds| to prevent the focus ring from including
// the divider bar. This is recomputed every time this object is drawn.
int focus_ring_right_inset_ = 0;
// Distance in points to inset the left edge of the focus ring by.
int focus_ring_left_inset_ = 0;
// Used to disable find bar animations when testing.
bool disable_animations_during_testing_;
// The frame of the drag-and-drop image.
NSRect drag_frame_;
DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleDecoration);
};
#endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION_H_
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Cocoa/Cocoa.h>
#import "chrome/browser/ui/cocoa/location_bar/page_info_bubble_decoration.h"
#import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class PageInfoBubbleDecorationTest : public CocoaTest {
public:
PageInfoBubbleDecorationTest() : decoration_(nullptr) {
decoration_.disable_animations_during_testing_ = true;
}
PageInfoBubbleDecoration decoration_;
};
// Test that the decoration gets smaller when there's not enough space
// to fit, within bounds.
TEST_F(PageInfoBubbleDecorationTest, MiddleElide) {
NSString* kLongString = @"A very long string with spaces";
const CGFloat kWide = 1000.0; // Wide enough to fit everything.
const CGFloat kNarrow = 10.0; // Too narrow for anything.
const CGFloat kMinimumWidth = 100.0; // Never should get this small.
const NSSize kImageSize = NSMakeSize(20.0, 20.0);
base::scoped_nsobject<NSImage> image(
[[NSImage alloc] initWithSize:kImageSize]);
decoration_.SetImage(image);
decoration_.SetFullLabel(kLongString);
// Lots of space, decoration not omitted.
EXPECT_NE(decoration_.GetWidthForSpace(kWide),
LocationBarDecoration::kOmittedWidth);
// If the available space is of the same magnitude as the required
// space, the decoration doesn't eat it all up.
const CGFloat long_width = decoration_.GetWidthForSpace(kWide);
EXPECT_NE(decoration_.GetWidthForSpace(long_width + 20.0),
LocationBarDecoration::kOmittedWidth);
EXPECT_LT(decoration_.GetWidthForSpace(long_width + 20.0), long_width);
// If there is very little space, the decoration is still relatively
// big.
EXPECT_NE(decoration_.GetWidthForSpace(kNarrow),
LocationBarDecoration::kOmittedWidth);
EXPECT_GT(decoration_.GetWidthForSpace(kNarrow), kMinimumWidth);
}
} // namespace
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/permission_bubble/chooser_bubble_ui.h"
#include <memory>
#include "chrome/browser/chooser_controller/chooser_controller.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/cocoa/browser_dialogs_views_mac.h"
#import "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h"
#include "chrome/browser/ui/permission_bubble/chooser_bubble_delegate.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
void ChooserBubbleUi::CreateAndShowCocoa(
views::BubbleDialogDelegateView* delegate) {
gfx::NativeWindow parent_window = browser_->window()->GetNativeWindow();
gfx::NativeView parent = platform_util::GetViewForWindow(parent_window);
DCHECK(parent);
// Set |parent_window_| because some valid anchors can become hidden.
delegate->set_parent_window(parent);
views::BubbleDialogDelegateView::CreateBubble(delegate)->Show();
KeepBubbleAnchored(delegate, GetPageInfoDecoration(parent_window));
}
......@@ -38,25 +38,6 @@ std::string UiModeToString(const ::testing::TestParamInfo<UiMode>& info) {
} // namespace
namespace test {
// Test API for LocationBarDecoration. This can be moved to its own file if
// another test needs it.
class LocationBarDecorationTestApi {
public:
explicit LocationBarDecorationTestApi(LocationBarDecoration* decoration)
: decoration_(decoration) {}
bool active() const { return decoration_->active_; }
private:
LocationBarDecoration* decoration_;
DISALLOW_COPY_AND_ASSIGN(LocationBarDecorationTestApi);
};
} // namespace test
// TODO(crbug.com/630357): Remove parameterized testing for this class.
class PermissionBubbleInteractiveUITest
: public InProcessBrowserTest,
......@@ -102,13 +83,9 @@ class PermissionBubbleInteractiveUITest
std::make_unique<test::PermissionRequestManagerTestApi>(browser());
EXPECT_TRUE(test_api_->manager());
decoration_test_api_ = std::make_unique<test::LocationBarDecorationTestApi>(
GetPageInfoDecoration(browser()->window()->GetNativeWindow()));
test_api_->AddSimpleRequest(CONTENT_SETTINGS_TYPE_GEOLOCATION);
EXPECT_TRUE([browser()->window()->GetNativeWindow() isKeyWindow]);
EXPECT_FALSE(decoration_test_api_->active());
// The PermissionRequestManager displays prompts asynchronously.
base::RunLoop().RunUntilIdle();
......@@ -119,17 +96,19 @@ class PermissionBubbleInteractiveUITest
protected:
std::unique_ptr<test::PermissionRequestManagerTestApi> test_api_;
std::unique_ptr<test::LocationBarDecorationTestApi> decoration_test_api_;
base::test::ScopedFeatureList scoped_feature_list_;
private:
// TDOO(thakis): Remove this, this should test views mode.
test::ScopedMacViewsBrowserMode cocoa_browser_mode_{false};
DISALLOW_COPY_AND_ASSIGN(PermissionBubbleInteractiveUITest);
};
// There is only one tab. Cmd+w will close it along with the browser window.
IN_PROC_BROWSER_TEST_P(PermissionBubbleInteractiveUITest, CmdWClosesWindow) {
// TDOO(thakis): Reenable this once this test tests views.
IN_PROC_BROWSER_TEST_P(PermissionBubbleInteractiveUITest,
DISABLED_CmdWClosesWindow) {
base::scoped_nsobject<NSWindow> browser_window(
browser()->window()->GetNativeWindow(), base::scoped_policy::RETAIN);
EXPECT_TRUE([browser_window isVisible]);
......@@ -154,7 +133,6 @@ IN_PROC_BROWSER_TEST_P(PermissionBubbleInteractiveUITest, DISABLED_SwitchTabs) {
EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
EXPECT_TRUE(test_api_->GetPromptWindow());
EXPECT_TRUE(decoration_test_api_->active());
// Add a blank tab in the foreground.
AddBlankTabAndShow(browser());
......@@ -169,7 +147,6 @@ IN_PROC_BROWSER_TEST_P(PermissionBubbleInteractiveUITest, DISABLED_SwitchTabs) {
// Prompt is hidden while its tab is not active.
EXPECT_FALSE(test_api_->GetPromptWindow());
EXPECT_FALSE(decoration_test_api_->active());
// Now a webcontents is active, it gets a first shot at processing the
// accelerator before sending it back unhandled to the browser via IPC. That's
......@@ -183,7 +160,6 @@ IN_PROC_BROWSER_TEST_P(PermissionBubbleInteractiveUITest, DISABLED_SwitchTabs) {
EnsureWindowActive(test_api_->GetPromptWindow(),
"switched to permission tab with arrow");
EXPECT_TRUE(test_api_->GetPromptWindow());
EXPECT_TRUE(decoration_test_api_->active());
// Ensure we can switch away with the bubble active.
SendAccelerator(ui::VKEY_RIGHT, false, true);
......@@ -192,7 +168,6 @@ IN_PROC_BROWSER_TEST_P(PermissionBubbleInteractiveUITest, DISABLED_SwitchTabs) {
[browser_window makeKeyAndOrderFront:nil];
EnsureWindowActive(browser_window, "switch away with arrow");
EXPECT_FALSE(test_api_->GetPromptWindow());
EXPECT_FALSE(decoration_test_api_->active());
// Also test switching tabs with curly braces. "VKEY_OEM_4" is
// LeftBracket/Brace on a US keyboard, which ui::MacKeyCodeForWindowsKeyCode
......@@ -204,14 +179,12 @@ IN_PROC_BROWSER_TEST_P(PermissionBubbleInteractiveUITest, DISABLED_SwitchTabs) {
EnsureWindowActive(test_api_->GetPromptWindow(),
"switch to permission tab with curly brace");
EXPECT_TRUE(test_api_->GetPromptWindow());
EXPECT_TRUE(decoration_test_api_->active());
SendAccelerator(ui::VKEY_OEM_4, true, false);
EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
[browser_window makeKeyAndOrderFront:nil];
EnsureWindowActive(browser_window, "switch away with curly brace");
EXPECT_FALSE(test_api_->GetPromptWindow());
EXPECT_FALSE(decoration_test_api_->active());
}
INSTANTIATE_TEST_CASE_P(,
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "build/buildflag.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/bubble_anchor_helper.h"
#include "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/browser/ui/views/permission_bubble/permission_prompt_impl.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "ui/base/ui_features.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
namespace {
views::BubbleDialogDelegateView* BubbleForWindow(gfx::NativeWindow window) {
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
DCHECK(widget);
return widget->widget_delegate()->AsBubbleDialogDelegate();
}
} // namespace
// static
std::unique_ptr<PermissionPrompt> PermissionPrompt::Create(
content::WebContents* web_contents,
Delegate* delegate) {
#if BUILDFLAG(MAC_VIEWS_BROWSER)
if (!views_mode_controller::IsViewsBrowserCocoa()) {
return base::WrapUnique(new PermissionPromptImpl(
chrome::FindBrowserWithWebContents(web_contents), delegate));
}
#endif
Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
auto prompt = std::make_unique<PermissionPromptImpl>(browser, delegate);
// Note the PermissionPromptImpl constructor always shows the bubble, which
// is necessary to call TrackBubbleState().
// Also note it's important to use BrowserWindow::GetNativeWindow() and not
// WebContents::GetTopLevelNativeWindow() below, since there's a brief
// period when attaching a dragged tab to a window that WebContents thinks
// it hasn't yet moved to the new window.
TrackBubbleState(BubbleForWindow(prompt->GetNativeWindow()),
GetPageInfoDecoration(browser->window()->GetNativeWindow()));
return prompt;
}
......@@ -10,7 +10,6 @@
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/views_mode_controller.h"
// This file contains the bubble_anchor_util implementation for a Views
// browser window (BrowserView).
......@@ -19,10 +18,6 @@ namespace bubble_anchor_util {
AnchorConfiguration GetPageInfoAnchorConfiguration(Browser* browser,
Anchor anchor) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
return {};
#endif
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
if (anchor == kLocationBar && browser_view->GetLocationBarView()->IsDrawn())
......@@ -39,10 +34,6 @@ AnchorConfiguration GetPageInfoAnchorConfiguration(Browser* browser,
}
gfx::Rect GetPageInfoAnchorRect(Browser* browser) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
return GetPageInfoAnchorRectCocoa(browser);
#endif
// GetPageInfoAnchorConfiguration()'s anchor_view should be preferred if
// available.
DCHECK_EQ(GetPageInfoAnchorConfiguration(browser).anchor_view, nullptr);
......
......@@ -20,10 +20,6 @@
#include "ui/views/controls/combobox/combobox_listener.h"
#include "ui/views/controls/link_listener.h"
namespace chrome {
class ContentSettingBubbleViewsBridge;
}
namespace views {
class ImageButton;
class RadioButton;
......@@ -81,9 +77,6 @@ class ContentSettingBubbleContents : public content::WebContentsObserver,
class Favicon;
class ListItemContainer;
// This allows ContentSettingBubbleViewsBridge to call SetAnchorRect().
friend class chrome::ContentSettingBubbleViewsBridge;
// Applies the colors appropriate for |theme| to the learn more button.
void StyleLearnMoreButton(const ui::NativeTheme* theme);
......
......@@ -391,18 +391,8 @@ void ExtensionInstalledBubbleUi::OnWidgetClosing(views::Widget* widget) {
bubble_reference_->CloseBubble(BUBBLE_CLOSE_FOCUS_LOST);
}
// Implemented here to create the platform specific instance of the BubbleUi.
#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
// Views (BrowserView) specific implementation.
bool ExtensionInstalledBubble::ShouldShow() {
#if BUILDFLAG(MAC_VIEWS_BROWSER)
// Cocoa browser windows can always show the bubble - no need to check for an
// animation.
// TODO(ellyjones): Is that actually true?
if (views_mode_controller::IsViewsBrowserCocoa())
return true;
#endif
if (anchor_position() == ANCHOR_ACTION) {
BrowserActionsContainer* container =
BrowserView::GetBrowserViewForBrowser(browser())
......@@ -415,11 +405,6 @@ bool ExtensionInstalledBubble::ShouldShow() {
gfx::Point ExtensionInstalledBubble::GetAnchorPoint(
gfx::NativeWindow window) const {
#if BUILDFLAG(MAC_VIEWS_BROWSER)
DCHECK(views_mode_controller::IsViewsBrowserCocoa());
return bubble_anchor_util::GetExtensionInstalledAnchorPointCocoa(window,
this);
#endif
NOTREACHED(); // There is always an anchor view.
return gfx::Point();
}
......@@ -427,5 +412,3 @@ gfx::Point ExtensionInstalledBubble::GetAnchorPoint(
std::unique_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() {
return base::WrapUnique(new ExtensionInstalledBubbleUi(this));
}
#endif
......@@ -28,12 +28,10 @@ using base::UserMetricsAction;
namespace importer {
#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
void ShowImportLockDialog(gfx::NativeWindow parent,
const base::Callback<void(bool)>& callback) {
ImportLockDialogView::Show(parent, callback);
}
#endif // !OS_MACOSX || MAC_VIEWS_BROWSER
} // namespace importer
......
......@@ -34,7 +34,6 @@
#include "chrome/browser/ui/views/hover_button.h"
#include "chrome/browser/ui/views/page_info/chosen_object_view.h"
#include "chrome/browser/ui/views/page_info/permission_selector_row.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "chrome/common/url_constants.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/security_state/core/security_state.h"
......@@ -911,20 +910,11 @@ void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label,
}
}
#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
void ShowPageInfoDialogImpl(Browser* browser,
content::WebContents* web_contents,
const GURL& virtual_url,
const security_state::SecurityInfo& security_info,
bubble_anchor_util::Anchor anchor) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa()) {
// Use the Cocoa code path for showing the Views page info dialog so that it
// anchors properly.
return chrome::ShowPageInfoBubbleViews(browser, web_contents, virtual_url,
security_info, anchor);
}
#endif
AnchorConfiguration configuration =
GetPageInfoAnchorConfiguration(browser, anchor);
gfx::Rect anchor_rect =
......@@ -938,4 +928,3 @@ void ShowPageInfoDialogImpl(Browser* browser,
bubble->SetArrow(configuration.bubble_arrow);
bubble->GetWidget()->Show();
}
#endif
......@@ -39,13 +39,8 @@ class ChooserBubbleUi : public BubbleUi, public views::WidgetObserver {
void OnWidgetClosing(views::Widget* widget) override;
private:
// Has separate implementations for Views-based and Cocoa-based browsers, to
// allow this bubble to be used in either.
void CreateAndShow(views::BubbleDialogDelegateView* delegate);
// Create a ChooserBubbleUi attached specifically to a Cocoa browser window.
void CreateAndShowCocoa(views::BubbleDialogDelegateView* delegate);
Browser* const browser_; // Weak.
// Weak. Owned by its parent view.
ChooserBubbleUiViewDelegate* chooser_bubble_ui_view_delegate_;
......
......@@ -12,7 +12,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/permission_bubble/chooser_bubble_delegate.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/widget/widget.h"
......@@ -26,10 +25,6 @@ std::unique_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
}
void ChooserBubbleUi::CreateAndShow(views::BubbleDialogDelegateView* delegate) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
return ChooserBubbleUi::CreateAndShowCocoa(delegate);
#endif
// Set |parent_window_| because some valid anchors can become hidden.
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(
browser_->window()->GetNativeWindow());
......
......@@ -4156,8 +4156,6 @@ test("unit_tests") {
"../browser/ui/cocoa/location_bar/autocomplete_text_field_unittest_helper.h",
"../browser/ui/cocoa/location_bar/autocomplete_text_field_unittest_helper.mm",
"../browser/ui/cocoa/location_bar/image_decoration_unittest.mm",
"../browser/ui/cocoa/location_bar/location_bar_view_mac_unittest.mm",
"../browser/ui/cocoa/location_bar/page_info_bubble_decoration_unittest.mm",
"../browser/ui/cocoa/location_bar/zoom_decoration_unittest.mm",
"../browser/ui/cocoa/main_menu_builder_unittest.mm",
"../browser/ui/cocoa/md_hover_button_unittest.mm",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment