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