Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / sim_dialog_delegate.cc
blob4321b1c82c4f403958c78fd889a2bb09e399090c
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.
5 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/ui/browser_dialogs.h"
10 #include "chrome/common/url_constants.h"
11 #include "ui/gfx/geometry/size.h"
13 using content::WebContents;
14 using content::WebUIMessageHandler;
16 namespace {
18 // Default width/height of the dialog.
19 const int kDefaultWidth = 350;
20 const int kDefaultHeight = 225;
22 // Width/height for the change PIN dialog mode.
23 const int kChangePinWidth = 350;
24 const int kChangePinHeight = 245;
26 // Dialog mode constants.
27 const char kSimDialogChangePinMode[] = "change-pin";
28 const char kSimDialogSetLockOnMode[] = "set-lock-on";
29 const char kSimDialogSetLockOffMode[] = "set-lock-off";
31 } // namespace
33 namespace chromeos {
35 // static
36 void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window,
37 SimDialogMode mode) {
38 chrome::ShowWebDialog(owning_window,
39 ProfileManager::GetActiveUserProfile(),
40 new SimDialogDelegate(mode));
43 SimDialogDelegate::SimDialogDelegate(SimDialogMode dialog_mode)
44 : dialog_mode_(dialog_mode) {
47 SimDialogDelegate::~SimDialogDelegate() {
50 ui::ModalType SimDialogDelegate::GetDialogModalType() const {
51 return ui::MODAL_TYPE_SYSTEM;
54 base::string16 SimDialogDelegate::GetDialogTitle() const {
55 return base::string16();
58 GURL SimDialogDelegate::GetDialogContentURL() const {
59 if (dialog_mode_ == SIM_DIALOG_UNLOCK) {
60 std::string url_string(chrome::kChromeUISimUnlockURL);
61 return GURL(url_string);
62 } else {
63 std::string mode_value;
64 if (dialog_mode_ == SIM_DIALOG_CHANGE_PIN)
65 mode_value = kSimDialogChangePinMode;
66 else if (dialog_mode_ == SIM_DIALOG_SET_LOCK_ON)
67 mode_value = kSimDialogSetLockOnMode;
68 else
69 mode_value = kSimDialogSetLockOffMode;
71 // Create a URL that includes an additional mode (other than Unlock flow).
72 // Possible values for mode are:
73 // change-pin - use dialog to change PIN, ask for old & new PIN.
74 // set-lock-on - enable RequirePin restriction.
75 // set-lock-off - disable RequirePin restriction.
76 std::string url_string =
77 std::string(chrome::kChromeUISimUnlockURL) + "?mode=" + mode_value;
78 return GURL(url_string);
82 void SimDialogDelegate::GetWebUIMessageHandlers(
83 std::vector<WebUIMessageHandler*>* handlers) const {
86 void SimDialogDelegate::GetDialogSize(gfx::Size* size) const {
87 // TODO(nkostylev): Set custom size based on locale settings.
88 if (dialog_mode_ == SIM_DIALOG_CHANGE_PIN)
89 size->SetSize(kChangePinWidth , kChangePinHeight);
90 else
91 size->SetSize(kDefaultWidth, kDefaultHeight);
94 std::string SimDialogDelegate::GetDialogArgs() const {
95 return "[]";
98 void SimDialogDelegate::OnDialogClosed(const std::string& json_retval) {
99 delete this;
102 void SimDialogDelegate::OnCloseContents(WebContents* source,
103 bool* out_close_dialog) {
104 if (out_close_dialog)
105 *out_close_dialog = true;
108 bool SimDialogDelegate::ShouldShowDialogTitle() const {
109 return false;
112 bool SimDialogDelegate::HandleContextMenu(
113 const content::ContextMenuParams& params) {
114 // Disable context menu.
115 return true;
118 } // namespace chromeos