| 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/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
| 9 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 9 #include "chrome/browser/ui/browser_dialogs.h" | 10 #include "chrome/browser/ui/browser_dialogs.h" |
| 10 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 11 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 12 | 13 |
| 13 using content::WebContents; | 14 using content::WebContents; |
| 14 using content::WebUIMessageHandler; | 15 using content::WebUIMessageHandler; |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Default width/height of the dialog. | 19 // Default width/height of the dialog. |
| 19 const int kDefaultWidth = 350; | 20 const int kDefaultWidth = 350; |
| 20 const int kDefaultHeight = 225; | 21 const int kDefaultHeight = 225; |
| 21 | 22 |
| 22 // Width/height for the change PIN dialog mode. | 23 // Width/height for the change PIN dialog mode. |
| 23 const int kChangePinWidth = 350; | 24 const int kChangePinWidth = 350; |
| 24 const int kChangePinHeight = 245; | 25 const int kChangePinHeight = 245; |
| 25 | 26 |
| 26 // Dialog mode constants. | 27 // Dialog mode constants. |
| 27 const char kSimDialogChangePinMode[] = "change-pin"; | 28 const char kSimDialogChangePinMode[] = "change-pin"; |
| 28 const char kSimDialogSetLockOnMode[] = "set-lock-on"; | 29 const char kSimDialogSetLockOnMode[] = "set-lock-on"; |
| 29 const char kSimDialogSetLockOffMode[] = "set-lock-off"; | 30 const char kSimDialogSetLockOffMode[] = "set-lock-off"; |
| 30 | 31 |
| 31 } // namespace | 32 } // namespace |
| 32 | 33 |
| 33 namespace chromeos { | 34 namespace chromeos { |
| 34 | 35 |
| 35 // static | 36 // static |
| 36 void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window, | 37 void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window, |
| 37 SimDialogMode mode) { | 38 SimDialogMode mode) { |
| 38 chrome::ShowWebDialog(owning_window, | 39 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 39 ProfileManager::GetActiveUserProfile(), | 40 if (owning_window) { |
| 40 new SimDialogDelegate(mode)); | 41 chrome::ShowWebDialog(owning_window, profile, new SimDialogDelegate(mode)); |
| 42 } else { |
| 43 chrome::ShowWebDialogInContainer( |
| 44 SystemTrayClient::GetDialogParentContainerId(), profile, |
| 45 new SimDialogDelegate(mode)); |
| 46 } |
| 41 } | 47 } |
| 42 | 48 |
| 43 SimDialogDelegate::SimDialogDelegate(SimDialogMode dialog_mode) | 49 SimDialogDelegate::SimDialogDelegate(SimDialogMode dialog_mode) |
| 44 : dialog_mode_(dialog_mode) { | 50 : dialog_mode_(dialog_mode) { |
| 45 } | 51 } |
| 46 | 52 |
| 47 SimDialogDelegate::~SimDialogDelegate() { | 53 SimDialogDelegate::~SimDialogDelegate() { |
| 48 } | 54 } |
| 49 | 55 |
| 50 ui::ModalType SimDialogDelegate::GetDialogModalType() const { | 56 ui::ModalType SimDialogDelegate::GetDialogModalType() const { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 return false; | 114 return false; |
| 109 } | 115 } |
| 110 | 116 |
| 111 bool SimDialogDelegate::HandleContextMenu( | 117 bool SimDialogDelegate::HandleContextMenu( |
| 112 const content::ContextMenuParams& params) { | 118 const content::ContextMenuParams& params) { |
| 113 // Disable context menu. | 119 // Disable context menu. |
| 114 return true; | 120 return true; |
| 115 } | 121 } |
| 116 | 122 |
| 117 } // namespace chromeos | 123 } // namespace chromeos |
| OLD | NEW |