| OLD | NEW |
| 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 "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 11 #include "content/public/browser/web_ui_data_source.h" | 12 #include "content/public/browser/web_ui_data_source.h" |
| 12 #include "grit/browser_resources.h" | 13 #include "grit/browser_resources.h" |
| 13 #include "ui/web_dialogs/web_dialog_delegate.h" | 14 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 #if !defined(OS_MACOSX) | 17 #if !defined(OS_MACOSX) |
| 17 #include "chrome/browser/ui/browser_dialogs.h" | 18 #include "chrome/browser/ui/browser_dialogs.h" |
| 18 #endif | 19 #endif |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 63 } |
| 63 | 64 |
| 64 bool HandleContextMenu(const content::ContextMenuParams& params) override { | 65 bool HandleContextMenu(const content::ContextMenuParams& params) override { |
| 65 // Do not show the contextual menu. | 66 // Do not show the contextual menu. |
| 66 return true; | 67 return true; |
| 67 } | 68 } |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 } // namespace | 71 } // namespace |
| 71 | 72 |
| 73 namespace { |
| 74 |
| 75 content::WebUIDataSource* CreateMdFeedbackUIHTMLSource(Profile* profile) { |
| 76 content::WebUIDataSource* html_source = |
| 77 content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost); |
| 78 |
| 79 // General strings. |
| 80 html_source->AddLocalizedString("headingText", |
| 81 IDS_MD_FEEDBACK_HEADING); |
| 82 |
| 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 } |
| 107 |
| 108 } // namespace |
| 109 |
| 72 MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui) | 110 MdFeedbackUI::MdFeedbackUI(content::WebUI* web_ui) |
| 73 : content::WebUIController(web_ui) { | 111 : content::WebUIController(web_ui) { |
| 74 // Set up the chrome://feedback data html_source. | 112 // Set up the chrome://feedback data html_source. |
| 113 Profile* profile = Profile::FromWebUI(web_ui); |
| 75 content::WebUIDataSource* html_source = | 114 content::WebUIDataSource* html_source = |
| 76 content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost); | 115 CreateMdFeedbackUIHTMLSource(profile); |
| 77 html_source->SetDefaultResource(IDR_MD_FEEDBACK_FEEDBACK_HTML); | 116 content::WebUIDataSource::Add(profile, html_source); |
| 78 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); | |
| 79 } | 117 } |
| 80 | 118 |
| 81 MdFeedbackUI::~MdFeedbackUI() {} | 119 MdFeedbackUI::~MdFeedbackUI() {} |
| 82 | 120 |
| 83 void ShowFeedbackWebDialog( | 121 void ShowFeedbackWebDialog( |
| 84 content::BrowserContext* browser_context) { | 122 content::BrowserContext* browser_context) { |
| 85 // TODO(apacible): Platform dependent implementations. | 123 // TODO(apacible): Platform dependent implementations. |
| 86 #if !defined(OS_MACOSX) | 124 #if !defined(OS_MACOSX) |
| 87 // TODO(apacible): If a feedback dialog is already open, bring that dialog | 125 // TODO(apacible): If a feedback dialog is already open, bring that dialog |
| 88 // to the front rather than creating a new dialog. | 126 // to the front rather than creating a new dialog. |
| 89 chrome::ShowWebDialog(NULL, browser_context, new MdFeedbackDialogDelegate()); | 127 chrome::ShowWebDialog(NULL, browser_context, new MdFeedbackDialogDelegate()); |
| 90 #endif // !OS_MACOSX | 128 #endif // !OS_MACOSX |
| 91 } | 129 } |
| OLD | NEW |