Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.cc

Issue 2159323003: [MD Feedback] Add placeholder feedback entry point. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/md_feedback/md_feedback_ui.h" 5 #include "chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/ui/browser_dialogs.h"
8 #include "chrome/common/url_constants.h" 8 #include "chrome/common/url_constants.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_ui_data_source.h"
13 #include "grit/browser_resources.h"
14 #include "ui/web_dialogs/web_dialog_delegate.h" 11 #include "ui/web_dialogs/web_dialog_delegate.h"
15 #include "url/gurl.h" 12 #include "url/gurl.h"
16 13
17 #if !defined(OS_MACOSX)
18 #include "chrome/browser/ui/browser_dialogs.h"
19 #endif
20
21 namespace { 14 namespace {
22 15
23 // The WebDialogDelegate that specifies what the MD Feedback dialog will look 16 // The WebDialogDelegate that specifies what the MD Feedback dialog will look
24 // like. 17 // like.
25 class MdFeedbackDialogDelegate : public ui::WebDialogDelegate { 18 class MdFeedbackDialogDelegate : public ui::WebDialogDelegate {
26 public: 19 public:
27 MdFeedbackDialogDelegate() {} 20 MdFeedbackDialogDelegate() {}
28 ~MdFeedbackDialogDelegate() override {} 21 ~MdFeedbackDialogDelegate() override {}
29 22
30 ui::ModalType GetDialogModalType() const override { 23 ui::ModalType GetDialogModalType() const override {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 56 }
64 57
65 bool HandleContextMenu(const content::ContextMenuParams& params) override { 58 bool HandleContextMenu(const content::ContextMenuParams& params) override {
66 // Do not show the contextual menu. 59 // Do not show the contextual menu.
67 return true; 60 return true;
68 } 61 }
69 }; 62 };
70 63
71 } // namespace 64 } // namespace
72 65
73 namespace { 66 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.
74 67
75 content::WebUIDataSource* CreateMdFeedbackUIHTMLSource(Profile* profile) { 68 MdFeedbackDialogController::~MdFeedbackDialogController() {}
76 content::WebUIDataSource* html_source =
77 content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost);
78 69
79 // General strings. 70 // static
80 html_source->AddLocalizedString("headingText", 71 MdFeedbackDialogController* MdFeedbackDialogController::GetOrCreate() {
81 IDS_MD_FEEDBACK_HEADING); 72 // TODO(apacible): If a controller already exists for this profile, reuse it.
82 73 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.
83 // Input labels.
84 html_source->AddLocalizedString("emailLabel",
85 IDS_MD_FEEDBACK_USER_EMAIL_LABEL);
86 html_source->AddLocalizedString("openEndedLabel",
87 IDS_MD_FEEDBACK_OPEN_ENDED_LABEL);
88 html_source->AddLocalizedString("urlLabel",
89 IDS_MD_FEEDBACK_URL_LABEL);
90
91 // Buttons.
92 html_source->AddLocalizedString("cancelButton",
93 IDS_MD_FEEDBACK_CANCEL_BUTTON);
94 html_source->AddLocalizedString("sendReportButton",
95 IDS_MD_FEEDBACK_SEND_REPORT_BUTTON);
96
97 // Polymer resources.
98 html_source->AddResourcePath("feedback_container.html",
99 IDR_MD_FEEDBACK_FEEDBACK_CONTAINER_HTML);
100 html_source->AddResourcePath("feedback_container.js",
101 IDR_MD_FEEDBACK_FEEDBACK_CONTAINER_JS);
102
103 html_source->SetJsonPath("strings.js");
104 html_source->SetDefaultResource(IDR_MD_FEEDBACK_FEEDBACK_HTML);
105 return html_source;
106 } 74 }
107 75
108 } // namespace 76 void MdFeedbackDialogController::Show(
109
110 MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui)
111 : content::WebUIController(web_ui) {
112 // Set up the chrome://feedback data html_source.
113 Profile* profile = Profile::FromWebUI(web_ui);
114 content::WebUIDataSource* html_source =
115 CreateMdFeedbackUIHTMLSource(profile);
116 content::WebUIDataSource::Add(profile, html_source);
117 }
118
119 MdFeedbackUI::~MdFeedbackUI() {}
120
121 void ShowFeedbackWebDialog(
122 content::BrowserContext* browser_context) { 77 content::BrowserContext* browser_context) {
123 // TODO(apacible): Platform dependent implementations. 78 // TODO(apacible): Platform dependent implementations.
124 #if !defined(OS_MACOSX) 79 #if !defined(OS_MACOSX)
125 // TODO(apacible): If a feedback dialog is already open, bring that dialog 80 // TODO(apacible): If a feedback dialog is already open, bring that dialog
126 // to the front rather than creating a new dialog. 81 // to the front rather than creating a new dialog.
127 chrome::ShowWebDialog(NULL, browser_context, new MdFeedbackDialogDelegate()); 82 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.
128 #endif // !OS_MACOSX 83 #endif
afakhry 2016/08/02 22:15:56 Nit: #endif // !defined(OS_MACOSX)
apacible 2016/08/09 22:11:13 Done.
129 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698