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

Side by Side Diff: remoting/host/it2me/it2me_confirmation_dialog_chromeos.cc

Issue 2310303002: Moving It2Me confirmation prompt into the Validation callback flow (Closed)
Patch Set: Addressing CR Feedback 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <memory>
6 #include <string>
7
5 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h"
6 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
7 #include "base/location.h" 11 #include "base/i18n/message_formatter.h"
8 #include "base/macros.h" 12 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 13 #include "base/strings/utf_string_conversions.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h"
12 #include "remoting/base/string_resources.h" 14 #include "remoting/base/string_resources.h"
13 #include "remoting/host/chromeos/message_box.h" 15 #include "remoting/host/chromeos/message_box.h"
14 #include "remoting/host/it2me/it2me_confirmation_dialog.h" 16 #include "remoting/host/it2me/it2me_confirmation_dialog.h"
15 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
16 18
17 namespace remoting { 19 namespace remoting {
18 20
19 class It2MeConfirmationDialogChromeOS : public It2MeConfirmationDialog { 21 class It2MeConfirmationDialogChromeOS : public It2MeConfirmationDialog {
20 public: 22 public:
21 It2MeConfirmationDialogChromeOS(); 23 It2MeConfirmationDialogChromeOS();
22 ~It2MeConfirmationDialogChromeOS() override; 24 ~It2MeConfirmationDialogChromeOS() override;
23 25
24 // It2MeConfirmationDialog implementation. 26 // It2MeConfirmationDialog implementation.
25 void Show(const ResultCallback& callback) override; 27 void Show(const std::string& remote_user_email,
28 const ResultCallback& callback) override;
26 29
27 private: 30 private:
28 // Handles result from |message_box_|. 31 // Handles result from |message_box_|.
29 void OnMessageBoxResult(MessageBox::Result result); 32 void OnMessageBoxResult(MessageBox::Result result);
30 33
31 std::unique_ptr<MessageBox> message_box_; 34 std::unique_ptr<MessageBox> message_box_;
32 ResultCallback callback_; 35 ResultCallback callback_;
33 36
34 DISALLOW_COPY_AND_ASSIGN(It2MeConfirmationDialogChromeOS); 37 DISALLOW_COPY_AND_ASSIGN(It2MeConfirmationDialogChromeOS);
35 }; 38 };
36 39
37 It2MeConfirmationDialogChromeOS::It2MeConfirmationDialogChromeOS() {} 40 It2MeConfirmationDialogChromeOS::It2MeConfirmationDialogChromeOS() {}
38 41
39 It2MeConfirmationDialogChromeOS::~It2MeConfirmationDialogChromeOS() {} 42 It2MeConfirmationDialogChromeOS::~It2MeConfirmationDialogChromeOS() {}
40 43
41 void It2MeConfirmationDialogChromeOS::Show(const ResultCallback& callback) { 44 void It2MeConfirmationDialogChromeOS::Show(const std::string& remote_user_email,
45 const ResultCallback& callback) {
46 DCHECK(!remote_user_email.empty());
42 callback_ = callback; 47 callback_ = callback;
43 48
44 message_box_.reset(new MessageBox( 49 message_box_.reset(new MessageBox(
45 l10n_util::GetStringUTF16(IDS_MODE_IT2ME), 50 l10n_util::GetStringUTF16(IDS_MODE_IT2ME),
46 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_MESSAGE), 51 base::i18n::MessageFormatter::FormatWithNumberedArgs(
52 l10n_util::GetStringUTF16(
53 IDS_SHARE_CONFIRM_DIALOG_MESSAGE_WITH_USERNAME),
54 base::UTF8ToUTF16(remote_user_email)),
47 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_CONFIRM), 55 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_CONFIRM),
48 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_DECLINE), 56 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_DECLINE),
49 base::Bind(&It2MeConfirmationDialogChromeOS::OnMessageBoxResult, 57 base::Bind(&It2MeConfirmationDialogChromeOS::OnMessageBoxResult,
50 base::Unretained(this)))); 58 base::Unretained(this))));
51 59
52 message_box_->Show(); 60 message_box_->Show();
53 } 61 }
54 62
55 void It2MeConfirmationDialogChromeOS::OnMessageBoxResult( 63 void It2MeConfirmationDialogChromeOS::OnMessageBoxResult(
56 MessageBox::Result result) { 64 MessageBox::Result result) {
57 message_box_->Hide(); 65 message_box_->Hide();
58 base::ResetAndReturn(&callback_).Run(result == MessageBox::OK ? 66 base::ResetAndReturn(&callback_).Run(result == MessageBox::OK ?
59 Result::OK : Result::CANCEL); 67 Result::OK : Result::CANCEL);
60 } 68 }
61 69
62 std::unique_ptr<It2MeConfirmationDialog> 70 std::unique_ptr<It2MeConfirmationDialog>
63 It2MeConfirmationDialogFactory::Create() { 71 It2MeConfirmationDialogFactory::Create() {
64 return std::unique_ptr<It2MeConfirmationDialog>( 72 return std::unique_ptr<It2MeConfirmationDialog>(
65 new It2MeConfirmationDialogChromeOS()); 73 new It2MeConfirmationDialogChromeOS());
66 } 74 }
67 75
68 } // namespace remoting 76 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_confirmation_dialog.h ('k') | remoting/host/it2me/it2me_confirmation_dialog_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698