OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/network_selection_view.h" | 5 #include "chrome/browser/chromeos/login/network_selection_view.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
12 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/chromeos/login/helper.h" | 14 #include "chrome/browser/chromeos/login/helper.h" |
15 #include "chrome/browser/chromeos/login/keyboard_switch_menu.h" | 15 #include "chrome/browser/chromeos/login/keyboard_switch_menu.h" |
16 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 16 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
17 #include "chrome/browser/chromeos/login/network_screen_delegate.h" | 17 #include "chrome/browser/chromeos/login/network_screen_delegate.h" |
| 18 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
18 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 19 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
19 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" | 20 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" |
20 #include "chrome/browser/chromeos/status/network_dropdown_button.h" | 21 #include "chrome/browser/chromeos/status/network_dropdown_button.h" |
21 #include "gfx/size.h" | 22 #include "gfx/size.h" |
22 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
24 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
25 #include "views/controls/button/native_button.h" | 26 #include "views/controls/button/native_button.h" |
26 #include "views/controls/label.h" | 27 #include "views/controls/label.h" |
27 #include "views/controls/throbber.h" | 28 #include "views/controls/throbber.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // Vertical addition to the menu window to make it appear exactly below | 75 // Vertical addition to the menu window to make it appear exactly below |
75 // MenuButton. | 76 // MenuButton. |
76 const int kMenuVerticalOffset = -1; | 77 const int kMenuVerticalOffset = -1; |
77 | 78 |
78 // Offset that compensates menu width so that it matches | 79 // Offset that compensates menu width so that it matches |
79 // menu button visual width when being in pushed state. | 80 // menu button visual width when being in pushed state. |
80 const int kMenuWidthOffset = 6; | 81 const int kMenuWidthOffset = 6; |
81 | 82 |
82 const SkColor kWelcomeColor = 0xFFCDD3D6; | 83 const SkColor kWelcomeColor = 0xFFCDD3D6; |
83 | 84 |
84 // Hints for size of proxy settings dialog. | |
85 static const int kProxySettingsDialogReasonableWidth = 750; | |
86 static const int kProxySettingsDialogReasonableHeight = 460; | |
87 static const int kProxySettingsDialogReasonableWidthRatio = 0.4; | |
88 static const int kProxySettingsDialogReasonableHeightRatio = 0.4; | |
89 | |
90 // Initializes menu button default properties. | 85 // Initializes menu button default properties. |
91 static void InitMenuButtonProperties(views::MenuButton* menu_button) { | 86 static void InitMenuButtonProperties(views::MenuButton* menu_button) { |
92 menu_button->SetFocusable(true); | 87 menu_button->SetFocusable(true); |
93 menu_button->SetNormalHasBorder(true); | 88 menu_button->SetNormalHasBorder(true); |
94 menu_button->SetEnabledColor(SK_ColorBLACK); | 89 menu_button->SetEnabledColor(SK_ColorBLACK); |
95 menu_button->SetHighlightColor(SK_ColorBLACK); | 90 menu_button->SetHighlightColor(SK_ColorBLACK); |
96 menu_button->SetHoverColor(SK_ColorBLACK); | 91 menu_button->SetHoverColor(SK_ColorBLACK); |
97 menu_button->set_animate_on_state_change(false); | 92 menu_button->set_animate_on_state_change(false); |
98 // Menu is positioned by bottom right corner of the MenuButton. | 93 // Menu is positioned by bottom right corner of the MenuButton. |
99 menu_button->set_menu_offset(kMenuHorizontalOffset, kMenuVerticalOffset); | 94 menu_button->set_menu_offset(kMenuHorizontalOffset, kMenuVerticalOffset); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 bool NetworkSelectionView::IsContinueEnabled() const { | 427 bool NetworkSelectionView::IsContinueEnabled() const { |
433 return continue_button_ && continue_button_->IsEnabled(); | 428 return continue_button_ && continue_button_->IsEnabled(); |
434 } | 429 } |
435 | 430 |
436 //////////////////////////////////////////////////////////////////////////////// | 431 //////////////////////////////////////////////////////////////////////////////// |
437 // views::LinkController implementation: | 432 // views::LinkController implementation: |
438 | 433 |
439 void NetworkSelectionView::LinkActivated(views::Link* source, int) { | 434 void NetworkSelectionView::LinkActivated(views::Link* source, int) { |
440 if (source == proxy_settings_link_) { | 435 if (source == proxy_settings_link_) { |
441 if (!proxy_settings_dialog_.get()) { | 436 if (!proxy_settings_dialog_.get()) { |
442 static const char kProxySettingsURL[] = | 437 proxy_settings_dialog_.reset( |
443 "chrome://settings/proxy?menu=off"; | 438 new ProxySettingsDialog(this, GetNativeWindow())); |
444 proxy_settings_dialog_.reset(new LoginHtmlDialog( | |
445 this, | |
446 GetNativeWindow(), | |
447 std::wstring(), | |
448 GURL(kProxySettingsURL), | |
449 LoginHtmlDialog::STYLE_BUBBLE)); | |
450 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); | |
451 proxy_settings_dialog_->SetDialogSize( | |
452 std::min( | |
453 screen_bounds.width(), | |
454 std::max(kProxySettingsDialogReasonableWidth, static_cast<int>( | |
455 kProxySettingsDialogReasonableWidthRatio * | |
456 screen_bounds.width()))), | |
457 std::min( | |
458 screen_bounds.height(), | |
459 std::max(kProxySettingsDialogReasonableHeight, static_cast<int>( | |
460 kProxySettingsDialogReasonableHeightRatio * | |
461 screen_bounds.height())))); | |
462 } | 439 } |
463 proxy_settings_dialog_->Show(); | 440 proxy_settings_dialog_->Show(); |
464 } | 441 } |
465 } | 442 } |
466 | 443 |
467 //////////////////////////////////////////////////////////////////////////////// | 444 //////////////////////////////////////////////////////////////////////////////// |
468 // NetworkSelectionView, private: | 445 // NetworkSelectionView, private: |
469 | 446 |
470 void NetworkSelectionView::RecreateNativeControls() { | 447 void NetworkSelectionView::RecreateNativeControls() { |
471 // There is no way to get native button preferred size after the button was | 448 // There is no way to get native button preferred size after the button was |
472 // sized so delete and recreate the button on text update. | 449 // sized so delete and recreate the button on text update. |
473 bool is_continue_enabled = IsContinueEnabled(); | 450 bool is_continue_enabled = IsContinueEnabled(); |
474 delete continue_button_; | 451 delete continue_button_; |
475 continue_button_ = new views::NativeButton( | 452 continue_button_ = new views::NativeButton( |
476 delegate_, | 453 delegate_, |
477 l10n_util::GetString(IDS_NETWORK_SELECTION_CONTINUE_BUTTON)); | 454 l10n_util::GetString(IDS_NETWORK_SELECTION_CONTINUE_BUTTON)); |
478 continue_button_->SetEnabled(is_continue_enabled); | 455 continue_button_->SetEnabled(is_continue_enabled); |
479 } | 456 } |
480 | 457 |
481 void NetworkSelectionView::UpdateConnectingNetworkLabel() { | 458 void NetworkSelectionView::UpdateConnectingNetworkLabel() { |
482 connecting_network_label_->SetText(l10n_util::GetStringF( | 459 connecting_network_label_->SetText(l10n_util::GetStringF( |
483 IDS_NETWORK_SELECTION_CONNECTING, UTF16ToWide(network_id_))); | 460 IDS_NETWORK_SELECTION_CONNECTING, UTF16ToWide(network_id_))); |
484 } | 461 } |
485 | 462 |
486 } // namespace chromeos | 463 } // namespace chromeos |
OLD | NEW |