Chromium Code Reviews| Index: chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.cc |
| diff --git a/chrome/browser/ui/webui/md_feedback/md_feedback_ui.cc b/chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.cc |
| similarity index 50% |
| copy from chrome/browser/ui/webui/md_feedback/md_feedback_ui.cc |
| copy to chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.cc |
| index f740732c7ad1b1a1e8553cf1c7451f19e59edae2..5af214fd90919c83de7058d9c5d83163621862c1 100644 |
| --- a/chrome/browser/ui/webui/md_feedback/md_feedback_ui.cc |
| +++ b/chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.cc |
| @@ -2,22 +2,15 @@ |
| // 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/md_feedback/md_feedback_ui.h" |
| +#include "chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.h" |
| -#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/ui/browser_dialogs.h" |
| #include "chrome/common/url_constants.h" |
| -#include "chrome/grit/generated_resources.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" |
| -#if !defined(OS_MACOSX) |
| -#include "chrome/browser/ui/browser_dialogs.h" |
| -#endif |
| - |
| namespace { |
| // The WebDialogDelegate that specifies what the MD Feedback dialog will look |
| @@ -70,60 +63,22 @@ class MdFeedbackDialogDelegate : public ui::WebDialogDelegate { |
| } // namespace |
| -namespace { |
| +MdFeedbackDialogController::MdFeedbackDialogController() {} |
|
afakhry
2016/08/02 22:15:56
Please keep the order of your functions implementa
apacible
2016/08/09 22:11:14
Done.
|
| -content::WebUIDataSource* CreateMdFeedbackUIHTMLSource(Profile* profile) { |
| - content::WebUIDataSource* html_source = |
| - content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost); |
| - |
| - // General strings. |
| - html_source->AddLocalizedString("headingText", |
| - IDS_MD_FEEDBACK_HEADING); |
| - |
| - // Input labels. |
| - html_source->AddLocalizedString("emailLabel", |
| - IDS_MD_FEEDBACK_USER_EMAIL_LABEL); |
| - html_source->AddLocalizedString("openEndedLabel", |
| - IDS_MD_FEEDBACK_OPEN_ENDED_LABEL); |
| - html_source->AddLocalizedString("urlLabel", |
| - IDS_MD_FEEDBACK_URL_LABEL); |
| - |
| - // Buttons. |
| - html_source->AddLocalizedString("cancelButton", |
| - IDS_MD_FEEDBACK_CANCEL_BUTTON); |
| - html_source->AddLocalizedString("sendReportButton", |
| - IDS_MD_FEEDBACK_SEND_REPORT_BUTTON); |
| - |
| - // Polymer resources. |
| - html_source->AddResourcePath("feedback_container.html", |
| - IDR_MD_FEEDBACK_FEEDBACK_CONTAINER_HTML); |
| - html_source->AddResourcePath("feedback_container.js", |
| - IDR_MD_FEEDBACK_FEEDBACK_CONTAINER_JS); |
| - |
| - html_source->SetJsonPath("strings.js"); |
| - html_source->SetDefaultResource(IDR_MD_FEEDBACK_FEEDBACK_HTML); |
| - return html_source; |
| -} |
| - |
| -} // namespace |
| +MdFeedbackDialogController::~MdFeedbackDialogController() {} |
| -MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui) |
| - : content::WebUIController(web_ui) { |
| - // Set up the chrome://feedback data html_source. |
| - Profile* profile = Profile::FromWebUI(web_ui); |
| - content::WebUIDataSource* html_source = |
| - CreateMdFeedbackUIHTMLSource(profile); |
| - content::WebUIDataSource::Add(profile, html_source); |
| +// static |
| +MdFeedbackDialogController* MdFeedbackDialogController::GetOrCreate() { |
| + // TODO(apacible): If a controller already exists for this profile, reuse it. |
| + return new MdFeedbackDialogController(); |
|
afakhry
2016/08/02 22:15:56
Hmmm, even with the presence of the above TODO, I
apacible
2016/08/09 22:11:14
SGTM. Switched to using a singleton.
|
| } |
| -MdFeedbackUI::~MdFeedbackUI() {} |
| - |
| -void ShowFeedbackWebDialog( |
| +void MdFeedbackDialogController::Show( |
| 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()); |
|
afakhry
2016/08/02 22:15:56
Nit: NULL --> nullptr.
apacible
2016/08/09 22:11:14
Done.
|
| -#endif // !OS_MACOSX |
| +#endif |
|
afakhry
2016/08/02 22:15:56
Nit: #endif // !defined(OS_MACOSX)
apacible
2016/08/09 22:11:13
Done.
|
| } |