Commit c24f67ea authored by Theo Johnson-kanu's avatar Theo Johnson-kanu Committed by Chromium LUCI CQ

[CrOS cellular] Add 'Add cellular icon' to Quick settings

Screenshot: https://screenshot.googleplex.com/7sot2pkVRoKn5ci.png

- Adds a new system tray icon
- Adds icon as a button to system tray
- No test where added because network_section_header.cc does not
  currently have a test. Test will be added in a subsequent CL

Bug: 1163556
Change-Id: Ia965ec395b83f72b20350851a730f76a392f4669
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622658Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Commit-Queue: Nnamdi Theodore Johnson-kanu <tjohnsonkanu@google.com>
Cr-Commit-Position: refs/heads/master@{#842879}
parent 8812faaa
...@@ -1559,6 +1559,9 @@ This file contains the strings for ash. ...@@ -1559,6 +1559,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_OTHER_WIFI" desc="The label used for the item to display other Wi-Fi networks."> <message name="IDS_ASH_STATUS_TRAY_OTHER_WIFI" desc="The label used for the item to display other Wi-Fi networks.">
Join other Wi-Fi networks Join other Wi-Fi networks
</message> </message>
<message name="IDS_ASH_STATUS_TRAY_ADD_CELLULAR_LABEL" desc="The label for button in network quick settings that allows user to add new cellular networks.">
Add new cellular network
</message>
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE" desc="Notification shown when a Bluetooth adapter is discoverable."> <message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE" desc="Notification shown when a Bluetooth adapter is discoverable.">
Your computer is discoverable to nearby Bluetooth devices and will appear as "<ph name="NAME">$1<ex>Chromebook</ex></ph>" with address <ph name="ADDRESS">$2<ex>01:23:45:67:89:0A</ex></ph> Your computer is discoverable to nearby Bluetooth devices and will appear as "<ph name="NAME">$1<ex>Chromebook</ex></ph>" with address <ph name="ADDRESS">$2<ex>01:23:45:67:89:0A</ex></ph>
</message> </message>
......
d2ef7556e3dca52f809cde1e65d84843f8187cc2
\ No newline at end of file
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ash/system/network/tray_network_state_model.h" #include "ash/system/network/tray_network_state_model.h"
#include "ash/system/unified/top_shortcut_button.h" #include "ash/system/unified/top_shortcut_button.h"
#include "base/bind.h" #include "base/bind.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
#include "chromeos/strings/grit/chromeos_strings.h" #include "chromeos/strings/grit/chromeos_strings.h"
#include "components/onc/onc_constants.h" #include "components/onc/onc_constants.h"
...@@ -274,6 +275,26 @@ void MobileSectionHeaderView::OnToggleToggled(bool is_on) { ...@@ -274,6 +275,26 @@ void MobileSectionHeaderView::OnToggleToggled(bool is_on) {
model()->SetNetworkTypeEnabledState(NetworkType::kTether, is_on); model()->SetNetworkTypeEnabledState(NetworkType::kTether, is_on);
} }
void MobileSectionHeaderView::AddExtraButtons(bool enabled) {
if (!base::FeatureList::IsEnabled(
chromeos::features::kUpdatedCellularActivationUi)) {
return;
}
TopShortcutButton* add_cellular_button = new TopShortcutButton(
base::BindRepeating(&MobileSectionHeaderView::AddCellularButtonPressed,
base::Unretained(this)),
vector_icons::kAddCellularNetworkIcon,
IDS_ASH_STATUS_TRAY_ADD_CELLULAR_LABEL);
add_cellular_button->SetEnabled(enabled);
container()->AddView(TriView::Container::END, add_cellular_button);
}
void MobileSectionHeaderView::AddCellularButtonPressed() {
Shell::Get()->system_tray_model()->client()->ShowNetworkCreate(
::onc::network_type::kCellular);
}
void MobileSectionHeaderView::EnableBluetooth() { void MobileSectionHeaderView::EnableBluetooth() {
DCHECK(!waiting_for_tether_initialize_); DCHECK(!waiting_for_tether_initialize_);
......
...@@ -101,6 +101,9 @@ class MobileSectionHeaderView : public NetworkSectionHeaderView { ...@@ -101,6 +101,9 @@ class MobileSectionHeaderView : public NetworkSectionHeaderView {
private: private:
// NetworkListView::NetworkSectionHeaderView: // NetworkListView::NetworkSectionHeaderView:
void OnToggleToggled(bool is_on) override; void OnToggleToggled(bool is_on) override;
void AddExtraButtons(bool enabled) override;
void AddCellularButtonPressed();
// When Tether is disabled because Bluetooth is off, then enabling Bluetooth // When Tether is disabled because Bluetooth is off, then enabling Bluetooth
// will enable Tether. If enabling Bluetooth takes longer than some timeout // will enable Tether. If enabling Bluetooth takes longer than some timeout
......
...@@ -370,6 +370,11 @@ void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { ...@@ -370,6 +370,11 @@ void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) {
void SystemTrayClient::ShowNetworkCreate(const std::string& type) { void SystemTrayClient::ShowNetworkCreate(const std::string& type) {
if (type == ::onc::network_type::kCellular) { if (type == ::onc::network_type::kCellular) {
if (base::FeatureList::IsEnabled(
chromeos::features::kUpdatedCellularActivationUi)) {
ShowSettingsCellularSetupFlow();
return;
}
const chromeos::NetworkState* cellular = const chromeos::NetworkState* cellular =
chromeos::NetworkHandler::Get() chromeos::NetworkHandler::Get()
->network_state_handler() ->network_state_handler()
...@@ -382,6 +387,13 @@ void SystemTrayClient::ShowNetworkCreate(const std::string& type) { ...@@ -382,6 +387,13 @@ void SystemTrayClient::ShowNetworkCreate(const std::string& type) {
chromeos::InternetConfigDialog::ShowDialogForNetworkType(type); chromeos::InternetConfigDialog::ShowDialogForNetworkType(type);
} }
void SystemTrayClient::ShowSettingsCellularSetupFlow() {
// TODO(crbug.com/1093185) Add metrics action recorder
std::string page = chromeos::settings::mojom::kCellularNetworksSubpagePath;
page += "&showCellularSetup=true";
ShowSettingsSubPageForActiveUser(page);
}
void SystemTrayClient::ShowThirdPartyVpnCreate( void SystemTrayClient::ShowThirdPartyVpnCreate(
const std::string& extension_id) { const std::string& extension_id) {
Profile* profile = ProfileManager::GetPrimaryUserProfile(); Profile* profile = ProfileManager::GetPrimaryUserProfile();
......
...@@ -83,6 +83,9 @@ class SystemTrayClient : public ash::SystemTrayClient, ...@@ -83,6 +83,9 @@ class SystemTrayClient : public ash::SystemTrayClient,
void SetLocaleAndExit(const std::string& locale_iso_code) override; void SetLocaleAndExit(const std::string& locale_iso_code) override;
private: private:
// Opens cellular setup dialog in os settings
void ShowSettingsCellularSetupFlow();
// Helper function shared by ShowNetworkSettings() and ShowNetworkConfigure(). // Helper function shared by ShowNetworkSettings() and ShowNetworkConfigure().
void ShowNetworkSettingsHelper(const std::string& network_id, void ShowNetworkSettingsHelper(const std::string& network_id,
bool show_configure); bool show_configure);
......
...@@ -146,6 +146,7 @@ const string kEthernetDetailsSubpagePath = "networkDetail"; ...@@ -146,6 +146,7 @@ const string kEthernetDetailsSubpagePath = "networkDetail";
const string kWifiNetworksSubpagePath = "networks?type=WiFi"; const string kWifiNetworksSubpagePath = "networks?type=WiFi";
const string kWifiDetailsSubpagePath = "networkDetail"; const string kWifiDetailsSubpagePath = "networkDetail";
const string kKnownNetworksSubpagePath = "knownNetworks"; const string kKnownNetworksSubpagePath = "knownNetworks";
const string kCellularNetworksSubpagePath = "networks?type=Cellular";
const string kMobileDataNetworksSubpagePath = "networks?type=Tether"; const string kMobileDataNetworksSubpagePath = "networks?type=Tether";
const string kCellularDetailsSubpagePath = "networkDetail"; const string kCellularDetailsSubpagePath = "networkDetail";
const string kTetherDetailsSubpagePath = "networkDetail"; const string kTetherDetailsSubpagePath = "networkDetail";
......
...@@ -9,6 +9,7 @@ aggregate_vector_icons("components_vector_icons") { ...@@ -9,6 +9,7 @@ aggregate_vector_icons("components_vector_icons") {
sources = [ sources = [
"accessibility.icon", "accessibility.icon",
"add_cellular_network.icon",
"ads.icon", "ads.icon",
"back_arrow.icon", "back_arrow.icon",
"blocked_badge.icon", "blocked_badge.icon",
......
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 20,
MOVE_TO, 16, 8,
CUBIC_TO, 16.34f, 8, 16.68f, 8.03f, 17, 8.08f,
V_LINE_TO, 5,
CUBIC_TO, 17, 4.11f, 15.92f, 3.66f, 15.29f, 4.29f,
LINE_TO, 4.29f, 15.29f,
CUBIC_TO, 3.66f, 15.92f, 4.11f, 17, 5, 17,
H_LINE_TO, 10.8f,
CUBIC_TO, 10.29f, 16.12f, 10, 15.09f, 10, 14,
CUBIC_TO, 10, 10.69f, 12.69f, 8, 16, 8,
CLOSE,
MOVE_TO, 19, 13,
H_LINE_TO, 17,
V_LINE_TO, 11,
H_LINE_TO, 15,
V_LINE_TO, 13,
H_LINE_TO, 13,
V_LINE_TO, 15,
H_LINE_TO, 15,
V_LINE_TO, 17,
H_LINE_TO, 17,
V_LINE_TO, 15,
H_LINE_TO, 19,
V_LINE_TO, 13,
CLOSE
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment