OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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/signin/profile_signin_confirmation_dialog.h" | |
6 | |
7 #include "base/json/json_writer.h" | |
8 #include "chrome/browser/profiles/profile_manager.h" | |
9 #include "chrome/browser/ui/browser.h" | |
10 #include "chrome/browser/ui/browser_dialogs.h" | |
11 #include "chrome/browser/ui/browser_finder.h" | |
12 #include "chrome/browser/ui/browser_list.h" | |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
14 #include "chrome/browser/ui/web_contents_modal_dialog.h" | |
15 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | |
16 #include "chrome/common/url_constants.h" | |
17 #include "grit/browser_resources.h" | |
18 #include "grit/chromium_strings.h" | |
19 #include "grit/generated_resources.h" | |
20 #include "ui/base/l10n/l10n_util.h" | |
21 | |
22 namespace { | |
23 const int kMinimumDialogWidth = 640; | |
24 const int kMinimumDialogHeight = 480; | |
25 } // namespace | |
26 | |
27 void ProfileSigninConfirmationDialog::ShowDialog( | |
28 const std::string& username, | |
29 const base::Closure& cancel_signin, | |
30 const base::Closure& signin_with_new_profile, | |
31 const base::Closure& continue_signin) { | |
32 new ProfileSigninConfirmationDialog(username, | |
33 cancel_signin, | |
34 signin_with_new_profile, | |
35 continue_signin); | |
36 } | |
37 | |
38 ProfileSigninConfirmationDialog::ProfileSigninConfirmationDialog( | |
39 const std::string& username, | |
40 const base::Closure& cancel_signin, | |
41 const base::Closure& signin_with_new_profile, | |
42 const base::Closure& continue_signin) | |
43 : username_(username) { | |
44 handler_.reset(new ProfileSigninConfirmationHandler(this, | |
45 cancel_signin, | |
46 signin_with_new_profile, | |
47 continue_signin)); | |
48 | |
49 Profile* profile = ProfileManager::GetLastUsedProfile(); | |
Andrew T Wilson (Slow)
2013/02/10 20:47:26
You should probably have the caller pass in a prof
dconnelly
2013/02/11 09:35:16
Done.
| |
50 Browser* browser = FindBrowserWithProfile(profile, | |
51 chrome::HOST_DESKTOP_TYPE_FIRST); | |
52 DCHECK(browser); | |
53 delegate_ = CreateConstrainedWebDialog( | |
54 profile, this, NULL, browser->tab_strip_model()->GetActiveWebContents()); | |
55 } | |
56 | |
57 ProfileSigninConfirmationDialog::~ProfileSigninConfirmationDialog() { | |
58 } | |
59 | |
60 void ProfileSigninConfirmationDialog::Close() { | |
61 delegate_->GetWindow()->CloseWebContentsModalDialog(); | |
62 } | |
63 | |
64 ui::ModalType ProfileSigninConfirmationDialog::GetDialogModalType() const { | |
65 return ui::MODAL_TYPE_WINDOW; | |
66 } | |
67 | |
68 string16 ProfileSigninConfirmationDialog::GetDialogTitle() const { | |
69 return l10n_util::GetStringUTF16( | |
70 IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_DIALOG_TITLE); | |
71 } | |
72 | |
73 GURL ProfileSigninConfirmationDialog::GetDialogContentURL() const { | |
74 return GURL(chrome::kChromeUIProfileSigninConfirmationURL); | |
75 } | |
76 | |
77 void ProfileSigninConfirmationDialog::GetWebUIMessageHandlers( | |
78 std::vector<content::WebUIMessageHandler*>* handlers) const { | |
79 handlers->push_back(handler_.release()); | |
80 } | |
81 | |
82 void ProfileSigninConfirmationDialog::GetDialogSize(gfx::Size* size) const { | |
83 size->SetSize(kMinimumDialogWidth, kMinimumDialogHeight); | |
84 } | |
85 | |
86 std::string ProfileSigninConfirmationDialog::GetDialogArgs() const { | |
87 std::string data; | |
88 DictionaryValue dict; | |
89 dict.SetString("username", username_); | |
90 base::JSONWriter::Write(&dict, &data); | |
91 return data; | |
92 } | |
93 | |
94 void ProfileSigninConfirmationDialog::OnDialogClosed( | |
95 const std::string& json_retval) { | |
96 // TODO(dconnelly): if the user closed the tab we should cancel | |
97 } | |
98 | |
99 void ProfileSigninConfirmationDialog::OnCloseContents( | |
100 content::WebContents* source, | |
101 bool* out_close_dialog) { | |
102 if (out_close_dialog) | |
103 *out_close_dialog = true; | |
104 } | |
105 | |
106 bool ProfileSigninConfirmationDialog::ShouldShowDialogTitle() const { | |
107 return true; | |
108 } | |
OLD | NEW |