| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 5 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/chromeos/login/users/user_manager.h" | 8 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/ui/browser_dialogs.h" | 10 #include "chrome/browser/ui/browser_dialogs.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
| 13 | 13 |
| 14 using content::WebContents; | 14 using content::WebContents; |
| 15 using content::WebUIMessageHandler; | 15 using content::WebUIMessageHandler; |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Default width/height of the dialog. | 19 // Default width/height of the dialog. |
| 20 const int kDefaultWidth = 350; | 20 const int kDefaultWidth = 350; |
| 21 const int kDefaultHeight = 225; | 21 const int kDefaultHeight = 225; |
| 22 | 22 |
| 23 // Width/height for the change PIN dialog mode. | 23 // Width/height for the change PIN dialog mode. |
| 24 const int kChangePinWidth = 350; | 24 const int kChangePinWidth = 350; |
| 25 const int kChangePinHeight = 245; | 25 const int kChangePinHeight = 245; |
| 26 | 26 |
| 27 // URL that includes additional mode (other than Unlock flow) that we're using | |
| 28 // dialog for. Possible values: | |
| 29 // change-pin - use dialog to change PIN, ask for old & new PIN. | |
| 30 // set-lock-on - enable RequirePin restriction. | |
| 31 // set-lock-off - disable RequirePin restriction. | |
| 32 // In general SIM unlock case sim-unlock URL is loaded w/o parameters. | |
| 33 const char kSimDialogSpecialModeURL[] = "chrome://sim-unlock/?mode=%s"; | |
| 34 | |
| 35 // Dialog mode constants. | 27 // Dialog mode constants. |
| 36 const char kSimDialogChangePinMode[] = "change-pin"; | 28 const char kSimDialogChangePinMode[] = "change-pin"; |
| 37 const char kSimDialogSetLockOnMode[] = "set-lock-on"; | 29 const char kSimDialogSetLockOnMode[] = "set-lock-on"; |
| 38 const char kSimDialogSetLockOffMode[] = "set-lock-off"; | 30 const char kSimDialogSetLockOffMode[] = "set-lock-off"; |
| 39 | 31 |
| 40 } // namespace | 32 } // namespace |
| 41 | 33 |
| 42 namespace chromeos { | 34 namespace chromeos { |
| 43 | 35 |
| 44 // static | 36 // static |
| (...skipping 24 matching lines...) Expand all Loading... |
| 69 std::string url_string(chrome::kChromeUISimUnlockURL); | 61 std::string url_string(chrome::kChromeUISimUnlockURL); |
| 70 return GURL(url_string); | 62 return GURL(url_string); |
| 71 } else { | 63 } else { |
| 72 std::string mode_value; | 64 std::string mode_value; |
| 73 if (dialog_mode_ == SIM_DIALOG_CHANGE_PIN) | 65 if (dialog_mode_ == SIM_DIALOG_CHANGE_PIN) |
| 74 mode_value = kSimDialogChangePinMode; | 66 mode_value = kSimDialogChangePinMode; |
| 75 else if (dialog_mode_ == SIM_DIALOG_SET_LOCK_ON) | 67 else if (dialog_mode_ == SIM_DIALOG_SET_LOCK_ON) |
| 76 mode_value = kSimDialogSetLockOnMode; | 68 mode_value = kSimDialogSetLockOnMode; |
| 77 else | 69 else |
| 78 mode_value = kSimDialogSetLockOffMode; | 70 mode_value = kSimDialogSetLockOffMode; |
| 79 return GURL( | 71 |
| 80 base::StringPrintf(kSimDialogSpecialModeURL, mode_value.c_str())); | 72 // Create a URL that includes an additional mode (other than Unlock flow). |
| 73 // Possible values for mode are: |
| 74 // change-pin - use dialog to change PIN, ask for old & new PIN. |
| 75 // set-lock-on - enable RequirePin restriction. |
| 76 // set-lock-off - disable RequirePin restriction. |
| 77 std::string url_string = |
| 78 std::string(chrome::kChromeUISimUnlockURL) + "?mode=" + mode_value; |
| 79 return GURL(url_string); |
| 81 } | 80 } |
| 82 } | 81 } |
| 83 | 82 |
| 84 void SimDialogDelegate::GetWebUIMessageHandlers( | 83 void SimDialogDelegate::GetWebUIMessageHandlers( |
| 85 std::vector<WebUIMessageHandler*>* handlers) const { | 84 std::vector<WebUIMessageHandler*>* handlers) const { |
| 86 } | 85 } |
| 87 | 86 |
| 88 void SimDialogDelegate::GetDialogSize(gfx::Size* size) const { | 87 void SimDialogDelegate::GetDialogSize(gfx::Size* size) const { |
| 89 // TODO(nkostylev): Set custom size based on locale settings. | 88 // TODO(nkostylev): Set custom size based on locale settings. |
| 90 if (dialog_mode_ == SIM_DIALOG_CHANGE_PIN) | 89 if (dialog_mode_ == SIM_DIALOG_CHANGE_PIN) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 111 return false; | 110 return false; |
| 112 } | 111 } |
| 113 | 112 |
| 114 bool SimDialogDelegate::HandleContextMenu( | 113 bool SimDialogDelegate::HandleContextMenu( |
| 115 const content::ContextMenuParams& params) { | 114 const content::ContextMenuParams& params) { |
| 116 // Disable context menu. | 115 // Disable context menu. |
| 117 return true; | 116 return true; |
| 118 } | 117 } |
| 119 | 118 |
| 120 } // namespace chromeos | 119 } // namespace chromeos |
| OLD | NEW |