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

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

Issue 2159323003: [MD Feedback] Add placeholder feedback entry point. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per afakhry@'s comments. Created 4 years, 4 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_ui.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/common/url_constants.h" 8 #include "chrome/common/url_constants.h"
9 #include "chrome/grit/generated_resources.h" 9 #include "chrome/grit/generated_resources.h"
10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_ui_data_source.h" 10 #include "content/public/browser/web_ui_data_source.h"
13 #include "grit/browser_resources.h" 11 #include "grit/browser_resources.h"
14 #include "ui/web_dialogs/web_dialog_delegate.h"
15 #include "url/gurl.h"
16 12
17 #if !defined(OS_MACOSX) 13 #if !defined(OS_MACOSX)
18 #include "chrome/browser/ui/browser_dialogs.h" 14 #include "chrome/browser/ui/browser_dialogs.h"
19 #endif 15 #endif
20 16
21 namespace { 17 namespace {
22 18
23 // The WebDialogDelegate that specifies what the MD Feedback dialog will look
24 // like.
25 class MdFeedbackDialogDelegate : public ui::WebDialogDelegate {
26 public:
27 MdFeedbackDialogDelegate() {}
28 ~MdFeedbackDialogDelegate() override {}
29
30 ui::ModalType GetDialogModalType() const override {
31 return ui::MODAL_TYPE_SYSTEM;
32 }
33
34 base::string16 GetDialogTitle() const override {
35 return base::string16();
36 }
37
38 GURL GetDialogContentURL() const override {
39 return GURL(chrome::kChromeUIFeedbackURL);
40 }
41
42 void GetWebUIMessageHandlers(
43 std::vector<content::WebUIMessageHandler*>* handlers) const override {}
44
45 void GetDialogSize(gfx::Size* size) const override {
46 // TODO(apacible): Update when WebUI sizing behavior is finalized.
47 size->SetSize(400, 600);
48 }
49
50 std::string GetDialogArgs() const override {
51 return std::string();
52 }
53
54 void OnDialogClosed(const std::string& json_retval) override {
55 delete this;
56 }
57
58 void OnCloseContents(
59 content::WebContents* source, bool* out_close_dialog) override {}
60
61 bool ShouldShowDialogTitle() const override {
62 return false;
63 }
64
65 bool HandleContextMenu(const content::ContextMenuParams& params) override {
66 // Do not show the contextual menu.
67 return true;
68 }
69 };
70
71 } // namespace
72
73 namespace {
74
75 content::WebUIDataSource* CreateMdFeedbackUIHTMLSource(Profile* profile) { 19 content::WebUIDataSource* CreateMdFeedbackUIHTMLSource(Profile* profile) {
76 content::WebUIDataSource* html_source = 20 content::WebUIDataSource* html_source =
77 content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost); 21 content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost);
78 22
79 // General strings. 23 // General strings.
80 html_source->AddLocalizedString("headingText", 24 html_source->AddLocalizedString("headingText",
81 IDS_MD_FEEDBACK_HEADING); 25 IDS_MD_FEEDBACK_HEADING);
82 #if defined(GOOGLE_CHROME_BUILD) 26 #if defined(GOOGLE_CHROME_BUILD)
83 html_source->AddLocalizedString("privacyNote", 27 html_source->AddLocalizedString("privacyNote",
84 IDS_MD_FEEDBACK_PRIVACY_NOTE); 28 IDS_MD_FEEDBACK_PRIVACY_NOTE);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui) 64 MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui)
121 : content::WebUIController(web_ui) { 65 : content::WebUIController(web_ui) {
122 // Set up the chrome://feedback data html_source. 66 // Set up the chrome://feedback data html_source.
123 Profile* profile = Profile::FromWebUI(web_ui); 67 Profile* profile = Profile::FromWebUI(web_ui);
124 content::WebUIDataSource* html_source = 68 content::WebUIDataSource* html_source =
125 CreateMdFeedbackUIHTMLSource(profile); 69 CreateMdFeedbackUIHTMLSource(profile);
126 content::WebUIDataSource::Add(profile, html_source); 70 content::WebUIDataSource::Add(profile, html_source);
127 } 71 }
128 72
129 MdFeedbackUI::~MdFeedbackUI() {} 73 MdFeedbackUI::~MdFeedbackUI() {}
130
131 void ShowFeedbackWebDialog(
132 content::BrowserContext* browser_context) {
133 // TODO(apacible): Platform dependent implementations.
134 #if !defined(OS_MACOSX)
135 // TODO(apacible): If a feedback dialog is already open, bring that dialog
136 // to the front rather than creating a new dialog.
137 chrome::ShowWebDialog(NULL, browser_context, new MdFeedbackDialogDelegate());
138 #endif // !OS_MACOSX
139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698