Commit message: None
CVE: None
Vulnerability description: None

Project: Chrome

void NetworkScreen::ButtonPressed(views::Button* sender,
                                  const views::Event& event) {
  ClearErrors();
  NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary();
  if (network && network->Connected()) {
    NotifyOnConnection();
  } else {
    continue_pressed_ = true;
    WaitForConnection(network_id_);
  }
}

Project: Chrome

void NetworkScreen::ClearErrors() {
  if (bubble_)
    bubble_->Close();
}

Project: Chrome

void NetworkScreen::CreateView() {
  language_switch_menu_.InitLanguageMenu();
  ViewScreen<NetworkSelectionView>::CreateView();
}

Project: Chrome

NetworkScreen::NetworkScreen(WizardScreenDelegate* delegate)
    : ViewScreen<NetworkSelectionView>(delegate,
                                       kWelcomeScreenWidth,
                                       kWelcomeScreenHeight),
      is_network_subscribed_(false),
      continue_pressed_(false),
      bubble_(NULL) {
  language_switch_menu_.set_menu_alignment(views::Menu2::ALIGN_TOPLEFT);
}

Project: Chrome

void NetworkScreen::NotifyOnConnection() {
  UnsubscribeNetworkNotification();
  connection_timer_.Stop();
  delegate()->GetObserver(this)->OnExit(ScreenObserver::NETWORK_CONNECTED);
}

Project: Chrome

void NetworkScreen::OnHelpLinkActivated() {
  ClearErrors();
  if (!help_app_.get())
    help_app_.reset(new HelpAppLauncher(view()->GetNativeWindow()));
  help_app_->ShowHelpTopic(HelpAppLauncher::HELP_CONNECTIVITY);
}

Project: Chrome

void NetworkScreen::OnNetworkManagerChanged(NetworkLibrary* network_lib) {
  UpdateStatus(network_lib);
}

Project: Chrome

void NetworkScreen::Refresh() {
  if (CrosLibrary::Get()->EnsureLoaded()) {
    SubscribeNetworkNotification();
    OnNetworkManagerChanged(chromeos::CrosLibrary::Get()->GetNetworkLibrary());
  }
}

Project: Chrome

void NetworkScreen::StopWaitingForConnection(const string16& network_id) {
  NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary();
  bool is_connected = network && network->Connected();
  if (is_connected && continue_pressed_) {
    NotifyOnConnection();
    return;
  }

  continue_pressed_ = false;
  connection_timer_.Stop();

  network_id_ = network_id;
  view()->ShowConnectingStatus(false, network_id_);
  view()->EnableContinue(is_connected);
}

Project: Chrome

void NetworkScreen::SubscribeNetworkNotification() {
  if (!is_network_subscribed_) {
    is_network_subscribed_ = true;
    chromeos::CrosLibrary::Get()->GetNetworkLibrary()
        ->AddNetworkManagerObserver(this);
  }
}

Project: Chrome

void NetworkScreen::UnsubscribeNetworkNotification() {
  if (is_network_subscribed_) {
    is_network_subscribed_ = false;
    chromeos::CrosLibrary::Get()->GetNetworkLibrary()
        ->RemoveNetworkManagerObserver(this);
  }
}

Project: Chrome

void NetworkScreen::UpdateStatus(NetworkLibrary* network) {
  if (!view() || !network)
    return;

  if (network->Connected())
    ClearErrors();

  if (network->ethernet_connected()) {
    StopWaitingForConnection(
        l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET));
  } else if (network->wifi_connected()) {
    StopWaitingForConnection(ASCIIToUTF16(network->wifi_network()->name()));
  } else if (network->cellular_connected()) {
    StopWaitingForConnection(ASCIIToUTF16(network->cellular_network()->name()));
  } else if (network->ethernet_connecting()) {
    WaitForConnection(
        l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET));
  } else if (network->wifi_connecting()) {
    WaitForConnection(ASCIIToUTF16(network->wifi_network()->name()));
  } else if (network->cellular_connecting()) {
    WaitForConnection(ASCIIToUTF16(network->cellular_network()->name()));
  } else {
    StopWaitingForConnection(network_id_);
  }
}

Project: Chrome

NetworkScreen::~NetworkScreen() {
  connection_timer_.Stop();
  UnsubscribeNetworkNotification();
}