Chromium Code Reviews| Index: chrome/browser/ui/webui/md_feedback/md_feedback_ui.cc |
| diff --git a/chrome/browser/ui/webui/md_feedback/md_feedback_ui.cc b/chrome/browser/ui/webui/md_feedback/md_feedback_ui.cc |
| index c6ee03764c590458f78f81496486abdde53b0ddf..ad824e28423cc5412e1861e4d7d9bc8ad61148d5 100644 |
| --- a/chrome/browser/ui/webui/md_feedback/md_feedback_ui.cc |
| +++ b/chrome/browser/ui/webui/md_feedback/md_feedback_ui.cc |
| @@ -5,9 +5,68 @@ |
| #include "chrome/browser/ui/webui/md_feedback/md_feedback_ui.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#if !defined(OS_MACOSX) |
|
imcheng
2016/06/02 19:50:00
put this below the unconditional #includes.
apacible
2016/06/02 21:00:42
Done.
|
| +#include "chrome/browser/ui/browser_dialogs.h" |
| +#endif // !OS_MACOSX |
|
imcheng
2016/06/02 19:50:00
nit: if the #if macro is short, no need to add com
apacible
2016/06/02 21:00:42
Done.
|
| #include "chrome/common/url_constants.h" |
| +#include "content/public/browser/browser_context.h" |
| +#include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_ui_data_source.h" |
| #include "grit/browser_resources.h" |
| +#include "ui/web_dialogs/web_dialog_delegate.h" |
| +#include "url/gurl.h" |
| + |
| +namespace { |
| + |
| +// The WebDialogDelegate that specifies what the MD Feedback dialog will look |
| +// like. |
| +class MdFeedbackDialogDelegate : public ui::WebDialogDelegate { |
| + public: |
| + MdFeedbackDialogDelegate() {} |
| + ~MdFeedbackDialogDelegate() override {} |
| + |
| + ui::ModalType GetDialogModalType() const override { |
| + return ui::MODAL_TYPE_SYSTEM; |
| + } |
| + |
| + base::string16 GetDialogTitle() const override { |
| + return base::string16(); |
| + } |
| + |
| + GURL GetDialogContentURL() const override { |
| + return GURL(chrome::kChromeUIFeedbackURL); |
| + } |
| + |
| + void GetWebUIMessageHandlers( |
| + std::vector<content::WebUIMessageHandler*>* handlers) const override {} |
| + |
| + void GetDialogSize(gfx::Size* size) const override { |
| + // TODO(apacible): Update when WebUI sizing behavior is finalized. |
| + size->SetSize(400, 600); |
| + } |
| + |
| + std::string GetDialogArgs() const override { |
| + return std::string(); |
| + } |
| + |
| + void OnDialogClosed(const std::string& json_retval) override { |
| + delete this; |
| + } |
| + |
| + void OnCloseContents( |
| + content::WebContents* source, bool* out_close_dialog) override {} |
| + |
| + bool ShouldShowDialogTitle() const override { |
| + return false; |
| + } |
| + |
| + bool HandleContextMenu(const content::ContextMenuParams& params) override { |
| + // Do not show the contextual menu. |
| + return true; |
| + } |
| +}; |
| + |
| +} // namespace |
| MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui) |
| : content::WebUIController(web_ui) { |
| @@ -19,3 +78,13 @@ MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui) |
| } |
| MdFeedbackUI::~MdFeedbackUI() {} |
| + |
| +void ShowFeedbackWebDialog( |
| + content::BrowserContext* browser_context) { |
| + // TODO(apacible): Platform dependent implementations. |
| +#if !defined(OS_MACOSX) |
| + // TODO(apacible): If a feedback dialog is already open, bring that dialog |
| + // to the front rather than creating a new dialog. |
| + chrome::ShowWebDialog(NULL, browser_context, new MdFeedbackDialogDelegate()); |
| +#endif // !OS_MACOSX |
| +} |