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

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

Issue 2190653003: [Md Feedback] Add initial data population for dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per afakhry@'s comments (Rebase). Created 4 years, 3 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_webui_message_handler.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/md_feedback/md_feedback_webui_message_handler. h"
6
7 #include "base/bind.h"
8 #include "base/values.h"
9 #include "chrome/browser/feedback/feedback_dialog_utils.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/signin/signin_manager_factory.h"
13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/browser/ui/webui/md_feedback/md_feedback_ui.h"
17 #include "components/signin/core/browser/signin_manager.h"
18
19 namespace {
20
21 // Message names.
22 constexpr char kRequestData[] = "requestData";
23
24 // JS function names.
25 constexpr char kSetData[] = "Feedback.UI.setData";
26
27 } // namespace
28
29 MdFeedbackWebUIMessageHandler::MdFeedbackWebUIMessageHandler(
30 MdFeedbackUI* md_feedback_ui)
31 : md_feedback_ui_(md_feedback_ui) {
32 DCHECK(md_feedback_ui_);
33 }
34
35 MdFeedbackWebUIMessageHandler::~MdFeedbackWebUIMessageHandler() {}
36
37 void MdFeedbackWebUIMessageHandler::RegisterMessages() {
38 web_ui()->RegisterMessageCallback(
39 kRequestData, base::Bind(&MdFeedbackWebUIMessageHandler::OnRequestData,
40 base::Unretained(this)));
41 }
42
43 void MdFeedbackWebUIMessageHandler::OnRequestData(const base::ListValue* args) {
44 DVLOG(1) << "OnRequestData";
45 base::DictionaryValue data;
46
47 Profile* profile = md_feedback_ui_->profile();
48 // Do not launch feedback on an OTR profile.
49 profile = profile->GetOriginalProfile();
50 DCHECK(profile);
51
52 SigninManagerBase* signin_manager =
53 SigninManagerFactory::GetForProfile(profile);
54 DCHECK(signin_manager);
55 data.SetString("email", signin_manager->GetAuthenticatedAccountInfo().email);
56
57 GURL page_url = GURL();
58 Browser* browser = chrome::FindBrowserWithProfile(profile);
59 if (browser) {
60 page_url = chrome::GetTargetTabUrl(
61 browser->session_id().id(), browser->tab_strip_model()->active_index());
62 }
63
64 data.SetString("url", page_url.spec());
65
66 web_ui()->CallJavascriptFunctionUnsafe(kSetData, data);
67 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/md_feedback/md_feedback_webui_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698