Skip to content

Commit

Permalink
Replace more hardcoded "ash" strings with ash::mojom::kServiceName
Browse files Browse the repository at this point in the history
The ash::mojom::kServiceName constant was introduced in [1] and replaced
some of the hardcoded "ash" strings. This CL finishes that work. It also
removes the ash_util::GetAshServiceName helper function and replaced it
with direct use of ash::mojom::kServiceName.

[1] https://codereview.chromium.org/2710673002/

BUG=697053

Review-Url: https://codereview.chromium.org/2718043002
Cr-Commit-Position: refs/heads/master@{#453636}
  • Loading branch information
fred-wang authored and Commit bot committed Feb 28, 2017
1 parent 7280d1c commit 02332db
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 40 deletions.
4 changes: 2 additions & 2 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/tracing/chrome_tracing_delegate.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/blocked_content/blocked_window_params.h"
#include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
#include "chrome/browser/ui/browser_navigator.h"
Expand Down Expand Up @@ -218,6 +217,7 @@
#elif defined(OS_MACOSX)
#include "chrome/browser/chrome_browser_main_mac.h"
#elif defined(OS_CHROMEOS)
#include "ash/public/interfaces/constants.mojom.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_backend_delegate.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_delegate.h"
Expand Down Expand Up @@ -3245,7 +3245,7 @@ void ChromeContentBrowserClient::RegisterInProcessServices(
content::ServiceInfo info;
info.factory = base::Bind(&ash_util::CreateEmbeddedAshService,
base::ThreadTaskRunnerHandle::Get());
services->insert(std::make_pair("ash", info));
services->insert(std::make_pair(ash::mojom::kServiceName, info));
}
#endif // OS_CHROMEOS
}
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/chromeos/locale_change_guard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <algorithm>

#include "ash/public/interfaces/constants.mojom.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
Expand All @@ -15,7 +16,6 @@
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/common/pref_names.h"
Expand Down Expand Up @@ -72,8 +72,7 @@ void LocaleChangeGuard::ConnectToLocaleNotificationController() {
if (!connector)
return;

connector->BindInterface(ash_util::GetAshServiceName(),
&notification_controller_);
connector->BindInterface(ash::mojom::kServiceName, &notification_controller_);
}

void LocaleChangeGuard::RevertLocaleChange() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ash/common/ash_constants.h"
#include "ash/common/wallpaper/wallpaper_controller.h"
#include "ash/common/wm_shell.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
Expand Down Expand Up @@ -205,8 +206,7 @@ void SetWallpaper(const gfx::ImageSkia& image,
return;

ash::mojom::WallpaperControllerPtr wallpaper_controller;
connector->BindInterface(ash_util::GetAshServiceName(),
&wallpaper_controller);
connector->BindInterface(ash::mojom::kServiceName, &wallpaper_controller);
// TODO(crbug.com/655875): Optimize ash wallpaper transport; avoid sending
// large bitmaps over Mojo; use shared memory like BitmapUploader, etc.
wallpaper_controller->SetWallpaper(*image.bitmap(), layout);
Expand Down Expand Up @@ -888,7 +888,7 @@ WallpaperManager::WallpaperManager()
if (connection && connection->GetConnector()) {
// Connect to the wallpaper controller interface in the ash service.
ash::mojom::WallpaperControllerPtr wallpaper_controller_ptr;
connection->GetConnector()->BindInterface(ash_util::GetAshServiceName(),
connection->GetConnector()->BindInterface(ash::mojom::kServiceName,
&wallpaper_controller_ptr);
// Register this object as the wallpaper picker.
wallpaper_controller_ptr->SetWallpaperPicker(
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/settings/shutdown_policy_forwarder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include "chrome/browser/chromeos/settings/shutdown_policy_forwarder.h"

#include "ash/public/interfaces/constants.mojom.h"
#include "ash/public/interfaces/shutdown.mojom.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"

Expand All @@ -25,7 +25,7 @@ void ShutdownPolicyForwarder::OnShutdownPolicyChanged(bool reboot_on_shutdown) {
ash::mojom::ShutdownControllerPtr shutdown_controller;
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ash_util::GetAshServiceName(), &shutdown_controller);
->BindInterface(ash::mojom::kServiceName, &shutdown_controller);

// Forward the setting to ash.
shutdown_controller->SetRebootOnShutdown(reboot_on_shutdown);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/app_list/app_list_presenter_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h"

#include "ash/public/interfaces/constants.mojom.h"
#include "chrome/browser/ui/ash/app_list/app_list_service_ash.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/app_list/presenter/app_list_presenter_impl.h"
Expand All @@ -16,7 +16,7 @@ AppListPresenterService::AppListPresenterService() : binding_(this) {
if (connection && connection->GetConnector()) {
// Connect to the app list interface in the ash service.
app_list::mojom::AppListPtr app_list_ptr;
connection->GetConnector()->BindInterface(ash_util::GetAshServiceName(),
connection->GetConnector()->BindInterface(ash::mojom::kServiceName,
&app_list_ptr);
// Register this object as the app list presenter.
app_list_ptr->SetAppListPresenter(binding_.CreateInterfacePtrAndBind());
Expand Down
5 changes: 0 additions & 5 deletions chrome/browser/ui/ash/ash_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ class EmbeddedAshService : public service_manager::Service {

} // namespace

// TODO(rockot): Remove this.
const char* GetAshServiceName() {
return "ash";
}

std::unique_ptr<service_manager::Service> CreateEmbeddedAshService(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
return base::MakeUnique<EmbeddedAshService>(task_runner);
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/ui/ash/ash_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class Accelerator;

namespace ash_util {

// Returns the name of the ash service depending on whether the browser is
// running in classic ash or mash.
const char* GetAshServiceName();

// Creates an in-process Service instance of which can host common ash
// interfaces.
std::unique_ptr<service_manager::Service> CreateEmbeddedAshService(
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/cast_config_client_media_router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <utility>
#include <vector>

#include "ash/public/interfaces/constants.mojom.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/optional.h"
Expand All @@ -21,7 +22,6 @@
#include "chrome/browser/media/router/media_sinks_observer.h"
#include "chrome/browser/media/router/media_source_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
Expand Down Expand Up @@ -151,7 +151,7 @@ CastConfigClientMediaRouter::CastConfigClientMediaRouter() : binding_(this) {
// client.
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ash_util::GetAshServiceName(), &cast_config_);
->BindInterface(ash::mojom::kServiceName, &cast_config_);

// Register this object as the client interface implementation.
ash::mojom::CastConfigClientAssociatedPtrInfo ptr_info;
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/ui/ash/chrome_new_window_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include "chrome/browser/ui/ash/chrome_new_window_client.h"

#include "ash/content/keyboard_overlay/keyboard_overlay_view.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/ash/chrome_shell_delegate.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
Expand Down Expand Up @@ -61,8 +61,7 @@ Browser* ChromeNewWindowClient::GetActiveBrowser() {
ChromeNewWindowClient::ChromeNewWindowClient() : binding_(this) {
service_manager::Connector* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
connector->BindInterface(ash_util::GetAshServiceName(),
&new_window_controller_);
connector->BindInterface(ash::mojom::kServiceName, &new_window_controller_);

// Register this object as the client interface implementation.
ash::mojom::NewWindowClientAssociatedPtrInfo ptr_info;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"

#include "ash/public/interfaces/constants.mojom.h"
#include "base/auto_reset.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/extensions/extension_app_icon_loader.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
#include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
#include "content/public/common/service_manager_connection.h"
Expand Down Expand Up @@ -57,7 +57,7 @@ bool ChromeLauncherController::ConnectToShelfController() {
if (!connector)
return false;

connector->BindInterface(ash_util::GetAshServiceName(), &shelf_controller_);
connector->BindInterface(ash::mojom::kServiceName, &shelf_controller_);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/media_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/ui/ash/media_client.h"

#include "ash/public/interfaces/constants.mojom.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
Expand All @@ -13,7 +14,6 @@
#include "chrome/browser/chromeos/extensions/media_player_event_router.h"
#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/ash/chrome_shell_content_state.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
Expand Down Expand Up @@ -132,7 +132,7 @@ MediaClient::MediaClient() : binding_(this), weak_ptr_factory_(this) {

service_manager::Connector* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
connector->BindInterface(ash_util::GetAshServiceName(), &media_controller_);
connector->BindInterface(ash::mojom::kServiceName, &media_controller_);

// Register this object as the client interface implementation.
ash::mojom::MediaClientAssociatedPtrInfo ptr_info;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/session_controller_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#include <utility>

#include "ash/public/cpp/session_types.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/ash/multi_user/user_switch_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/theme_resources.h"
Expand Down Expand Up @@ -246,7 +246,7 @@ void SessionControllerClient::OnSessionStateChanged() {
void SessionControllerClient::ConnectToSessionControllerAndSetClient() {
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ash_util::GetAshServiceName(), &session_controller_);
->BindInterface(ash::mojom::kServiceName, &session_controller_);

// Set as |session_controller_|'s client.
session_controller_->SetClient(binding_.CreateInterfacePtrAndBind());
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/ui/ash/system_tray_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ash/common/login_status.h"
#include "ash/common/wm_shell.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/shell.h"
#include "base/feature_list.h"
#include "base/logging.h"
Expand Down Expand Up @@ -86,7 +87,7 @@ ash::mojom::UpdateSeverity GetUpdateSeverity(UpgradeDetector* detector) {
SystemTrayClient::SystemTrayClient() : binding_(this) {
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ash_util::GetAshServiceName(), &system_tray_);
->BindInterface(ash::mojom::kServiceName, &system_tray_);
// Register this object as the client interface implementation.
system_tray_->SetClient(binding_.CreateInterfacePtrAndBind());

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/volume_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "chrome/browser/ui/ash/volume_controller.h"

#include "ash/public/interfaces/accelerator_controller.mojom.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/command_line.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/grit/browser_resources.h"
#include "chromeos/audio/chromeos_sounds.h"
#include "chromeos/audio/cras_audio_handler.h"
Expand Down Expand Up @@ -42,7 +42,7 @@ VolumeController::VolumeController() : binding_(this) {
service_manager::Connector* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
ash::mojom::AcceleratorControllerPtr accelerator_controller_ptr;
connector->BindInterface(ash_util::GetAshServiceName(),
connector->BindInterface(ash::mojom::kServiceName,
&accelerator_controller_ptr);

// Register this object as the volume controller.
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/vpn_list_forwarder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/ui/ash/vpn_list_forwarder.h"

#include "ash/public/interfaces/constants.mojom.h"
#include "ash/public/interfaces/vpn_list.mojom.h"
#include "base/bind.h"
#include "base/location.h"
Expand All @@ -12,7 +13,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_service.h"
Expand Down Expand Up @@ -46,7 +46,7 @@ ash::mojom::VpnListPtr ConnectToVpnList() {
ash::mojom::VpnListPtr vpn_list;
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ash_util::GetAshServiceName(), &vpn_list);
->BindInterface(ash::mojom::kServiceName, &vpn_list);
return vpn_list;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ash/common/session/session_state_delegate.h"
#include "ash/common/system/chromeos/devicetype_utils.h"
#include "ash/common/wm_shell.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/shell.h"
#include "ash/wm/lock_state_controller.h"
#include "base/bind.h"
Expand Down Expand Up @@ -62,7 +63,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/signin/easy_unlock_service.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
Expand Down Expand Up @@ -336,7 +336,7 @@ SigninScreenHandler::SigninScreenHandler(

content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ash_util::GetAshServiceName(), &touch_view_manager_ptr_);
->BindInterface(ash::mojom::kServiceName, &touch_view_manager_ptr_);
touch_view_manager_ptr_->AddObserver(
touch_view_binding_.CreateInterfacePtrAndBind());
}
Expand Down
3 changes: 2 additions & 1 deletion mash/package/mash_packaged_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#if defined(OS_CHROMEOS)
#include "ash/autoclick/mus/autoclick_application.h" // nogncheck
#include "ash/mus/window_manager_application.h" // nogncheck
#include "ash/public/interfaces/constants.mojom.h" // nogncheck
#include "ash/touch_hud/mus/touch_hud_application.h" // nogncheck
#endif

Expand Down Expand Up @@ -84,7 +85,7 @@ std::unique_ptr<service_manager::Service> MashPackagedService::CreateService(
}

#if defined(OS_CHROMEOS)
if (name == "ash")
if (name == ash::mojom::kServiceName)
return base::WrapUnique(new ash::mus::WindowManagerApplication);
if (name == "accessibility_autoclick")
return base::WrapUnique(new ash::autoclick::AutoclickApplication);
Expand Down

0 comments on commit 02332db

Please sign in to comment.