Commit e0eec373 authored by tapted's avatar tapted Committed by Commit bot

Mac (cleanup): Remove WebDialogs.

Nothing uses these on Mac.

They're used a lot on ChromeOS. On Windows, it shows a default browser
selection dialog. On Linux it shows the certificate viewer. On Mac I
think it was once used for a webui task manager.

BUG=None

Review URL: https://codereview.chromium.org/1640043002

Cr-Commit-Position: refs/heads/master@{#371971}
parent 17257534
......@@ -47,6 +47,11 @@ class WebDialogDelegate;
namespace chrome {
// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
void ShowTaskManager(Browser* browser);
void HideTaskManager();
#if !defined(OS_MACOSX)
// Creates and shows an HTML dialog with the given delegate and context.
// The window is automatically destroyed when it is closed.
// Returns the created window.
......@@ -57,11 +62,6 @@ gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
content::BrowserContext* context,
ui::WebDialogDelegate* delegate);
// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
void ShowTaskManager(Browser* browser);
void HideTaskManager();
#if !defined(OS_MACOSX)
// Shows the create web app shortcut dialog box.
void ShowCreateWebAppShortcutsDialog(gfx::NativeWindow parent_window,
content::WebContents* web_contents);
......
......@@ -46,7 +46,6 @@
#include "chrome/browser/ui/cocoa/status_bubble_mac.h"
#include "chrome/browser/ui/cocoa/task_manager_mac.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#import "chrome/browser/ui/cocoa/web_dialog_window_controller.h"
#import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/search/search_model.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_WEB_DIALOG_WINDOW_CONTROLLER_H_
#define CHROME_BROWSER_UI_COCOA_WEB_DIALOG_WINDOW_CONTROLLER_H_
#import <Cocoa/Cocoa.h>
#include "base/memory/scoped_ptr.h"
#include "ui/web_dialogs/web_dialog_ui.h"
class WebDialogWindowDelegateBridge;
namespace content {
class BrowserContext;
class WebContents;
}
// This controller manages a dialog box with properties and HTML content taken
// from a WebDialogDelegate object.
@interface WebDialogWindowController : NSWindowController<NSWindowDelegate> {
@private
// Order here is important, as webContents_ may send messages to
// delegate_ when it gets destroyed.
scoped_ptr<WebDialogWindowDelegateBridge> delegate_;
scoped_ptr<content::WebContents> webContents_;
}
// Creates and shows an WebDialogWindowController with the given
// delegate and profile. The window is automatically destroyed when it, or its
// profile, is closed. Returns the created window.
//
// Make sure to use the returned window only when you know it is safe
// to do so, i.e. before OnDialogClosed() is called on the delegate.
+ (NSWindow*)showWebDialog:(ui::WebDialogDelegate*)delegate
context:(content::BrowserContext*)context;
@end
@interface WebDialogWindowController (TestingAPI)
// This is the designated initializer. However, this is exposed only
// for testing; use -showWebDialog:context: instead.
- (id)initWithDelegate:(ui::WebDialogDelegate*)delegate
context:(content::BrowserContext*)context;
// Loads the HTML content from the delegate; this is not a lightweight
// process which is why it is not part of the constructor. Must be
// called before -showWebDialog:context:.
- (void)loadDialogContents;
@end
#endif // CHROME_BROWSER_UI_COCOA_WEB_DIALOG_WINDOW_CONTROLLER_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.
#import "chrome/browser/ui/cocoa/web_dialog_window_controller.h"
#include <string>
#include <vector>
#import <Cocoa/Cocoa.h>
#import "base/mac/scoped_nsautorelease_pool.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/size.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
#include "url/gurl.h"
using content::WebContents;
using content::WebUIMessageHandler;
using ui::WebDialogDelegate;
namespace {
class MockDelegate : public WebDialogDelegate {
public:
MOCK_CONST_METHOD0(GetDialogModalType, ui::ModalType());
MOCK_CONST_METHOD0(GetDialogTitle, base::string16());
MOCK_CONST_METHOD0(GetDialogContentURL, GURL());
MOCK_CONST_METHOD1(GetWebUIMessageHandlers,
void(std::vector<WebUIMessageHandler*>*));
MOCK_CONST_METHOD1(GetDialogSize, void(gfx::Size*));
MOCK_CONST_METHOD0(GetDialogArgs, std::string());
MOCK_METHOD1(OnDialogClosed, void(const std::string& json_retval));
MOCK_METHOD2(OnCloseContents,
void(WebContents* source, bool* out_close_dialog));
MOCK_CONST_METHOD0(ShouldShowDialogTitle, bool());
};
class WebDialogWindowControllerTest : public BrowserWithTestWindowTest {
public:
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
CocoaTest::BootstrapCocoa();
title_ = base::ASCIIToUTF16("Mock Title");
size_ = gfx::Size(50, 100);
gurl_ = GURL("");
}
protected:
base::string16 title_;
gfx::Size size_;
GURL gurl_;
// Order here is important.
MockDelegate delegate_;
};
using ::testing::_;
using ::testing::Return;
using ::testing::SetArgumentPointee;
// TODO(akalin): We can't test much more than the below without a real browser.
// In particular, GetWebUIMessageHandlers() and GetDialogArgs() are never
// called. This should be fixed.
TEST_F(WebDialogWindowControllerTest, showDialog) {
// We want to make sure web_dialog_window_controller below gets
// destroyed before delegate_, so we specify our own autorelease pool.
//
// TODO(dmaclach): Remove this once
// http://code.google.com/p/chromium/issues/detail?id=26133 is fixed.
base::mac::ScopedNSAutoreleasePool release_pool;
EXPECT_CALL(delegate_, GetDialogTitle())
.WillOnce(Return(title_));
EXPECT_CALL(delegate_, GetDialogSize(_))
.WillOnce(SetArgumentPointee<0>(size_));
EXPECT_CALL(delegate_, GetDialogContentURL())
.WillOnce(Return(gurl_));
EXPECT_CALL(delegate_, OnDialogClosed(_))
.Times(1);
WebDialogWindowController* web_dialog_window_controller =
[[WebDialogWindowController alloc] initWithDelegate:&delegate_
context:profile()];
[web_dialog_window_controller loadDialogContents];
[web_dialog_window_controller showWindow:nil];
[web_dialog_window_controller close];
}
} // namespace
......@@ -1283,8 +1283,6 @@
'browser/ui/cocoa/view_resizer.h',
'browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.h',
'browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.mm',
'browser/ui/cocoa/web_dialog_window_controller.h',
'browser/ui/cocoa/web_dialog_window_controller.mm',
'browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.h',
'browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm',
'browser/ui/cocoa/website_settings/permission_bubble_cocoa.h',
......
......@@ -1339,7 +1339,6 @@
'browser/ui/cocoa/vertical_gradient_view_unittest.mm',
'browser/ui/cocoa/view_resizer_pong.h',
'browser/ui/cocoa/view_resizer_pong.mm',
'browser/ui/cocoa/web_dialog_window_controller_unittest.mm',
'browser/ui/cocoa/website_settings/permission_bubble_controller_unittest.mm',
'browser/ui/cocoa/website_settings/permission_selector_button_unittest.mm',
'browser/ui/cocoa/website_settings/website_settings_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