| 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/login/proxy_settings_dialog.h" | 5 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/chromeos/login/helper.h" | 10 #include "chrome/browser/chromeos/login/helper.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "chromeos/network/network_state.h" | 12 #include "chromeos/network/network_state.h" |
| 13 #include "chromeos/network/shill_property_util.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 16 #include "net/base/escape.h" | 17 #include "net/base/escape.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 : LoginWebDialog(delegate, | 57 : LoginWebDialog(delegate, |
| 57 window, | 58 window, |
| 58 string16(), | 59 string16(), |
| 59 GetURLForProxySettings(network.path()), | 60 GetURLForProxySettings(network.path()), |
| 60 LoginWebDialog::STYLE_BUBBLE) { | 61 LoginWebDialog::STYLE_BUBBLE) { |
| 61 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 62 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 62 ++instance_count_; | 63 ++instance_count_; |
| 63 | 64 |
| 64 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); | 65 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); |
| 65 SetDialogSize(CalculateSize(screen_bounds.width(), | 66 SetDialogSize(CalculateSize(screen_bounds.width(), |
| 66 kProxySettingsDialogReasonableWidth, | 67 kProxySettingsDialogReasonableWidth, |
| 67 kProxySettingsDialogReasonableWidthRatio), | 68 kProxySettingsDialogReasonableWidthRatio), |
| 68 CalculateSize(screen_bounds.height(), | 69 CalculateSize(screen_bounds.height(), |
| 69 kProxySettingsDialogReasonableHeight, | 70 kProxySettingsDialogReasonableHeight, |
| 70 kProxySettingsDialogReasonableHeightRatio)); | 71 kProxySettingsDialogReasonableHeightRatio)); |
| 71 | 72 |
| 72 std::string network_name = network.name(); | 73 std::string network_name = network.name(); |
| 73 if (network_name.empty() && network.type() == flimflam::kTypeEthernet) { | 74 if (network_name.empty() && network.Matches(NetworkTypePattern::Ethernet())) { |
| 74 network_name = | 75 network_name = |
| 75 l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); | 76 l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); |
| 76 } | 77 } |
| 77 | 78 |
| 78 SetDialogTitle(l10n_util::GetStringFUTF16(IDS_PROXY_PAGE_TITLE_FORMAT, | 79 SetDialogTitle(l10n_util::GetStringFUTF16(IDS_PROXY_PAGE_TITLE_FORMAT, |
| 79 ASCIIToUTF16(network_name))); | 80 ASCIIToUTF16(network_name))); |
| 80 } | 81 } |
| 81 | 82 |
| 82 ProxySettingsDialog::~ProxySettingsDialog() { | 83 ProxySettingsDialog::~ProxySettingsDialog() { |
| 83 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 84 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 84 --instance_count_; | 85 --instance_count_; |
| 85 } | 86 } |
| 86 | 87 |
| 87 void ProxySettingsDialog::OnDialogClosed(const std::string& json_retval) { | 88 void ProxySettingsDialog::OnDialogClosed(const std::string& json_retval) { |
| 88 LoginWebDialog::OnDialogClosed(json_retval); | 89 LoginWebDialog::OnDialogClosed(json_retval); |
| 89 content::NotificationService::current()->Notify( | 90 content::NotificationService::current()->Notify( |
| 90 chrome::NOTIFICATION_LOGIN_PROXY_CHANGED, | 91 chrome::NOTIFICATION_LOGIN_PROXY_CHANGED, |
| 91 content::NotificationService::AllSources(), | 92 content::NotificationService::AllSources(), |
| 92 content::NotificationService::NoDetails()); | 93 content::NotificationService::NoDetails()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 bool ProxySettingsDialog::IsShown() { | 96 bool ProxySettingsDialog::IsShown() { |
| 96 return instance_count_ > 0; | 97 return instance_count_ > 0; |
| 97 } | 98 } |
| 98 | 99 |
| 99 } // namespace chromeos | 100 } // namespace chromeos |
| OLD | NEW |