| 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.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 "chromeos/network/network_state.h" |
| 22 #include "chromeos/network/network_state_handler.h" |
| 21 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/gfx/geometry/size.h" | 25 #include "ui/gfx/geometry/size.h" |
| 24 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
| 25 #include "ui/web_dialogs/web_dialog_delegate.h" | 27 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 26 | 28 |
| 27 using chromeos::MobileActivator; | 29 using chromeos::MobileActivator; |
| 28 using content::BrowserThread; | 30 using content::BrowserThread; |
| 29 using content::WebContents; | 31 using content::WebContents; |
| 30 using content::WebUIMessageHandler; | 32 using content::WebUIMessageHandler; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 57 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 59 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
| 58 | 60 |
| 59 private: | 61 private: |
| 60 gfx::NativeWindow dialog_window_; | 62 gfx::NativeWindow dialog_window_; |
| 61 // Cellular network service path. | 63 // Cellular network service path. |
| 62 std::string service_path_; | 64 std::string service_path_; |
| 63 DISALLOW_COPY_AND_ASSIGN(MobileSetupDialogDelegate); | 65 DISALLOW_COPY_AND_ASSIGN(MobileSetupDialogDelegate); |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 // static | 68 // static |
| 67 void MobileSetupDialog::Show(const std::string& service_path) { | 69 void MobileSetupDialog::ShowByNetworkId(const std::string& network_id) { |
| 68 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 69 MobileSetupDialogDelegate::GetInstance()->ShowDialog(service_path); | 71 const chromeos::NetworkState* network = |
| 72 chromeos::NetworkHandler::Get() |
| 73 ->network_state_handler() |
| 74 ->GetNetworkStateFromGuid(network_id); |
| 75 if (!network) { |
| 76 LOG(ERROR) << "MobileSetupDialog: Network ID not found: " << network_id; |
| 77 return; |
| 78 } |
| 79 MobileSetupDialogDelegate::GetInstance()->ShowDialog(network->path()); |
| 70 } | 80 } |
| 71 | 81 |
| 72 // static | 82 // static |
| 73 MobileSetupDialogDelegate* MobileSetupDialogDelegate::GetInstance() { | 83 MobileSetupDialogDelegate* MobileSetupDialogDelegate::GetInstance() { |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 84 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 75 return base::Singleton<MobileSetupDialogDelegate>::get(); | 85 return base::Singleton<MobileSetupDialogDelegate>::get(); |
| 76 } | 86 } |
| 77 | 87 |
| 78 MobileSetupDialogDelegate::MobileSetupDialogDelegate() | 88 MobileSetupDialogDelegate::MobileSetupDialogDelegate() |
| 79 : dialog_window_(nullptr) {} | 89 : dialog_window_(nullptr) {} |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 158 } |
| 149 | 159 |
| 150 bool MobileSetupDialogDelegate::ShouldShowDialogTitle() const { | 160 bool MobileSetupDialogDelegate::ShouldShowDialogTitle() const { |
| 151 return true; | 161 return true; |
| 152 } | 162 } |
| 153 | 163 |
| 154 bool MobileSetupDialogDelegate::HandleContextMenu( | 164 bool MobileSetupDialogDelegate::HandleContextMenu( |
| 155 const content::ContextMenuParams& params) { | 165 const content::ContextMenuParams& params) { |
| 156 return true; | 166 return true; |
| 157 } | 167 } |
| OLD | NEW |