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

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