Commit b6027333 authored by Kenton Lam's avatar Kenton Lam Committed by Chromium LUCI CQ

Split EmojiPickerDialog from emoji_picker.cc into separate file.

In preparation for adding webui message handlers, it will be cleaner to have the dialog-related code in a separate file.

Change-Id: I926788149d63a512055d1bb1932f60362f6b6172
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2626811Reviewed-by: default avatarJohn Palmer <jopalmer@chromium.org>
Reviewed-by: default avatarSatoru Takabayashi <satorux@chromium.org>
Reviewed-by: default avatarKeith Lee <keithlee@chromium.org>
Commit-Queue: Kenton Lam <kentonlam@google.com>
Cr-Commit-Position: refs/heads/master@{#843384}
parent c0a3f1d0
......@@ -138,7 +138,7 @@
#include "chrome/browser/ui/ash/assistant/assistant_state_client.h"
#include "chrome/browser/ui/ash/image_downloader_impl.h"
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h"
#include "chrome/browser/ui/webui/chromeos/emoji/emoji_picker.h"
#include "chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h"
#include "chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_constants.h"
......
......@@ -2222,6 +2222,8 @@ static_library("ui") {
"webui/chromeos/edu_coexistence_login_handler_chromeos.h",
"webui/chromeos/edu_coexistence_state_tracker.cc",
"webui/chromeos/edu_coexistence_state_tracker.h",
"webui/chromeos/emoji/emoji_dialog.cc",
"webui/chromeos/emoji/emoji_dialog.h",
"webui/chromeos/emoji/emoji_picker.cc",
"webui/chromeos/emoji/emoji_picker.h",
"webui/chromeos/image_source.cc",
......
// Copyright 2021 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/webui/chromeos/emoji/emoji_dialog.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/common/url_constants.h"
namespace chromeos {
EmojiPickerDialog::EmojiPickerDialog() {}
void EmojiPickerDialog::Show() {
chrome::ShowWebDialog(nullptr, ProfileManager::GetActiveUserProfile(),
new EmojiPickerDialog());
}
ui::ModalType EmojiPickerDialog::GetDialogModalType() const {
return ui::MODAL_TYPE_NONE;
}
base::string16 EmojiPickerDialog::GetDialogTitle() const {
return base::UTF8ToUTF16("Emoji picker");
}
GURL EmojiPickerDialog::GetDialogContentURL() const {
return GURL(chrome::kChromeUIEmojiPickerURL);
}
void EmojiPickerDialog::GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const {}
void EmojiPickerDialog::GetDialogSize(gfx::Size* size) const {
const int kDefaultWidth = 544;
const int kDefaultHeight = 628;
size->SetSize(kDefaultWidth, kDefaultHeight);
}
std::string EmojiPickerDialog::GetDialogArgs() const {
return "";
}
void EmojiPickerDialog::OnDialogShown(content::WebUI* webui) {
webui_ = webui;
}
void EmojiPickerDialog::OnDialogClosed(const std::string& json_retval) {
delete this;
}
void EmojiPickerDialog::OnCloseContents(content::WebContents* source,
bool* out_close_dialog) {
*out_close_dialog = true;
}
bool EmojiPickerDialog::ShouldShowDialogTitle() const {
return true;
}
EmojiPickerDialog::~EmojiPickerDialog() = default;
} // namespace chromeos
// Copyright 2021 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_WEBUI_CHROMEOS_EMOJI_EMOJI_DIALOG_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_DIALOG_H_
#include "base/macros.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
namespace chromeos {
class EmojiPickerDialog : public ui::WebDialogDelegate {
public:
static void Show();
~EmojiPickerDialog() override;
private:
EmojiPickerDialog();
// ui::WebDialogDelegate:
ui::ModalType GetDialogModalType() const override;
base::string16 GetDialogTitle() const override;
GURL GetDialogContentURL() const override;
void GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const override;
void GetDialogSize(gfx::Size* size) const override;
std::string GetDialogArgs() const override;
void OnDialogShown(content::WebUI* webui) override;
void OnDialogClosed(const std::string& json_retval) override;
void OnCloseContents(content::WebContents* source,
bool* out_close_dialog) override;
bool ShouldShowDialogTitle() const override;
content::WebUI* webui_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(EmojiPickerDialog);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_DIALOG_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Copyright 2021 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/webui/chromeos/emoji/emoji_picker.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/emoji_picker_resources.h"
......@@ -18,6 +13,8 @@
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h"
namespace chromeos {
EmojiPicker::EmojiPicker(content::WebUI* web_ui)
......@@ -45,55 +42,4 @@ EmojiPicker::EmojiPicker(content::WebUI* web_ui)
EmojiPicker::~EmojiPicker() {}
EmojiPickerDialog::EmojiPickerDialog() {}
void EmojiPickerDialog::Show() {
chrome::ShowWebDialog(nullptr, ProfileManager::GetActiveUserProfile(),
new EmojiPickerDialog());
}
ui::ModalType EmojiPickerDialog::GetDialogModalType() const {
return ui::MODAL_TYPE_NONE;
}
base::string16 EmojiPickerDialog::GetDialogTitle() const {
return base::UTF8ToUTF16("Emoji picker");
}
GURL EmojiPickerDialog::GetDialogContentURL() const {
return GURL(chrome::kChromeUIEmojiPickerURL);
}
void EmojiPickerDialog::GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const {}
void EmojiPickerDialog::GetDialogSize(gfx::Size* size) const {
const int kDefaultWidth = 544;
const int kDefaultHeight = 628;
size->SetSize(kDefaultWidth, kDefaultHeight);
}
std::string EmojiPickerDialog::GetDialogArgs() const {
return "";
}
void EmojiPickerDialog::OnDialogShown(content::WebUI* webui) {
webui_ = webui;
}
void EmojiPickerDialog::OnDialogClosed(const std::string& json_retval) {
delete this;
}
void EmojiPickerDialog::OnCloseContents(content::WebContents* source,
bool* out_close_dialog) {
*out_close_dialog = true;
}
bool EmojiPickerDialog::ShouldShowDialogTitle() const {
return true;
}
EmojiPickerDialog::~EmojiPickerDialog() = default;
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All Rights Reserved.
// Use of this source code is governed by the Apache v2.0 license that can be
// Copyright 2021 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_WEBUI_CHROMEOS_EMOJI_EMOJI_PICKER_H_
......@@ -21,32 +21,6 @@ class EmojiPicker : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(EmojiPicker);
};
class EmojiPickerDialog : public ui::WebDialogDelegate {
public:
static void Show();
~EmojiPickerDialog() override;
private:
EmojiPickerDialog();
// ui::WebDialogDelegate:
ui::ModalType GetDialogModalType() const override;
base::string16 GetDialogTitle() const override;
GURL GetDialogContentURL() const override;
void GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const override;
void GetDialogSize(gfx::Size* size) const override;
std::string GetDialogArgs() const override;
void OnDialogShown(content::WebUI* webui) override;
void OnDialogClosed(const std::string& json_retval) override;
void OnCloseContents(content::WebContents* source,
bool* out_close_dialog) override;
bool ShouldShowDialogTitle() const override;
content::WebUI* webui_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(EmojiPickerDialog);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_PICKER_H_
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