Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / web_dialogs / test / test_web_dialog_delegate.cc
blob41b07bc6a7f30293b2538dfaff91734ea5cce51d
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/web_dialogs/test/test_web_dialog_delegate.h"
7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h"
10 using content::WebContents;
11 using content::WebUIMessageHandler;
13 namespace ui {
14 namespace test {
16 TestWebDialogDelegate::TestWebDialogDelegate(const GURL& url)
17 : url_(url), size_(400, 400), did_delete_(nullptr) {
20 TestWebDialogDelegate::~TestWebDialogDelegate() {
21 if (did_delete_) {
22 CHECK(!*did_delete_);
23 *did_delete_ = true;
27 void TestWebDialogDelegate::SetDeleteOnClosedAndObserve(
28 bool* destroy_observer) {
29 CHECK(destroy_observer);
30 did_delete_ = destroy_observer;
33 ModalType TestWebDialogDelegate::GetDialogModalType() const {
34 return MODAL_TYPE_WINDOW;
37 base::string16 TestWebDialogDelegate::GetDialogTitle() const {
38 return base::UTF8ToUTF16("Test");
41 GURL TestWebDialogDelegate::GetDialogContentURL() const {
42 return url_;
45 void TestWebDialogDelegate::GetWebUIMessageHandlers(
46 std::vector<WebUIMessageHandler*>* handlers) const {
49 void TestWebDialogDelegate::GetDialogSize(gfx::Size* size) const {
50 *size = size_;
53 std::string TestWebDialogDelegate::GetDialogArgs() const {
54 return std::string();
57 void TestWebDialogDelegate::OnDialogClosed(const std::string& json_retval) {
58 if (did_delete_)
59 delete this;
62 void TestWebDialogDelegate::OnCloseContents(WebContents* source,
63 bool* out_close_dialog) {
64 *out_close_dialog = true;
67 bool TestWebDialogDelegate::ShouldShowDialogTitle() const {
68 return true;
71 } // namespace test
72 } // namespace ui