Commit 567bb924 authored by thiago.santos's avatar thiago.santos Committed by Commit bot

This removes an ash dependency from the system.display API in order to move it...

This removes an ash dependency from the system.display API in order to move it to extensions/. As a side effect, we got rid of #ifdefs on system_info_api.cc

BUG=392842

Review URL: https://codereview.chromium.org/507783003

Cr-Commit-Position: refs/heads/master@{#292373}
parent b5d3236c
......@@ -13,6 +13,7 @@
namespace gfx {
class Display;
class Screen;
}
namespace extensions {
......@@ -46,6 +47,10 @@ class DisplayInfoProvider {
const api::system_display::DisplayProperties& info,
std::string* error) = 0;
// Get the screen that is always active, which will be used for monitoring
// display changes events.
virtual gfx::Screen* GetActiveScreen() = 0;
DisplayInfo GetAllDisplaysInfo();
protected:
......
......@@ -131,6 +131,8 @@ class MockDisplayInfoProvider : public DisplayInfoProvider {
return true;
}
virtual gfx::Screen* GetActiveScreen() OVERRIDE { return NULL; }
scoped_ptr<base::DictionaryValue> GetSetInfoValue() {
return set_info_value_.Pass();
}
......
......@@ -13,6 +13,7 @@
#include "base/strings/string_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/system_display/display_info_provider.h"
#include "chrome/browser/extensions/api/system_storage/storage_info_provider.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/common/extensions/api/system_display.h"
......@@ -22,11 +23,7 @@
#include "components/storage_monitor/storage_monitor.h"
#include "content/public/browser/browser_thread.h"
#include "ui/gfx/display_observer.h"
#if defined(OS_CHROMEOS)
#include "ash/shell.h"
#include "ui/gfx/screen.h"
#endif
namespace extensions {
......@@ -39,11 +36,9 @@ namespace system_storage = api::system_storage;
namespace {
#if defined(OS_CHROMEOS)
bool IsDisplayChangedEvent(const std::string& event_name) {
return event_name == system_display::OnDisplayChanged::kEventName;
}
#endif
bool IsSystemStorageEvent(const std::string& event_name) {
return (event_name == system_storage::OnAttached::kEventName ||
......@@ -120,11 +115,11 @@ void SystemInfoEventRouter::AddEventListener(const std::string& event_name) {
if (watching_event_set_.count(event_name) > 1)
return;
// For system.display event.
#if defined(OS_CHROMEOS)
if (IsDisplayChangedEvent(event_name))
ash::Shell::GetScreen()->AddObserver(this);
#endif
if (IsDisplayChangedEvent(event_name)) {
gfx::Screen* screen = DisplayInfoProvider::Get()->GetActiveScreen();
if (screen)
screen->AddObserver(this);
}
if (IsSystemStorageEvent(event_name)) {
if (!has_storage_monitor_observer_) {
......@@ -146,10 +141,11 @@ void SystemInfoEventRouter::RemoveEventListener(const std::string& event_name) {
return;
}
#if defined(OS_CHROMEOS)
if (IsDisplayChangedEvent(event_name))
ash::Shell::GetScreen()->RemoveObserver(this);
#endif
if (IsDisplayChangedEvent(event_name)) {
gfx::Screen* screen = DisplayInfoProvider::Get()->GetActiveScreen();
if (screen)
screen->RemoveObserver(this);
}
if (IsSystemStorageEvent(event_name)) {
const std::string& other_event_name =
......
......@@ -26,6 +26,10 @@ void DisplayInfoProviderAura::UpdateDisplayUnitInfoForPlatform(
NOTIMPLEMENTED();
}
gfx::Screen* DisplayInfoProviderAura::GetActiveScreen() {
return NULL;
}
// static
DisplayInfoProvider* DisplayInfoProvider::Create() {
return new DisplayInfoProviderAura();
......
......@@ -21,6 +21,7 @@ class DisplayInfoProviderAura : public DisplayInfoProvider {
virtual void UpdateDisplayUnitInfoForPlatform(
const gfx::Display& display,
extensions::api::system_display::DisplayUnitInfo* unit) OVERRIDE;
virtual gfx::Screen* GetActiveScreen() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderAura);
......
......@@ -380,6 +380,10 @@ void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform(
unit->overscan.bottom = overscan_insets.bottom();
}
gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() {
return ash::Shell::GetScreen();
}
// static
DisplayInfoProvider* DisplayInfoProvider::Create() {
return new DisplayInfoProviderChromeOS();
......
......@@ -21,6 +21,7 @@ class DisplayInfoProviderChromeOS : public DisplayInfoProvider {
virtual void UpdateDisplayUnitInfoForPlatform(
const gfx::Display& display,
extensions::api::system_display::DisplayUnitInfo* unit) OVERRIDE;
virtual gfx::Screen* GetActiveScreen() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeOS);
......
......@@ -26,6 +26,10 @@ void DisplayInfoProviderMac::UpdateDisplayUnitInfoForPlatform(
NOTIMPLEMENTED();
}
gfx::Screen* DisplayInfoProviderMac::GetActiveScreen() {
return NULL;
}
// static
DisplayInfoProvider* DisplayInfoProvider::Create() {
return new DisplayInfoProviderMac();
......
......@@ -21,6 +21,7 @@ class DisplayInfoProviderMac : public DisplayInfoProvider {
virtual void UpdateDisplayUnitInfoForPlatform(
const gfx::Display& display,
extensions::api::system_display::DisplayUnitInfo* unit) OVERRIDE;
virtual gfx::Screen* GetActiveScreen() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderMac);
......
......@@ -80,6 +80,10 @@ void DisplayInfoProviderWin::UpdateDisplayUnitInfoForPlatform(
}
}
gfx::Screen* DisplayInfoProviderWin::GetActiveScreen() {
return NULL;
}
// static
DisplayInfoProvider* DisplayInfoProvider::Create() {
return new DisplayInfoProviderWin();
......
......@@ -21,6 +21,7 @@ class DisplayInfoProviderWin : public DisplayInfoProvider {
virtual void UpdateDisplayUnitInfoForPlatform(
const gfx::Display& display,
extensions::api::system_display::DisplayUnitInfo* unit) OVERRIDE;
virtual gfx::Screen* GetActiveScreen() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderWin);
......
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