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

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

Issue 2021753005: [MD Feedback] Add basic chrome://feedback dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per imcheng@'s comments. Created 4 years, 6 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
« no previous file with comments | « chrome/browser/ui/webui/md_feedback/md_feedback_ui.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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.
9 #include "chrome/browser/ui/browser_dialogs.h"
10 #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.
8 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_ui_data_source.h" 14 #include "content/public/browser/web_ui_data_source.h"
10 #include "grit/browser_resources.h" 15 #include "grit/browser_resources.h"
16 #include "ui/web_dialogs/web_dialog_delegate.h"
17 #include "url/gurl.h"
18
19 namespace {
20
21 // The WebDialogDelegate that specifies what the MD Feedback dialog will look
22 // like.
23 class MdFeedbackDialogDelegate : public ui::WebDialogDelegate {
24 public:
25 MdFeedbackDialogDelegate() {}
26 ~MdFeedbackDialogDelegate() override {}
27
28 ui::ModalType GetDialogModalType() const override {
29 return ui::MODAL_TYPE_SYSTEM;
30 }
31
32 base::string16 GetDialogTitle() const override {
33 return base::string16();
34 }
35
36 GURL GetDialogContentURL() const override {
37 return GURL(chrome::kChromeUIFeedbackURL);
38 }
39
40 void GetWebUIMessageHandlers(
41 std::vector<content::WebUIMessageHandler*>* handlers) const override {}
42
43 void GetDialogSize(gfx::Size* size) const override {
44 // TODO(apacible): Update when WebUI sizing behavior is finalized.
45 size->SetSize(400, 600);
46 }
47
48 std::string GetDialogArgs() const override {
49 return std::string();
50 }
51
52 void OnDialogClosed(const std::string& json_retval) override {
53 delete this;
54 }
55
56 void OnCloseContents(
57 content::WebContents* source, bool* out_close_dialog) override {}
58
59 bool ShouldShowDialogTitle() const override {
60 return false;
61 }
62
63 bool HandleContextMenu(const content::ContextMenuParams& params) override {
64 // Do not show the contextual menu.
65 return true;
66 }
67 };
68
69 } // namespace
11 70
12 MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui) 71 MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui)
13 : content::WebUIController(web_ui) { 72 : content::WebUIController(web_ui) {
14 // Set up the chrome://feedback data html_source. 73 // Set up the chrome://feedback data html_source.
15 content::WebUIDataSource* html_source = 74 content::WebUIDataSource* html_source =
16 content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost); 75 content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost);
17 html_source->SetDefaultResource(IDR_MD_FEEDBACK_FEEDBACK_HTML); 76 html_source->SetDefaultResource(IDR_MD_FEEDBACK_FEEDBACK_HTML);
18 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); 77 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
19 } 78 }
20 79
21 MdFeedbackUI::~MdFeedbackUI() {} 80 MdFeedbackUI::~MdFeedbackUI() {}
81
82 void ShowFeedbackWebDialog(
83 content::BrowserContext* browser_context) {
84 // TODO(apacible): Platform dependent implementations.
85 #if !defined(OS_MACOSX)
86 // TODO(apacible): If a feedback dialog is already open, bring that dialog
87 // to the front rather than creating a new dialog.
88 chrome::ShowWebDialog(NULL, browser_context, new MdFeedbackDialogDelegate());
89 #endif // !OS_MACOSX
90 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/md_feedback/md_feedback_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698