Commit 98d260d4 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac: Remove unused MediaGalleriesDialogCocoa.

Bug: 832676
Change-Id: If8b70eefc57a17b734c33a953b3c06a1a0dc2bd2
Reviewed-on: https://chromium-review.googlesource.com/1240165
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593563}
parent b63fffc7
...@@ -35,12 +35,6 @@ class MediaGalleriesDialog { ...@@ -35,12 +35,6 @@ class MediaGalleriesDialog {
// Constructs a platform-specific dialog owned and controlled by |controller|. // Constructs a platform-specific dialog owned and controlled by |controller|.
static MediaGalleriesDialog* Create( static MediaGalleriesDialog* Create(
MediaGalleriesDialogController* controller); MediaGalleriesDialogController* controller);
#if defined(OS_MACOSX)
// Temporary shim for Polychrome. See bottom of first comment in
// https://crbug.com/80495 for details.
static MediaGalleriesDialog* CreateCocoa(
MediaGalleriesDialogController* controller);
#endif
private: private:
friend class TestMediaGalleriesAddScanResultsFunction; friend class TestMediaGalleriesAddScanResultsFunction;
......
...@@ -149,10 +149,6 @@ jumbo_split_static_library("ui") { ...@@ -149,10 +149,6 @@ jumbo_split_static_library("ui") {
"cocoa/extensions/extension_keybinding_registry_cocoa.mm", "cocoa/extensions/extension_keybinding_registry_cocoa.mm",
"cocoa/extensions/extension_popup_views_mac.h", "cocoa/extensions/extension_popup_views_mac.h",
"cocoa/extensions/extension_popup_views_mac.mm", "cocoa/extensions/extension_popup_views_mac.mm",
"cocoa/extensions/media_galleries_dialog_cocoa.h",
"cocoa/extensions/media_galleries_dialog_cocoa.mm",
"cocoa/extensions/media_gallery_list_entry_view.h",
"cocoa/extensions/media_gallery_list_entry_view.mm",
"cocoa/extensions/toolbar_actions_bar_bubble_views_presenter.h", "cocoa/extensions/toolbar_actions_bar_bubble_views_presenter.h",
"cocoa/extensions/toolbar_actions_bar_bubble_views_presenter.mm", "cocoa/extensions/toolbar_actions_bar_bubble_views_presenter.mm",
"cocoa/fast_resize_view.h", "cocoa/fast_resize_view.h",
......
// Copyright (c) 2012 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_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_
#define CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_
#import <Cocoa/Cocoa.h>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "chrome/browser/media_galleries/media_galleries_dialog_controller.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
#import "chrome/browser/ui/cocoa/extensions/media_gallery_list_entry_view.h"
@class ConstrainedWindowAlert;
@class MediaGalleriesCocoaController;
@class NSString;
class MediaGalleriesDialogBrowserTest;
class MediaGalleriesDialogTest;
namespace ui {
class MenuModel;
}
// This class displays an alert that can be used to manage lists of media
// galleries.
class MediaGalleriesDialogCocoa : public ConstrainedWindowMacDelegate,
public MediaGalleriesDialog,
public MediaGalleryListEntryController {
public:
MediaGalleriesDialogCocoa(
MediaGalleriesDialogController* controller,
MediaGalleriesCocoaController* delegate);
~MediaGalleriesDialogCocoa() override;
// Called when the user clicks the accept button.
void OnAcceptClicked();
// Called when the user clicks the cancel button.
void OnCancelClicked();
// Called when the user clicks the auxiliary button.
void OnAuxiliaryButtonClicked();
// MediaGalleriesDialog implementation:
void UpdateGalleries() override;
// ConstrainedWindowMacDelegate implementation.
void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override;
// MediaGalleryListEntryController implementation.
void OnCheckboxToggled(MediaGalleryPrefId pref_id, bool checked) override;
ui::MenuModel* GetContextMenu(MediaGalleryPrefId pref_id) override;
private:
FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogBrowserTest, Close);
FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes);
FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes);
FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds);
FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes);
// MediaGalleriesDialog implementation:
void AcceptDialogForTesting() override;
void InitDialogControls();
CGFloat CreateCheckboxes(
CGFloat y_pos,
const MediaGalleriesDialogController::Entries& entries);
CGFloat CreateCheckboxSeparator(CGFloat y_pos, NSString* header);
MediaGalleriesDialogController* controller_; // weak
std::unique_ptr<ConstrainedWindowMac> window_;
// The alert that the dialog is being displayed as.
base::scoped_nsobject<ConstrainedWindowAlert> alert_;
// True if the user has pressed accept.
bool accepted_;
// Container view for checkboxes.
base::scoped_nsobject<NSView> checkbox_container_;
// Container view for the main dialog contents.
base::scoped_nsobject<NSBox> main_container_;
// An Objective-C class to route callbacks from Cocoa code.
base::scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller_;
DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa);
};
#endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_
// Copyright (c) 2012 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 "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h"
#include "chrome/browser/media_galleries/media_galleries_dialog_controller_mock.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/views/scoped_macviews_browser_mode.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::NiceMock;
using ::testing::Return;
using ::testing::ReturnRef;
class MediaGalleriesDialogBrowserTest : public InProcessBrowserTest {
private:
test::ScopedMacViewsBrowserMode cocoa_browser_mode_{false};
};
// Verify that programatically closing the constrained window correctly closes
// the sheet.
IN_PROC_BROWSER_TEST_F(MediaGalleriesDialogBrowserTest, Close) {
NiceMock<MediaGalleriesDialogControllerMock> controller;
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_CALL(controller, WebContents()).
WillRepeatedly(Return(web_contents));
std::vector<base::string16> headers;
headers.push_back(base::string16()); // The first section has no header.
headers.push_back(base::ASCIIToUTF16("header2"));
ON_CALL(controller, GetSectionHeaders()).
WillByDefault(Return(headers));
EXPECT_CALL(controller, GetAuxiliaryButtonText()).
WillRepeatedly(Return(base::ASCIIToUTF16("button")));
EXPECT_CALL(controller, GetSectionEntries(_)).
Times(AnyNumber());
std::unique_ptr<MediaGalleriesDialogCocoa> dialog(
static_cast<MediaGalleriesDialogCocoa*>(
MediaGalleriesDialog::Create(&controller)));
base::scoped_nsobject<NSWindow> window([[dialog->alert_ window] retain]);
EXPECT_TRUE([window isVisible]);
web_modal::WebContentsModalDialogManager* manager =
web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
web_modal::WebContentsModalDialogManager::TestApi(manager).CloseAllDialogs();
EXPECT_FALSE([window isVisible]);
}
// Copyright (c) 2012 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 "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/media_galleries/media_galleries_dialog_controller_mock.h"
#include "chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h"
#include "components/storage_monitor/storage_info.h"
#include "extensions/common/extension.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::Mock;
using ::testing::NiceMock;
using ::testing::Return;
using ::testing::ReturnPointee;
using ::testing::ReturnRef;
@interface MediaGalleryListEntry (testing)
- (NSInteger)state;
- (void)performClick:(id)sender;
@end
@implementation MediaGalleryListEntry (testing)
- (NSInteger)state {
return [checkbox_ state];
}
- (void)performClick:(id)sender {
[checkbox_ performClick:sender];
}
@end
MediaGalleryPrefInfo MakePrefInfoForTesting(MediaGalleryPrefId pref_id) {
MediaGalleryPrefInfo gallery;
gallery.pref_id = pref_id;
gallery.device_id = storage_monitor::StorageInfo::MakeDeviceId(
storage_monitor::StorageInfo::FIXED_MASS_STORAGE,
base::Int64ToString(pref_id));
gallery.display_name = base::ASCIIToUTF16("name");
return gallery;
}
class MediaGalleriesDialogTest : public testing::Test {
public:
MediaGalleriesDialogTest() {}
~MediaGalleriesDialogTest() override {}
void SetUp() override {
std::vector<base::string16> headers;
headers.push_back(base::string16());
headers.push_back(base::ASCIIToUTF16("header2"));
ON_CALL(controller_, GetSectionHeaders()).
WillByDefault(Return(headers));
EXPECT_CALL(controller_, GetSectionEntries(_)).
Times(AnyNumber());
}
void TearDown() override {
Mock::VerifyAndClearExpectations(&controller_);
dialog_.reset();
}
NiceMock<MediaGalleriesDialogControllerMock>* controller() {
return &controller_;
}
MediaGalleriesDialogCocoa* GetOrCreateDialog() {
if (!dialog_.get()) {
dialog_.reset(static_cast<MediaGalleriesDialogCocoa*>(
MediaGalleriesDialog::Create(&controller_)));
}
return dialog_.get();
}
private:
NiceMock<MediaGalleriesDialogControllerMock> controller_;
std::unique_ptr<MediaGalleriesDialogCocoa> dialog_;
DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogTest);
};
// Tests that checkboxes are initialized according to the contents of
// permissions().
TEST_F(MediaGalleriesDialogTest, InitializeCheckboxes) {
MediaGalleriesDialogController::Entries attached_permissions;
attached_permissions.push_back(
MediaGalleriesDialogController::Entry(MakePrefInfoForTesting(1), true));
attached_permissions.push_back(
MediaGalleriesDialogController::Entry(MakePrefInfoForTesting(2), false));
EXPECT_CALL(*controller(), GetSectionEntries(0)).
WillRepeatedly(Return(attached_permissions));
// Initializing checkboxes should not cause them to be toggled.
EXPECT_CALL(*controller(), DidToggleEntry(_, _)).
Times(0);
EXPECT_EQ(2U, [[GetOrCreateDialog()->checkbox_container_ subviews] count]);
NSButton* checkbox1 =
[[GetOrCreateDialog()->checkbox_container_ subviews] objectAtIndex:0];
EXPECT_EQ([checkbox1 state], NSOnState);
NSButton* checkbox2 =
[[GetOrCreateDialog()->checkbox_container_ subviews] objectAtIndex:1];
EXPECT_EQ([checkbox2 state], NSOffState);
}
// Tests that toggling checkboxes updates the controller.
TEST_F(MediaGalleriesDialogTest, ToggleCheckboxes) {
MediaGalleriesDialogController::Entries attached_permissions;
attached_permissions.push_back(
MediaGalleriesDialogController::Entry(MakePrefInfoForTesting(1), true));
EXPECT_CALL(*controller(), GetSectionEntries(0)).
WillRepeatedly(Return(attached_permissions));
EXPECT_EQ(1U, [[GetOrCreateDialog()->checkbox_container_ subviews] count]);
NSButton* checkbox =
[[GetOrCreateDialog()->checkbox_container_ subviews] objectAtIndex:0];
EXPECT_EQ([checkbox state], NSOnState);
EXPECT_CALL(*controller(), DidToggleEntry(1, false));
[checkbox performClick:nil];
EXPECT_EQ([checkbox state], NSOffState);
EXPECT_CALL(*controller(), DidToggleEntry(1, true));
[checkbox performClick:nil];
EXPECT_EQ([checkbox state], NSOnState);
}
// Tests that UpdateGalleries will add a new checkbox, but only if it refers to
// a gallery that the dialog hasn't seen before.
TEST_F(MediaGalleriesDialogTest, UpdateAdds) {
MediaGalleriesDialogController::Entries attached_permissions;
EXPECT_CALL(*controller(), GetSectionEntries(0)).
WillRepeatedly(ReturnPointee(&attached_permissions));
EXPECT_EQ(0U, [[GetOrCreateDialog()->checkbox_container_ subviews] count]);
CGFloat old_container_height =
NSHeight([GetOrCreateDialog()->checkbox_container_ frame]);
attached_permissions.push_back(
MediaGalleriesDialogController::Entry(MakePrefInfoForTesting(1), true));
GetOrCreateDialog()->UpdateGalleries();
EXPECT_EQ(1U, [[GetOrCreateDialog()->checkbox_container_ subviews] count]);
// The checkbox container should be taller.
CGFloat new_container_height =
NSHeight([GetOrCreateDialog()->checkbox_container_ frame]);
EXPECT_GT(new_container_height, old_container_height);
old_container_height = new_container_height;
attached_permissions.push_back(
MediaGalleriesDialogController::Entry(MakePrefInfoForTesting(2), true));
GetOrCreateDialog()->UpdateGalleries();
EXPECT_EQ(2U, [[GetOrCreateDialog()->checkbox_container_ subviews] count]);
// The checkbox container should be taller.
new_container_height =
NSHeight([GetOrCreateDialog()->checkbox_container_ frame]);
EXPECT_GT(new_container_height, old_container_height);
old_container_height = new_container_height;
attached_permissions[1].selected = false;
GetOrCreateDialog()->UpdateGalleries();
EXPECT_EQ(2U, [[GetOrCreateDialog()->checkbox_container_ subviews] count]);
// The checkbox container height should not have changed.
new_container_height =
NSHeight([GetOrCreateDialog()->checkbox_container_ frame]);
EXPECT_EQ(new_container_height, old_container_height);
}
TEST_F(MediaGalleriesDialogTest, ForgetDeletes) {
MediaGalleriesDialogController::Entries attached_permissions;
EXPECT_CALL(*controller(), GetSectionEntries(0)).
WillRepeatedly(ReturnPointee(&attached_permissions));
GetOrCreateDialog();
// Add a couple of galleries.
attached_permissions.push_back(
MediaGalleriesDialogController::Entry(MakePrefInfoForTesting(1), true));
GetOrCreateDialog()->UpdateGalleries();
attached_permissions.push_back(
MediaGalleriesDialogController::Entry(MakePrefInfoForTesting(2), true));
GetOrCreateDialog()->UpdateGalleries();
EXPECT_EQ(2U, [[GetOrCreateDialog()->checkbox_container_ subviews] count]);
CGFloat old_container_height =
NSHeight([GetOrCreateDialog()->checkbox_container_ frame]);
// Remove a gallery.
attached_permissions.erase(attached_permissions.begin());
GetOrCreateDialog()->UpdateGalleries();
EXPECT_EQ(1U, [[GetOrCreateDialog()->checkbox_container_ subviews] count]);
// The checkbox container should be shorter.
CGFloat new_container_height =
NSHeight([GetOrCreateDialog()->checkbox_container_ frame]);
EXPECT_LT(new_container_height, old_container_height);
}
// Copyright 2014 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_EXTENSIONS_MEDIA_GALLERY_LIST_ENTRY_VIEW_H_
#define CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERY_LIST_ENTRY_VIEW_H_
#import <Cocoa/Cocoa.h>
#import "base/mac/scoped_nsobject.h"
#include "chrome/browser/media_galleries/media_galleries_preferences.h"
#import "ui/base/models/menu_model.h"
@class MediaGalleryButton;
class MediaGalleryListEntryController {
public:
virtual void OnCheckboxToggled(MediaGalleryPrefId pref_id, bool checked) {}
virtual void OnFolderViewerClicked(MediaGalleryPrefId pref_id) {}
virtual ui::MenuModel* GetContextMenu(MediaGalleryPrefId pref_id);
protected:
virtual ~MediaGalleryListEntryController() {}
};
@interface MediaGalleryListEntry : NSView {
@private
MediaGalleryListEntryController* controller_; // |controller_| owns |this|.
MediaGalleryPrefId prefId_;
base::scoped_nsobject<MediaGalleryButton> checkbox_;
base::scoped_nsobject<NSTextField> details_;
}
// Does size to fit if frameRect is empty.
- (id)initWithFrame:(NSRect)frameRect
controller:(MediaGalleryListEntryController*)controller_
prefInfo:(const MediaGalleryPrefInfo&)prefInfo;
- (void)setState:(bool)selected;
@end
#endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERY_LIST_ENTRY_VIEW_H_
// Copyright 2014 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 "chrome/browser/ui/cocoa/extensions/media_gallery_list_entry_view.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/ui/cocoa/chrome_style.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_utils.h"
#import "ui/base/cocoa/menu_controller.h"
#include "ui/base/resource/resource_bundle.h"
const CGFloat kGalleryEntryCheckboxMargin = 10;
ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
MediaGalleryPrefId pref_id) {
return NULL;
}
@interface MediaGalleryListEntry ()
- (void)onCheckboxToggled:(MediaGalleryButton*)sender;
- (void)onFolderViewerClicked:(id)sender;
- (ui::MenuModel*)getContextMenu;
- (void)layoutSubViews;
@end
@interface MediaGalleryButton : NSButton {
@private
MediaGalleryListEntry* controller_; // |controller_| owns |self|.
base::scoped_nsobject<MenuControllerCocoa> menuController_;
}
- (id)initWithFrame:(NSRect)frameRect
controller:(MediaGalleryListEntry*)controller;
- (NSMenu*)menuForEvent:(NSEvent*)theEvent;
@end
@implementation MediaGalleryButton
- (id)initWithFrame:(NSRect)frameRect
controller:(MediaGalleryListEntry*)controller {
if ((self = [super initWithFrame:frameRect])) {
controller_ = controller;
}
return self;
}
- (NSMenu*)menuForEvent:(NSEvent*)theEvent {
menuController_.reset([[MenuControllerCocoa alloc]
initWithModel:[controller_ getContextMenu]
useWithPopUpButtonCell:NO]);
return [menuController_ menu];
}
@end
@implementation MediaGalleryListEntry
- (id)initWithFrame:(NSRect)frameRect
controller:(MediaGalleryListEntryController*)controller
prefInfo:(const MediaGalleryPrefInfo&)prefInfo {
if ((self = [super initWithFrame:frameRect])) {
controller_ = controller;
prefId_ = prefInfo.pref_id;
NSString* nsTooltip =
base::SysUTF16ToNSString(prefInfo.GetGalleryTooltip());
// Set a auto resize mask so that -resizeWithOldSuperviewSize: is called.
// It is overridden so the particular mask doesn't matter.
[self setAutoresizingMask:NSViewWidthSizable];
checkbox_.reset(
[[MediaGalleryButton alloc] initWithFrame:NSZeroRect
controller:self]);
[[checkbox_ cell] setLineBreakMode:NSLineBreakByTruncatingMiddle];
[checkbox_ setButtonType:NSSwitchButton];
[checkbox_ setTarget:self];
[checkbox_ setAction:@selector(onCheckboxToggled:)];
[checkbox_ setTitle:
base::SysUTF16ToNSString(prefInfo.GetGalleryDisplayName())];
[checkbox_ setToolTip:nsTooltip];
[self addSubview:checkbox_];
// Additional details text.
base::string16 subscript = prefInfo.GetGalleryAdditionalDetails();
if (!subscript.empty()) {
details_.reset([[NSTextField alloc] initWithFrame:NSZeroRect]);
[[details_ cell] setLineBreakMode:NSLineBreakByTruncatingHead];
[details_ setEditable:NO];
[details_ setSelectable:NO];
[details_ setBezeled:NO];
[details_ setAttributedStringValue:
constrained_window::GetAttributedLabelString(
base::SysUTF16ToNSString(subscript),
chrome_style::kTextFontStyle,
NSNaturalTextAlignment,
NSLineBreakByClipping
)];
[details_ setTextColor:[NSColor disabledControlTextColor]];
[self addSubview:details_];
}
[self layoutSubViews];
}
return self;
}
- (void)setFrameSize:(NSSize)frameSize {
[super setFrameSize:frameSize];
[self layoutSubViews];
}
- (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize {
NSRect frame = [self frame];
frame.size.width = NSWidth([[self superview] frame]);
[self setFrameSize:frame.size];
}
- (void)setState:(bool)selected {
[checkbox_ setState:selected ? NSOnState : NSOffState];
}
- (void)onCheckboxToggled:(MediaGalleryButton*)sender {
controller_->OnCheckboxToggled(prefId_, [sender state] == NSOnState);
}
- (void)onFolderViewerClicked:(id)sender {
controller_->OnFolderViewerClicked(prefId_);
}
- (ui::MenuModel*)getContextMenu {
return controller_->GetContextMenu(prefId_);
}
- (void)layoutSubViews {
NSRect bounds = [self bounds];
// If we have an empty frame, we should auto size, so start with really big
// bounds and then set it to the real size of the contents later.
if (NSIsEmptyRect([self frame]))
bounds.size = NSMakeSize(10000, 10000);
[checkbox_ sizeToFit];
[details_ sizeToFit];
// Auto size everything and lay it out horizontally.
CGFloat xPos = kGalleryEntryCheckboxMargin;
for (NSView* view in [self subviews]) {
NSRect viewFrame = [view frame];
viewFrame.origin.x = xPos;
viewFrame.size.height = std::min(NSHeight(bounds), NSHeight(viewFrame));
[view setFrame:viewFrame];
xPos = NSMaxX([view frame]) + kGalleryEntryCheckboxMargin;
}
// Size the views. If all the elements don't naturally fit, the checkbox
// should get squished and will elide in the middle. However, it shouldn't
// squish too much so it gets at least half of the max width and the details
// text should elide as well in that case.
if (xPos > NSWidth(bounds)) {
CGFloat maxRHSContent = NSWidth(bounds) / 2 - kGalleryEntryCheckboxMargin;
NSRect detailsFrame = [details_ frame];
NSRect checkboxFrame = [checkbox_ frame];
if (NSMaxX(detailsFrame) - NSMaxX(checkboxFrame) > maxRHSContent) {
detailsFrame.size.width = std::max(
maxRHSContent - (NSMinX(detailsFrame) - NSMaxX(checkboxFrame)),
NSWidth(bounds) - kGalleryEntryCheckboxMargin - NSMinX(detailsFrame));
[details_ setFrameSize:detailsFrame.size];
xPos = NSMaxX(detailsFrame) + kGalleryEntryCheckboxMargin;
}
CGFloat overflow = xPos - NSWidth(bounds);
if (overflow > 0) {
checkboxFrame.size.width -= overflow;
[checkbox_ setFrameSize:checkboxFrame.size];
if (details_.get()) {
detailsFrame.origin.x -= overflow;
[details_ setFrameOrigin:detailsFrame.origin];
}
}
}
if (NSIsEmptyRect([self frame])) {
NSRect frame = NSMakeRect(0, 0, 1, 1);
for (NSView* view in [self subviews]) {
frame = NSUnionRect(frame, [view frame]);
}
frame.size.width += kGalleryEntryCheckboxMargin;
[super setFrameSize:frame.size];
}
}
@end
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h" #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h" #include "chrome/grit/locale_settings.h"
#include "components/constrained_window/constrained_window_views.h" #include "components/constrained_window/constrained_window_views.h"
...@@ -333,9 +332,5 @@ void MediaGalleriesDialogViews::OnMenuClosed() { ...@@ -333,9 +332,5 @@ void MediaGalleriesDialogViews::OnMenuClosed() {
// static // static
MediaGalleriesDialog* MediaGalleriesDialog::Create( MediaGalleriesDialog* MediaGalleriesDialog::Create(
MediaGalleriesDialogController* controller) { MediaGalleriesDialogController* controller) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
return MediaGalleriesDialog::CreateCocoa(controller);
#endif
return new MediaGalleriesDialogViews(controller); return new MediaGalleriesDialogViews(controller);
} }
...@@ -1966,7 +1966,6 @@ test("browser_tests") { ...@@ -1966,7 +1966,6 @@ test("browser_tests") {
"../browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm", "../browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm",
"../browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm", "../browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm",
"../browser/ui/cocoa/dev_tools_controller_browsertest.mm", "../browser/ui/cocoa/dev_tools_controller_browsertest.mm",
"../browser/ui/cocoa/extensions/media_galleries_dialog_cocoa_browsertest.mm",
"../browser/ui/cocoa/location_bar/zoom_decoration_browsertest.mm", "../browser/ui/cocoa/location_bar/zoom_decoration_browsertest.mm",
"../browser/ui/cocoa/omnibox/omnibox_view_mac_browsertest.mm", "../browser/ui/cocoa/omnibox/omnibox_view_mac_browsertest.mm",
"../browser/ui/cocoa/permission_bubble/permission_bubble_views_cocoa_browsertest.mm", "../browser/ui/cocoa/permission_bubble/permission_bubble_views_cocoa_browsertest.mm",
...@@ -4142,7 +4141,6 @@ test("unit_tests") { ...@@ -4142,7 +4141,6 @@ test("unit_tests") {
"../browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm", "../browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm",
"../browser/ui/cocoa/draggable_button_unittest.mm", "../browser/ui/cocoa/draggable_button_unittest.mm",
"../browser/ui/cocoa/extensions/browser_actions_container_view_unittest.mm", "../browser/ui/cocoa/extensions/browser_actions_container_view_unittest.mm",
"../browser/ui/cocoa/extensions/media_galleries_dialog_cocoa_unittest.mm",
"../browser/ui/cocoa/find_pasteboard_unittest.mm", "../browser/ui/cocoa/find_pasteboard_unittest.mm",
"../browser/ui/cocoa/first_run_dialog_controller_unittest.mm", "../browser/ui/cocoa/first_run_dialog_controller_unittest.mm",
"../browser/ui/cocoa/floating_bar_backing_view_unittest.mm", "../browser/ui/cocoa/floating_bar_backing_view_unittest.mm",
...@@ -4220,7 +4218,6 @@ test("unit_tests") { ...@@ -4220,7 +4218,6 @@ test("unit_tests") {
if (mac_views_browser) { if (mac_views_browser) {
sources -= [ sources -= [
"../browser/ui/cocoa/extensions/media_galleries_dialog_cocoa_unittest.mm",
"../browser/ui/cocoa/page_info/page_info_bubble_controller_unittest.mm", "../browser/ui/cocoa/page_info/page_info_bubble_controller_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