Skip to content

Commit

Permalink
Remove an ash reference from chrome://settings
Browse files Browse the repository at this point in the history
Bug: 756095
Change-Id: Ic0519eb868b675bb825de62c062477bd6ce2442b
Reviewed-on: https://chromium-review.googlesource.com/696034
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#507596}
  • Loading branch information
Evan Stade authored and Commit Bot committed Oct 10, 2017
1 parent e068ddc commit 48768f4
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 23 deletions.
3 changes: 2 additions & 1 deletion ash/mojo_interface_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ash/login/lock_screen_controller.h"
#include "ash/media_controller.h"
#include "ash/new_window_controller.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/session/session_controller.h"
#include "ash/shelf/shelf_controller.h"
#include "ash/shell.h"
Expand Down Expand Up @@ -146,7 +147,7 @@ void RegisterInterfaces(
registry->AddInterface(
base::Bind(&BindNewWindowControllerRequestOnMainThread),
main_thread_task_runner);
if (NightLightController::IsFeatureEnabled()) {
if (switches::IsNightLightEnabled()) {
registry->AddInterface(
base::Bind(&BindNightLightControllerRequestOnMainThread),
main_thread_task_runner);
Expand Down
7 changes: 7 additions & 0 deletions ash/public/cpp/ash_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "ash/public/cpp/ash_switches.h"

#include "base/command_line.h"

namespace ash {
namespace switches {

Expand Down Expand Up @@ -147,5 +149,10 @@ const char kSpuriousPowerButtonLidAngleChange[] =
// enables the IME service (i.e. InputMethodMus) instead.
const char kUseIMEService[] = "use-ime-service";

bool IsNightLightEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
kAshEnableNightLight);
}

} // namespace switches
} // namespace ash
2 changes: 2 additions & 0 deletions ash/public/cpp/ash_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ ASH_PUBLIC_EXPORT extern const char kSpuriousPowerButtonKeyboardAccel[];
ASH_PUBLIC_EXPORT extern const char kSpuriousPowerButtonLidAngleChange[];
ASH_PUBLIC_EXPORT extern const char kUseIMEService[];

ASH_PUBLIC_EXPORT bool IsNightLightEnabled();

} // namespace switches
} // namespace ash

Expand Down
4 changes: 2 additions & 2 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ bool Shell::ShouldSaveDisplaySettings() {
}

NightLightController* Shell::night_light_controller() {
DCHECK(NightLightController::IsFeatureEnabled());
DCHECK(switches::IsNightLightEnabled());
return night_light_controller_.get();
}

Expand Down Expand Up @@ -843,7 +843,7 @@ Shell::~Shell() {
void Shell::Init(const ShellInitParams& init_params) {
const Config config = shell_port_->GetAshConfig();

if (NightLightController::IsFeatureEnabled())
if (switches::IsNightLightEnabled())
night_light_controller_ = std::make_unique<NightLightController>();

touch_devices_controller_ = std::make_unique<TouchDevicesController>();
Expand Down
7 changes: 0 additions & 7 deletions ash/system/night_light/night_light_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "ash/public/cpp/ash_switches.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "base/command_line.h"
#include "base/i18n/time_formatting.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
Expand Down Expand Up @@ -131,12 +130,6 @@ NightLightController::~NightLightController() {
Shell::Get()->session_controller()->RemoveObserver(this);
}

// static
bool NightLightController::IsFeatureEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
ash::switches::kAshEnableNightLight);
}

// static
void NightLightController::RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kNightLightEnabled, false,
Expand Down
3 changes: 0 additions & 3 deletions ash/system/night_light/night_light_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ class ASH_EXPORT NightLightController : public mojom::NightLightController,
NightLightController();
~NightLightController() override;

// Returns true if the NightLight feature is enabled in the flags.
static bool IsFeatureEnabled();

static void RegisterProfilePrefs(PrefRegistrySimple* registry);

AnimationDuration animation_duration() const { return animation_duration_; }
Expand Down
3 changes: 2 additions & 1 deletion ash/system/night_light/night_light_toggle_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ash/system/night_light/night_light_toggle_button.h"

#include "ash/public/cpp/ash_switches.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/night_light/night_light_controller.h"
Expand Down Expand Up @@ -56,7 +57,7 @@ NightLightToggleButton::NightLightToggleButton(views::ButtonListener* listener)
}

void NightLightToggleButton::Toggle() {
DCHECK(NightLightController::IsFeatureEnabled());
DCHECK(switches::IsNightLightEnabled());
Shell::Get()->night_light_controller()->Toggle();
Update();
NotifyAccessibilityEvent(ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED, true);
Expand Down
6 changes: 3 additions & 3 deletions ash/system/tiles/tiles_default_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ash/metrics/user_metrics_action.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
Expand Down Expand Up @@ -87,7 +88,7 @@ void TilesDefaultView::Init() {
AddChildView(help_button_);
AddChildView(TrayPopupUtils::CreateVerticalSeparator());

if (NightLightController::IsFeatureEnabled()) {
if (switches::IsNightLightEnabled()) {
night_light_button_ = new NightLightToggleButton(this);
night_light_button_->SetEnabled(can_show_web_ui);
AddChildView(night_light_button_);
Expand Down Expand Up @@ -123,8 +124,7 @@ void TilesDefaultView::ButtonPressed(views::Button* sender,
} else if (sender == help_button_) {
Shell::Get()->metrics()->RecordUserMetricsAction(UMA_TRAY_HELP);
Shell::Get()->system_tray_controller()->ShowHelp();
} else if (NightLightController::IsFeatureEnabled() &&
sender == night_light_button_) {
} else if (switches::IsNightLightEnabled() && sender == night_light_button_) {
Shell::Get()->metrics()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT);
night_light_button_->Toggle();
} else if (sender == lock_button_) {
Expand Down
3 changes: 2 additions & 1 deletion ash/system/tray/system_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "ash/login_status.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/config.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h"
Expand Down Expand Up @@ -314,7 +315,7 @@ void SystemTray::CreateItems() {
AddTrayItem(std::make_unique<TrayKeyboardBrightness>(this));
tray_caps_lock_ = new TrayCapsLock(this);
AddTrayItem(base::WrapUnique(tray_caps_lock_));
if (NightLightController::IsFeatureEnabled()) {
if (switches::IsNightLightEnabled()) {
tray_night_light_ = new TrayNightLight(this);
AddTrayItem(base::WrapUnique(tray_night_light_));
}
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/chrome_browser_main_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,7 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
// fetch of the initial CrosSettings DeviceRebootOnShutdown policy.
shutdown_policy_forwarder_ = base::MakeUnique<ShutdownPolicyForwarder>();

if (base::CommandLine::ForCurrentProcess()->HasSwitch(
ash::switches::kAshEnableNightLight)) {
if (ash::switches::IsNightLightEnabled()) {
night_light_client_ = base::MakeUnique<NightLightClient>(
g_browser_process->system_request_context());
night_light_client_->Start();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/night_light/night_light_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class URLRequestContextGetter;
// NightLightController running in ash.
class NightLightClient : public ash::mojom::NightLightClient {
public:
NightLightClient(net::URLRequestContextGetter* url_context_getter);
explicit NightLightClient(net::URLRequestContextGetter* url_context_getter);
~NightLightClient() override;

// Starts watching changes in the Night Light schedule type in order to begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "ui/base/l10n/l10n_util.h"

#if defined(OS_CHROMEOS)
#include "ash/public/cpp/ash_switches.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/night_light/night_light_controller.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
Expand Down Expand Up @@ -646,7 +646,7 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
chromeos::switches::kEnableTouchCalibrationSetting));

html_source->AddBoolean("nightLightFeatureEnabled",
ash::NightLightController::IsFeatureEnabled());
ash::switches::IsNightLightEnabled());

LocalizedString storage_strings[] = {
{"storageTitle", IDS_SETTINGS_STORAGE_TITLE},
Expand Down

0 comments on commit 48768f4

Please sign in to comment.