OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 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/chromeos/charger_replace/charger_link_dialog.h" | |
6 | |
7 #include "base/json/json_writer.h" | |
8 #include "base/prefs/pref_service.h" | |
9 #include "chrome/browser/browser_process.h" | |
10 #include "chrome/browser/profiles/profile_manager.h" | |
11 #include "chrome/browser/ui/browser_dialogs.h" | |
12 #include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h" | |
13 #include "chrome/common/url_constants.h" | |
14 #include "chrome/grit/generated_resources.h" | |
15 #include "ui/base/l10n/l10n_util.h" | |
16 #include "ui/gfx/size.h" | |
17 | |
18 using content::WebContents; | |
19 using content::WebUIMessageHandler; | |
20 | |
21 namespace chromeos { | |
22 | |
23 namespace { | |
24 | |
25 const int kDefaultDialogWidth = 1200; | |
26 const int kDefaultDialogHeight = 650; | |
27 | |
28 } // namespace | |
29 | |
30 ChargerLinkDialog::ChargerLinkDialog(gfx::NativeWindow parent_window, | |
31 std::string url) | |
32 : parent_window_(parent_window), | |
33 url_(url) { | |
34 } | |
35 | |
36 ChargerLinkDialog::~ChargerLinkDialog() { | |
37 } | |
38 | |
39 void ChargerLinkDialog::Show() { | |
40 // We show the dialog for the active user, so that the dialog will get | |
41 // displayed immediately. The parent window is a system modal/lock container | |
42 // and does not belong to any user. | |
43 chrome::ShowWebDialog(parent_window_, | |
44 ProfileManager::GetActiveUserProfile(), | |
45 this); | |
46 } | |
47 | |
48 ui::ModalType ChargerLinkDialog::GetDialogModalType() const { | |
49 return ui::MODAL_TYPE_SYSTEM; | |
50 } | |
51 | |
52 base::string16 ChargerLinkDialog::GetDialogTitle() const { | |
53 return l10n_util::GetStringUTF16(IDS_CHARGER_REPLACEMENT_DIALOG_TITLE); | |
54 } | |
55 | |
56 GURL ChargerLinkDialog::GetDialogContentURL() const { | |
57 return GURL(url_); | |
58 } | |
59 | |
60 void ChargerLinkDialog::GetWebUIMessageHandlers( | |
61 std::vector<WebUIMessageHandler*>* handlers) const { | |
62 } | |
63 | |
64 void ChargerLinkDialog::GetDialogSize(gfx::Size* size) const { | |
65 size->SetSize(kDefaultDialogWidth, kDefaultDialogHeight); | |
66 } | |
67 | |
68 std::string ChargerLinkDialog::GetDialogArgs() const { | |
69 return std::string(); | |
70 } | |
71 | |
72 void ChargerLinkDialog::OnDialogClosed(const std::string& json_retval) { | |
73 delete this; | |
74 } | |
75 | |
76 void ChargerLinkDialog::OnCloseContents(WebContents* source, | |
77 bool* out_close_dialog) { | |
78 if (out_close_dialog) | |
79 *out_close_dialog = true; | |
80 } | |
81 | |
82 bool ChargerLinkDialog::ShouldShowDialogTitle() const { | |
83 return true; | |
84 } | |
85 | |
86 bool ChargerLinkDialog::HandleContextMenu( | |
87 const content::ContextMenuParams& params) { | |
88 // Disable context menu. | |
89 return true; | |
90 } | |
91 | |
92 } // namespace chromeos | |
OLD | NEW |