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/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" |
| 18 |
| 19 using content::WebContents; |
| 20 using content::WebUIMessageHandler; |
| 21 |
| 22 namespace chromeos { |
| 23 |
| 24 namespace { |
| 25 |
| 26 const int kDefaultDialogWidth = 1200; |
| 27 const int kDefaultDialogHeight = 650; |
| 28 |
| 29 } // namespace |
| 30 |
| 31 ChargerLinkDialog::ChargerLinkDialog(gfx::NativeWindow parent_window, |
| 32 std::string url) |
| 33 : parent_window_(parent_window), |
| 34 url_(url) { |
| 35 } |
| 36 |
| 37 ChargerLinkDialog::~ChargerLinkDialog() { |
| 38 } |
| 39 |
| 40 void ChargerLinkDialog::Show() { |
| 41 chrome::ShowWebDialog(parent_window_, |
| 42 ProfileManager::GetDefaultProfile(), |
| 43 this); |
| 44 } |
| 45 |
| 46 ui::ModalType ChargerLinkDialog::GetDialogModalType() const { |
| 47 return ui::MODAL_TYPE_SYSTEM; |
| 48 } |
| 49 |
| 50 string16 ChargerLinkDialog::GetDialogTitle() const { |
| 51 return l10n_util::GetStringUTF16(IDS_CHARGER_REPLACEMENT_DIALOG_TITLE); |
| 52 } |
| 53 |
| 54 GURL ChargerLinkDialog::GetDialogContentURL() const { |
| 55 return GURL(url_); |
| 56 } |
| 57 |
| 58 void ChargerLinkDialog::GetWebUIMessageHandlers( |
| 59 std::vector<WebUIMessageHandler*>* handlers) const { |
| 60 } |
| 61 |
| 62 void ChargerLinkDialog::GetDialogSize(gfx::Size* size) const { |
| 63 size->SetSize(kDefaultDialogWidth, kDefaultDialogHeight); |
| 64 } |
| 65 |
| 66 std::string ChargerLinkDialog::GetDialogArgs() const { |
| 67 return std::string(); |
| 68 } |
| 69 |
| 70 void ChargerLinkDialog::OnDialogClosed(const std::string& json_retval) { |
| 71 delete this; |
| 72 } |
| 73 |
| 74 void ChargerLinkDialog::OnCloseContents(WebContents* source, |
| 75 bool* out_close_dialog) { |
| 76 if (out_close_dialog) |
| 77 *out_close_dialog = true; |
| 78 } |
| 79 |
| 80 bool ChargerLinkDialog::ShouldShowDialogTitle() const { |
| 81 return true; |
| 82 } |
| 83 |
| 84 bool ChargerLinkDialog::HandleContextMenu( |
| 85 const content::ContextMenuParams& params) { |
| 86 // Disable context menu. |
| 87 return true; |
| 88 } |
| 89 |
| 90 } // namespace chromeos |
OLD | NEW |