Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / charger_replace / charger_link_dialog.cc
blob415b783832672ab44965f243a0dc21d658ef339f
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;
22 namespace chromeos {
24 namespace {
26 const int kDefaultDialogWidth = 1200;
27 const int kDefaultDialogHeight = 650;
29 } // namespace
31 ChargerLinkDialog::ChargerLinkDialog(gfx::NativeWindow parent_window,
32 std::string url)
33 : parent_window_(parent_window),
34 url_(url) {
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(),
46 this);
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 {
58 return GURL(url_);
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 {
70 return std::string();
73 void ChargerLinkDialog::OnDialogClosed(const std::string& json_retval) {
74 delete this;
77 void ChargerLinkDialog::OnCloseContents(WebContents* source,
78 bool* out_close_dialog) {
79 if (out_close_dialog)
80 *out_close_dialog = true;
83 bool ChargerLinkDialog::ShouldShowDialogTitle() const {
84 return true;
87 bool ChargerLinkDialog::HandleContextMenu(
88 const content::ContextMenuParams& params) {
89 // Disable context menu.
90 return true;
93 } // namespace chromeos