| 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/ui/webui/chromeos/mobile_setup_dialog.h" | 5 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_shutdown.h" | 11 #include "chrome/browser/browser_shutdown.h" |
| 12 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 12 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 14 #include "chrome/browser/chromeos/mobile/mobile_activator.h" | 14 #include "chrome/browser/chromeos/mobile/mobile_activator.h" |
| 15 #include "chrome/browser/platform_util.h" | 15 #include "chrome/browser/platform_util.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/ui/browser_dialogs.h" | 17 #include "chrome/browser/ui/browser_dialogs.h" |
| 18 #include "chrome/browser/ui/simple_message_box.h" | 18 #include "chrome/browser/ui/simple_message_box.h" |
| 19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 68 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 69 MobileSetupDialogDelegate::GetInstance()->ShowDialog(service_path); | 69 MobileSetupDialogDelegate::GetInstance()->ShowDialog(service_path); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // static | 72 // static |
| 73 MobileSetupDialogDelegate* MobileSetupDialogDelegate::GetInstance() { | 73 MobileSetupDialogDelegate* MobileSetupDialogDelegate::GetInstance() { |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 74 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 75 return base::Singleton<MobileSetupDialogDelegate>::get(); | 75 return base::Singleton<MobileSetupDialogDelegate>::get(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 MobileSetupDialogDelegate::MobileSetupDialogDelegate() : dialog_window_(NULL) { | 78 MobileSetupDialogDelegate::MobileSetupDialogDelegate() |
| 79 } | 79 : dialog_window_(nullptr) {} |
| 80 | 80 |
| 81 MobileSetupDialogDelegate::~MobileSetupDialogDelegate() { | 81 MobileSetupDialogDelegate::~MobileSetupDialogDelegate() { |
| 82 } | 82 } |
| 83 | 83 |
| 84 void MobileSetupDialogDelegate::ShowDialog(const std::string& service_path) { | 84 void MobileSetupDialogDelegate::ShowDialog(const std::string& service_path) { |
| 85 service_path_ = service_path; | 85 service_path_ = service_path; |
| 86 | 86 |
| 87 gfx::NativeWindow parent = NULL; | 87 gfx::NativeWindow parent = nullptr; |
| 88 // If we're on the login screen. | 88 // If we're on the login screen. |
| 89 if (chromeos::LoginDisplayHostImpl::default_host()) { | 89 if (chromeos::LoginDisplayHost::default_host()) { |
| 90 chromeos::LoginDisplayHostImpl* webui_host = | 90 chromeos::WebUILoginView* login_view = |
| 91 static_cast<chromeos::LoginDisplayHostImpl*>( | 91 chromeos::LoginDisplayHost::default_host()->GetWebUILoginView(); |
| 92 chromeos::LoginDisplayHostImpl::default_host()); | |
| 93 chromeos::WebUILoginView* login_view = webui_host->GetWebUILoginView(); | |
| 94 if (login_view) | 92 if (login_view) |
| 95 parent = login_view->GetNativeWindow(); | 93 parent = login_view->GetNativeWindow(); |
| 96 } | 94 } |
| 97 // Only the primary user can change this. | 95 // Only the primary user can change this. |
| 98 dialog_window_ = chrome::ShowWebDialog( | 96 dialog_window_ = chrome::ShowWebDialog( |
| 99 parent, | 97 parent, |
| 100 ProfileManager::GetPrimaryUserProfile(), | 98 ProfileManager::GetPrimaryUserProfile(), |
| 101 this); | 99 this); |
| 102 } | 100 } |
| 103 | 101 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 121 | 119 |
| 122 void MobileSetupDialogDelegate::GetDialogSize(gfx::Size* size) const { | 120 void MobileSetupDialogDelegate::GetDialogSize(gfx::Size* size) const { |
| 123 size->SetSize(850, 650); | 121 size->SetSize(850, 650); |
| 124 } | 122 } |
| 125 | 123 |
| 126 std::string MobileSetupDialogDelegate::GetDialogArgs() const { | 124 std::string MobileSetupDialogDelegate::GetDialogArgs() const { |
| 127 return std::string(); | 125 return std::string(); |
| 128 } | 126 } |
| 129 | 127 |
| 130 void MobileSetupDialogDelegate::OnDialogClosed(const std::string& json_retval) { | 128 void MobileSetupDialogDelegate::OnDialogClosed(const std::string& json_retval) { |
| 131 dialog_window_ = NULL; | 129 dialog_window_ = nullptr; |
| 132 } | 130 } |
| 133 | 131 |
| 134 void MobileSetupDialogDelegate::OnCloseContents(WebContents* source, | 132 void MobileSetupDialogDelegate::OnCloseContents(WebContents* source, |
| 135 bool* out_close_dialog) { | 133 bool* out_close_dialog) { |
| 136 // If we're exiting, popping up the confirmation dialog can cause a | 134 // If we're exiting, popping up the confirmation dialog can cause a |
| 137 // crash. Note: IsTryingToQuit can be cancelled on other platforms by the | 135 // crash. Note: IsTryingToQuit can be cancelled on other platforms by the |
| 138 // onbeforeunload handler, except on ChromeOS. So IsTryingToQuit is the | 136 // onbeforeunload handler, except on ChromeOS. So IsTryingToQuit is the |
| 139 // appropriate check to use here. | 137 // appropriate check to use here. |
| 140 if (!dialog_window_ || | 138 if (!dialog_window_ || |
| 141 !MobileActivator::GetInstance()->RunningActivation() || | 139 !MobileActivator::GetInstance()->RunningActivation() || |
| 142 browser_shutdown::IsTryingToQuit()) { | 140 browser_shutdown::IsTryingToQuit()) { |
| 143 *out_close_dialog = true; | 141 *out_close_dialog = true; |
| 144 return; | 142 return; |
| 145 } | 143 } |
| 146 | 144 |
| 147 *out_close_dialog = chrome::ShowMessageBox(dialog_window_, | 145 *out_close_dialog = chrome::ShowMessageBox(dialog_window_, |
| 148 l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE), | 146 l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE), |
| 149 l10n_util::GetStringUTF16(IDS_MOBILE_CANCEL_ACTIVATION), | 147 l10n_util::GetStringUTF16(IDS_MOBILE_CANCEL_ACTIVATION), |
| 150 chrome::MESSAGE_BOX_TYPE_QUESTION); | 148 chrome::MESSAGE_BOX_TYPE_QUESTION); |
| 151 } | 149 } |
| 152 | 150 |
| 153 bool MobileSetupDialogDelegate::ShouldShowDialogTitle() const { | 151 bool MobileSetupDialogDelegate::ShouldShowDialogTitle() const { |
| 154 return true; | 152 return true; |
| 155 } | 153 } |
| 156 | 154 |
| 157 bool MobileSetupDialogDelegate::HandleContextMenu( | 155 bool MobileSetupDialogDelegate::HandleContextMenu( |
| 158 const content::ContextMenuParams& params) { | 156 const content::ContextMenuParams& params) { |
| 159 return true; | 157 return true; |
| 160 } | 158 } |
| OLD | NEW |