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.
5 #include "chrome/browser/chromeos/charger_replace/charger_link_dialog.h"
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/pref_names.h"
14 #include "chrome/common/url_constants.h"
15 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/size.h"
19 using content::WebContents
;
20 using content::WebUIMessageHandler
;
26 const int kDefaultDialogWidth
= 1200;
27 const int kDefaultDialogHeight
= 650;
31 ChargerLinkDialog::ChargerLinkDialog(gfx::NativeWindow parent_window
,
33 : parent_window_(parent_window
),
37 ChargerLinkDialog::~ChargerLinkDialog() {
40 void ChargerLinkDialog::Show() {
41 // We show the dialog for the active user, so that the dialog will get
42 // displayed immediately. The parent window is a system modal/lock container
43 // and does not belong to any user.
44 chrome::ShowWebDialog(parent_window_
,
45 ProfileManager::GetActiveUserProfile(),
49 ui::ModalType
ChargerLinkDialog::GetDialogModalType() const {
50 return ui::MODAL_TYPE_SYSTEM
;
53 base::string16
ChargerLinkDialog::GetDialogTitle() const {
54 return l10n_util::GetStringUTF16(IDS_CHARGER_REPLACEMENT_DIALOG_TITLE
);
57 GURL
ChargerLinkDialog::GetDialogContentURL() const {
61 void ChargerLinkDialog::GetWebUIMessageHandlers(
62 std::vector
<WebUIMessageHandler
*>* handlers
) const {
65 void ChargerLinkDialog::GetDialogSize(gfx::Size
* size
) const {
66 size
->SetSize(kDefaultDialogWidth
, kDefaultDialogHeight
);
69 std::string
ChargerLinkDialog::GetDialogArgs() const {
73 void ChargerLinkDialog::OnDialogClosed(const std::string
& json_retval
) {
77 void ChargerLinkDialog::OnCloseContents(WebContents
* source
,
78 bool* out_close_dialog
) {
80 *out_close_dialog
= true;
83 bool ChargerLinkDialog::ShouldShowDialogTitle() const {
87 bool ChargerLinkDialog::HandleContextMenu(
88 const content::ContextMenuParams
& params
) {
89 // Disable context menu.
93 } // namespace chromeos