Commit aab5ac5a authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove using directives ("using namespace x") from components/.

Bug: 82078
Change-Id: I00bb47e46d3d78283a61da88fb34d549d0ff3873
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1818646Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698905}
parent 938cd501
...@@ -21,7 +21,8 @@ using cast_util::StringToEnum; ...@@ -21,7 +21,8 @@ using cast_util::StringToEnum;
namespace cast_util { namespace cast_util {
using namespace cast_channel; using cast_channel::CastMessageType;
using cast_channel::GetAppAvailabilityResult;
template <> template <>
const EnumTable<CastMessageType> EnumTable<CastMessageType>::instance( const EnumTable<CastMessageType> EnumTable<CastMessageType>::instance(
...@@ -45,30 +46,31 @@ const EnumTable<CastMessageType> EnumTable<CastMessageType>::instance( ...@@ -45,30 +46,31 @@ const EnumTable<CastMessageType> EnumTable<CastMessageType>::instance(
CastMessageType::kMaxValue); CastMessageType::kMaxValue);
template <> template <>
const EnumTable<V2MessageType> EnumTable<V2MessageType>::instance( const EnumTable<cast_channel::V2MessageType>
{ EnumTable<cast_channel::V2MessageType>::instance(
{V2MessageType::kEditTracksInfo, "EDIT_TRACKS_INFO"}, {
{V2MessageType::kGetStatus, "GET_STATUS"}, {cast_channel::V2MessageType::kEditTracksInfo, "EDIT_TRACKS_INFO"},
{V2MessageType::kLoad, "LOAD"}, {cast_channel::V2MessageType::kGetStatus, "GET_STATUS"},
{V2MessageType::kMediaGetStatus, "MEDIA_GET_STATUS"}, {cast_channel::V2MessageType::kLoad, "LOAD"},
{V2MessageType::kMediaSetVolume, "MEDIA_SET_VOLUME"}, {cast_channel::V2MessageType::kMediaGetStatus, "MEDIA_GET_STATUS"},
{V2MessageType::kPause, "PAUSE"}, {cast_channel::V2MessageType::kMediaSetVolume, "MEDIA_SET_VOLUME"},
{V2MessageType::kPlay, "PLAY"}, {cast_channel::V2MessageType::kPause, "PAUSE"},
{V2MessageType::kPrecache, "PRECACHE"}, {cast_channel::V2MessageType::kPlay, "PLAY"},
{V2MessageType::kQueueInsert, "QUEUE_INSERT"}, {cast_channel::V2MessageType::kPrecache, "PRECACHE"},
{V2MessageType::kQueueLoad, "QUEUE_LOAD"}, {cast_channel::V2MessageType::kQueueInsert, "QUEUE_INSERT"},
{V2MessageType::kQueueRemove, "QUEUE_REMOVE"}, {cast_channel::V2MessageType::kQueueLoad, "QUEUE_LOAD"},
{V2MessageType::kQueueReorder, "QUEUE_REORDER"}, {cast_channel::V2MessageType::kQueueRemove, "QUEUE_REMOVE"},
{V2MessageType::kQueueUpdate, "QUEUE_UPDATE"}, {cast_channel::V2MessageType::kQueueReorder, "QUEUE_REORDER"},
{V2MessageType::kQueueNext, "QUEUE_NEXT"}, {cast_channel::V2MessageType::kQueueUpdate, "QUEUE_UPDATE"},
{V2MessageType::kQueuePrev, "QUEUE_PREV"}, {cast_channel::V2MessageType::kQueueNext, "QUEUE_NEXT"},
{V2MessageType::kSeek, "SEEK"}, {cast_channel::V2MessageType::kQueuePrev, "QUEUE_PREV"},
{V2MessageType::kSetVolume, "SET_VOLUME"}, {cast_channel::V2MessageType::kSeek, "SEEK"},
{V2MessageType::kStop, "STOP"}, {cast_channel::V2MessageType::kSetVolume, "SET_VOLUME"},
{V2MessageType::kStopMedia, "STOP_MEDIA"}, {cast_channel::V2MessageType::kStop, "STOP"},
{V2MessageType::kOther}, {cast_channel::V2MessageType::kStopMedia, "STOP_MEDIA"},
}, {cast_channel::V2MessageType::kOther},
V2MessageType::kMaxValue); },
cast_channel::V2MessageType::kMaxValue);
template <> template <>
const EnumTable<GetAppAvailabilityResult> const EnumTable<GetAppAvailabilityResult>
......
...@@ -1434,39 +1434,42 @@ class PinTraits : public NoValueValidation, public ItemsTraits<kOptionPin> { ...@@ -1434,39 +1434,42 @@ class PinTraits : public NoValueValidation, public ItemsTraits<kOptionPin> {
} // namespace printer } // namespace printer
using namespace printer; template class ListCapability<printer::ContentType, printer::ContentTypeTraits>;
template class ValueCapability<printer::PwgRasterConfig,
template class ListCapability<ContentType, ContentTypeTraits>; printer::PwgRasterConfigTraits>;
template class ValueCapability<PwgRasterConfig, PwgRasterConfigTraits>; template class ListCapability<printer::VendorCapability,
template class ListCapability<VendorCapability, VendorCapabilityTraits>; printer::VendorCapabilityTraits>;
template class SelectionCapability<SelectVendorCapabilityOption, template class SelectionCapability<printer::SelectVendorCapabilityOption,
SelectVendorCapabilityTraits>; printer::SelectVendorCapabilityTraits>;
template class SelectionCapability<Color, ColorTraits>; template class SelectionCapability<printer::Color, printer::ColorTraits>;
template class SelectionCapability<DuplexType, DuplexTraits>; template class SelectionCapability<printer::DuplexType, printer::DuplexTraits>;
template class SelectionCapability<OrientationType, OrientationTraits>; template class SelectionCapability<printer::OrientationType,
template class SelectionCapability<Margins, MarginsTraits>; printer::OrientationTraits>;
template class SelectionCapability<Dpi, DpiTraits>; template class SelectionCapability<printer::Margins, printer::MarginsTraits>;
template class SelectionCapability<FitToPageType, FitToPageTraits>; template class SelectionCapability<printer::Dpi, printer::DpiTraits>;
template class SelectionCapability<Media, MediaTraits>; template class SelectionCapability<printer::FitToPageType,
template class EmptyCapability<class CopiesTraits>; printer::FitToPageTraits>;
template class EmptyCapability<class PageRangeTraits>; template class SelectionCapability<printer::Media, printer::MediaTraits>;
template class BooleanCapability<class CollateTraits>; template class EmptyCapability<printer::CopiesTraits>;
template class BooleanCapability<class ReverseTraits>; template class EmptyCapability<printer::PageRangeTraits>;
template class BooleanCapability<printer::CollateTraits>;
template class BooleanCapability<printer::ReverseTraits>;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
template class ValueCapability<bool, class PinTraits>; template class ValueCapability<bool, printer::PinTraits>;
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
template class TicketItem<PwgRasterConfig, PwgRasterConfigTraits>; template class TicketItem<printer::PwgRasterConfig,
template class TicketItem<Color, ColorTraits>; printer::PwgRasterConfigTraits>;
template class TicketItem<DuplexType, DuplexTraits>; template class TicketItem<printer::Color, printer::ColorTraits>;
template class TicketItem<OrientationType, OrientationTraits>; template class TicketItem<printer::DuplexType, printer::DuplexTraits>;
template class TicketItem<Margins, MarginsTraits>; template class TicketItem<printer::OrientationType, printer::OrientationTraits>;
template class TicketItem<Dpi, DpiTraits>; template class TicketItem<printer::Margins, printer::MarginsTraits>;
template class TicketItem<FitToPageType, FitToPageTraits>; template class TicketItem<printer::Dpi, printer::DpiTraits>;
template class TicketItem<Media, MediaTraits>; template class TicketItem<printer::FitToPageType, printer::FitToPageTraits>;
template class TicketItem<int32_t, CopiesTraits>; template class TicketItem<printer::Media, printer::MediaTraits>;
template class TicketItem<PageRange, PageRangeTraits>; template class TicketItem<int32_t, printer::CopiesTraits>;
template class TicketItem<bool, CollateTraits>; template class TicketItem<printer::PageRange, printer::PageRangeTraits>;
template class TicketItem<bool, ReverseTraits>; template class TicketItem<bool, printer::CollateTraits>;
template class TicketItem<bool, printer::ReverseTraits>;
} // namespace cloud_devices } // namespace cloud_devices
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
namespace dom_distiller { namespace dom_distiller {
using namespace blink;
namespace { namespace {
const char* const kBlacklist[] = {"www.reddit.com", "tools.usps.com"}; const char* const kBlacklist[] = {"www.reddit.com", "tools.usps.com"};
...@@ -78,7 +76,7 @@ bool IsBlacklisted(const GURL& url) { ...@@ -78,7 +76,7 @@ bool IsBlacklisted(const GURL& url) {
} }
void DumpDistillability(content::RenderFrame* render_frame, void DumpDistillability(content::RenderFrame* render_frame,
const WebDistillabilityFeatures& features, const blink::WebDistillabilityFeatures& features,
const std::vector<double>& derived, const std::vector<double>& derived,
double score, double score,
bool distillable, bool distillable,
...@@ -125,7 +123,7 @@ void DumpDistillability(content::RenderFrame* render_frame, ...@@ -125,7 +123,7 @@ void DumpDistillability(content::RenderFrame* render_frame,
msg); msg);
} }
bool IsDistillablePageAdaboost(WebDocument& doc, bool IsDistillablePageAdaboost(blink::WebDocument& doc,
const DistillablePageDetector* detector, const DistillablePageDetector* detector,
const DistillablePageDetector* long_page, const DistillablePageDetector* long_page,
bool is_last, bool is_last,
...@@ -136,7 +134,7 @@ bool IsDistillablePageAdaboost(WebDocument& doc, ...@@ -136,7 +134,7 @@ bool IsDistillablePageAdaboost(WebDocument& doc,
if (!parsed_url.is_valid()) { if (!parsed_url.is_valid()) {
return false; return false;
} }
WebDistillabilityFeatures features = doc.DistillabilityFeatures(); blink::WebDistillabilityFeatures features = doc.DistillabilityFeatures();
is_mobile_friendly = features.is_mobile_friendly; is_mobile_friendly = features.is_mobile_friendly;
std::vector<double> derived = CalculateDerivedFeatures( std::vector<double> derived = CalculateDerivedFeatures(
features.open_graph, parsed_url, features.element_count, features.open_graph, parsed_url, features.element_count,
...@@ -209,7 +207,7 @@ bool IsDistillablePageAdaboost(WebDocument& doc, ...@@ -209,7 +207,7 @@ bool IsDistillablePageAdaboost(WebDocument& doc,
return distillable && long_article; return distillable && long_article;
} }
bool IsDistillablePage(WebDocument& doc, bool IsDistillablePage(blink::WebDocument& doc,
bool is_last, bool is_last,
bool& is_mobile_friendly, bool& is_mobile_friendly,
content::RenderFrame* render_frame, content::RenderFrame* render_frame,
...@@ -237,9 +235,10 @@ DistillabilityAgent::DistillabilityAgent(content::RenderFrame* render_frame, ...@@ -237,9 +235,10 @@ DistillabilityAgent::DistillabilityAgent(content::RenderFrame* render_frame,
bool dump_info) bool dump_info)
: RenderFrameObserver(render_frame), dump_info_(dump_info) {} : RenderFrameObserver(render_frame), dump_info_(dump_info) {}
void DistillabilityAgent::DidMeaningfulLayout(WebMeaningfulLayout layout_type) { void DistillabilityAgent::DidMeaningfulLayout(
if (layout_type != WebMeaningfulLayout::kFinishedParsing && blink::WebMeaningfulLayout layout_type) {
layout_type != WebMeaningfulLayout::kFinishedLoading) { if (layout_type != blink::WebMeaningfulLayout::kFinishedParsing &&
layout_type != blink::WebMeaningfulLayout::kFinishedLoading) {
return; return;
} }
...@@ -247,13 +246,13 @@ void DistillabilityAgent::DidMeaningfulLayout(WebMeaningfulLayout layout_type) { ...@@ -247,13 +246,13 @@ void DistillabilityAgent::DidMeaningfulLayout(WebMeaningfulLayout layout_type) {
if (!render_frame()->IsMainFrame()) if (!render_frame()->IsMainFrame())
return; return;
DCHECK(render_frame()->GetWebFrame()); DCHECK(render_frame()->GetWebFrame());
WebDocument doc = render_frame()->GetWebFrame()->GetDocument(); blink::WebDocument doc = render_frame()->GetWebFrame()->GetDocument();
if (doc.IsNull() || doc.Body().IsNull()) if (doc.IsNull() || doc.Body().IsNull())
return; return;
if (!url_utils::IsUrlDistillable(doc.Url())) if (!url_utils::IsUrlDistillable(doc.Url()))
return; return;
bool is_loaded = layout_type == WebMeaningfulLayout::kFinishedLoading; bool is_loaded = layout_type == blink::WebMeaningfulLayout::kFinishedLoading;
if (!NeedToUpdate(is_loaded)) if (!NeedToUpdate(is_loaded))
return; return;
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
namespace { namespace {
using namespace os_crypt;
class KeyStorageUtilLinuxPreferenceTest : public testing::Test { class KeyStorageUtilLinuxPreferenceTest : public testing::Test {
public: public:
KeyStorageUtilLinuxPreferenceTest() = default; KeyStorageUtilLinuxPreferenceTest() = default;
...@@ -34,28 +32,28 @@ class KeyStorageUtilLinuxPreferenceTest : public testing::Test { ...@@ -34,28 +32,28 @@ class KeyStorageUtilLinuxPreferenceTest : public testing::Test {
}; };
TEST_F(KeyStorageUtilLinuxPreferenceTest, FirstTimeDefaultsToTrue) { TEST_F(KeyStorageUtilLinuxPreferenceTest, FirstTimeDefaultsToTrue) {
EXPECT_TRUE(GetBackendUse(fake_user_data_dir_)); EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_));
} }
TEST_F(KeyStorageUtilLinuxPreferenceTest, SetToTrue) { TEST_F(KeyStorageUtilLinuxPreferenceTest, SetToTrue) {
EXPECT_TRUE(WriteBackendUse(fake_user_data_dir_, true)); EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, true));
EXPECT_TRUE(GetBackendUse(fake_user_data_dir_)); EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_));
} }
TEST_F(KeyStorageUtilLinuxPreferenceTest, SetToFalse) { TEST_F(KeyStorageUtilLinuxPreferenceTest, SetToFalse) {
EXPECT_TRUE(WriteBackendUse(fake_user_data_dir_, false)); EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false));
EXPECT_FALSE(GetBackendUse(fake_user_data_dir_)); EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_));
} }
TEST_F(KeyStorageUtilLinuxPreferenceTest, MultipleWrites) { TEST_F(KeyStorageUtilLinuxPreferenceTest, MultipleWrites) {
EXPECT_TRUE(WriteBackendUse(fake_user_data_dir_, false)); EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false));
EXPECT_FALSE(GetBackendUse(fake_user_data_dir_)); EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_));
EXPECT_TRUE(WriteBackendUse(fake_user_data_dir_, true)); EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, true));
EXPECT_TRUE(GetBackendUse(fake_user_data_dir_)); EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_));
EXPECT_TRUE(WriteBackendUse(fake_user_data_dir_, false)); EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false));
EXPECT_FALSE(GetBackendUse(fake_user_data_dir_)); EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_));
} }
class KeyStorageUtilLinuxTest : public testing::Test { class KeyStorageUtilLinuxTest : public testing::Test {
...@@ -72,41 +70,41 @@ class KeyStorageUtilLinuxTest : public testing::Test { ...@@ -72,41 +70,41 @@ class KeyStorageUtilLinuxTest : public testing::Test {
}; };
TEST_F(KeyStorageUtilLinuxTest, PasswordStoreFlagOverrides) { TEST_F(KeyStorageUtilLinuxTest, PasswordStoreFlagOverrides) {
SelectedLinuxBackend selected; os_crypt::SelectedLinuxBackend selected;
selected = SelectBackend( selected = os_crypt::SelectBackend(
"basic", true, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_GNOME); "basic", true, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_GNOME);
EXPECT_EQ(selected, SelectedLinuxBackend::BASIC_TEXT); EXPECT_EQ(selected, os_crypt::SelectedLinuxBackend::BASIC_TEXT);
selected = selected = os_crypt::SelectBackend(
SelectBackend("gnome-libsecret", false, "gnome-libsecret", false,
base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_KDE4); base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_KDE4);
EXPECT_EQ(selected, SelectedLinuxBackend::GNOME_LIBSECRET); EXPECT_EQ(selected, os_crypt::SelectedLinuxBackend::GNOME_LIBSECRET);
selected = selected = os_crypt::SelectBackend(
SelectBackend("gnome-libsecret", true, "gnome-libsecret", true,
base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_KDE4); base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_KDE4);
EXPECT_EQ(selected, SelectedLinuxBackend::GNOME_LIBSECRET); EXPECT_EQ(selected, os_crypt::SelectedLinuxBackend::GNOME_LIBSECRET);
} }
TEST_F(KeyStorageUtilLinuxTest, IgnoreBackends) { TEST_F(KeyStorageUtilLinuxTest, IgnoreBackends) {
SelectedLinuxBackend selected; os_crypt::SelectedLinuxBackend selected;
selected = SelectBackend( selected = os_crypt::SelectBackend(
"", true, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_GNOME); "", true, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_GNOME);
EXPECT_EQ(selected, SelectedLinuxBackend::GNOME_ANY); EXPECT_EQ(selected, os_crypt::SelectedLinuxBackend::GNOME_ANY);
selected = SelectBackend( selected = os_crypt::SelectBackend(
"", false, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_GNOME); "", false, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_GNOME);
EXPECT_EQ(selected, SelectedLinuxBackend::BASIC_TEXT); EXPECT_EQ(selected, os_crypt::SelectedLinuxBackend::BASIC_TEXT);
selected = SelectBackend( selected = os_crypt::SelectBackend(
"", true, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_KDE5); "", true, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_KDE5);
EXPECT_EQ(selected, SelectedLinuxBackend::KWALLET5); EXPECT_EQ(selected, os_crypt::SelectedLinuxBackend::KWALLET5);
selected = SelectBackend( selected = os_crypt::SelectBackend(
"", false, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_KDE5); "", false, base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_KDE5);
EXPECT_EQ(selected, SelectedLinuxBackend::BASIC_TEXT); EXPECT_EQ(selected, os_crypt::SelectedLinuxBackend::BASIC_TEXT);
} }
} // namespace os_crypt } // namespace os_crypt
...@@ -18,45 +18,42 @@ ...@@ -18,45 +18,42 @@
#include "printing/printing_features_chromeos.h" #include "printing/printing_features_chromeos.h"
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
namespace printer = cloud_devices::printer;
namespace cloud_print { namespace cloud_print {
namespace { namespace {
cloud_devices::printer::DuplexType ToCloudDuplexType( printer::DuplexType ToCloudDuplexType(printing::DuplexMode mode) {
printing::DuplexMode mode) {
switch (mode) { switch (mode) {
case printing::SIMPLEX: case printing::SIMPLEX:
return cloud_devices::printer::DuplexType::NO_DUPLEX; return printer::DuplexType::NO_DUPLEX;
case printing::LONG_EDGE: case printing::LONG_EDGE:
return cloud_devices::printer::DuplexType::LONG_EDGE; return printer::DuplexType::LONG_EDGE;
case printing::SHORT_EDGE: case printing::SHORT_EDGE:
return cloud_devices::printer::DuplexType::SHORT_EDGE; return printer::DuplexType::SHORT_EDGE;
default: default:
NOTREACHED(); NOTREACHED();
} }
return cloud_devices::printer::DuplexType::NO_DUPLEX; return printer::DuplexType::NO_DUPLEX;
} }
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
cloud_devices::printer::TypedValueVendorCapability::ValueType ToCloudValueType( printer::TypedValueVendorCapability::ValueType ToCloudValueType(
base::Value::Type type) { base::Value::Type type) {
switch (type) { switch (type) {
case base::Value::Type::BOOLEAN: case base::Value::Type::BOOLEAN:
return cloud_devices::printer::TypedValueVendorCapability::ValueType:: return printer::TypedValueVendorCapability::ValueType::BOOLEAN;
BOOLEAN;
case base::Value::Type::DOUBLE: case base::Value::Type::DOUBLE:
return cloud_devices::printer::TypedValueVendorCapability::ValueType:: return printer::TypedValueVendorCapability::ValueType::FLOAT;
FLOAT;
case base::Value::Type::INTEGER: case base::Value::Type::INTEGER:
return cloud_devices::printer::TypedValueVendorCapability::ValueType:: return printer::TypedValueVendorCapability::ValueType::INTEGER;
INTEGER;
case base::Value::Type::STRING: case base::Value::Type::STRING:
return cloud_devices::printer::TypedValueVendorCapability::ValueType:: return printer::TypedValueVendorCapability::ValueType::STRING;
STRING;
default: default:
NOTREACHED(); NOTREACHED();
} }
return cloud_devices::printer::TypedValueVendorCapability::ValueType::STRING; return printer::TypedValueVendorCapability::ValueType::STRING;
} }
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -64,26 +61,25 @@ cloud_devices::printer::TypedValueVendorCapability::ValueType ToCloudValueType( ...@@ -64,26 +61,25 @@ cloud_devices::printer::TypedValueVendorCapability::ValueType ToCloudValueType(
base::Value PrinterSemanticCapsAndDefaultsToCdd( base::Value PrinterSemanticCapsAndDefaultsToCdd(
const printing::PrinterSemanticCapsAndDefaults& semantic_info) { const printing::PrinterSemanticCapsAndDefaults& semantic_info) {
using namespace cloud_devices::printer;
cloud_devices::CloudDeviceDescription description; cloud_devices::CloudDeviceDescription description;
ContentTypesCapability content_types; printer::ContentTypesCapability content_types;
content_types.AddOption("application/pdf"); content_types.AddOption("application/pdf");
content_types.SaveTo(&description); content_types.SaveTo(&description);
if (semantic_info.collate_capable) { if (semantic_info.collate_capable) {
CollateCapability collate; printer::CollateCapability collate;
collate.set_default_value(semantic_info.collate_default); collate.set_default_value(semantic_info.collate_default);
collate.SaveTo(&description); collate.SaveTo(&description);
} }
if (semantic_info.copies_capable) { if (semantic_info.copies_capable) {
CopiesCapability copies; printer::CopiesCapability copies;
copies.SaveTo(&description); copies.SaveTo(&description);
} }
if (semantic_info.duplex_modes.size() > 1) { if (semantic_info.duplex_modes.size() > 1) {
DuplexCapability duplex; printer::DuplexCapability duplex;
for (printing::DuplexMode mode : semantic_info.duplex_modes) { for (printing::DuplexMode mode : semantic_info.duplex_modes) {
duplex.AddDefaultOption(ToCloudDuplexType(mode), duplex.AddDefaultOption(ToCloudDuplexType(mode),
semantic_info.duplex_default == mode); semantic_info.duplex_default == mode);
...@@ -91,14 +87,14 @@ base::Value PrinterSemanticCapsAndDefaultsToCdd( ...@@ -91,14 +87,14 @@ base::Value PrinterSemanticCapsAndDefaultsToCdd(
duplex.SaveTo(&description); duplex.SaveTo(&description);
} }
ColorCapability color; printer::ColorCapability color;
if (semantic_info.color_default || semantic_info.color_changeable) { if (semantic_info.color_default || semantic_info.color_changeable) {
Color standard_color(ColorType::STANDARD_COLOR); printer::Color standard_color(printer::ColorType::STANDARD_COLOR);
standard_color.vendor_id = base::NumberToString(semantic_info.color_model); standard_color.vendor_id = base::NumberToString(semantic_info.color_model);
color.AddDefaultOption(standard_color, semantic_info.color_default); color.AddDefaultOption(standard_color, semantic_info.color_default);
} }
if (!semantic_info.color_default || semantic_info.color_changeable) { if (!semantic_info.color_default || semantic_info.color_changeable) {
Color standard_monochrome(ColorType::STANDARD_MONOCHROME); printer::Color standard_monochrome(printer::ColorType::STANDARD_MONOCHROME);
standard_monochrome.vendor_id = standard_monochrome.vendor_id =
base::NumberToString(semantic_info.bw_model); base::NumberToString(semantic_info.bw_model);
color.AddDefaultOption(standard_monochrome, !semantic_info.color_default); color.AddDefaultOption(standard_monochrome, !semantic_info.color_default);
...@@ -106,21 +102,21 @@ base::Value PrinterSemanticCapsAndDefaultsToCdd( ...@@ -106,21 +102,21 @@ base::Value PrinterSemanticCapsAndDefaultsToCdd(
color.SaveTo(&description); color.SaveTo(&description);
if (!semantic_info.papers.empty()) { if (!semantic_info.papers.empty()) {
Media default_media(semantic_info.default_paper.display_name, printer::Media default_media(semantic_info.default_paper.display_name,
semantic_info.default_paper.vendor_id, semantic_info.default_paper.vendor_id,
semantic_info.default_paper.size_um.width(), semantic_info.default_paper.size_um.width(),
semantic_info.default_paper.size_um.height()); semantic_info.default_paper.size_um.height());
default_media.MatchBySize(); default_media.MatchBySize();
MediaCapability media; printer::MediaCapability media;
bool is_default_set = false; bool is_default_set = false;
for (size_t i = 0; i < semantic_info.papers.size(); ++i) { for (size_t i = 0; i < semantic_info.papers.size(); ++i) {
gfx::Size paper_size = semantic_info.papers[i].size_um; gfx::Size paper_size = semantic_info.papers[i].size_um;
if (paper_size.width() > paper_size.height()) if (paper_size.width() > paper_size.height())
paper_size.SetSize(paper_size.height(), paper_size.width()); paper_size.SetSize(paper_size.height(), paper_size.width());
Media new_media(semantic_info.papers[i].display_name, printer::Media new_media(semantic_info.papers[i].display_name,
semantic_info.papers[i].vendor_id, paper_size.width(), semantic_info.papers[i].vendor_id,
paper_size.height()); paper_size.width(), paper_size.height());
new_media.MatchBySize(); new_media.MatchBySize();
if (new_media.IsValid() && !media.Contains(new_media)) { if (new_media.IsValid() && !media.Contains(new_media)) {
if (!default_media.IsValid()) if (!default_media.IsValid())
...@@ -132,21 +128,18 @@ base::Value PrinterSemanticCapsAndDefaultsToCdd( ...@@ -132,21 +128,18 @@ base::Value PrinterSemanticCapsAndDefaultsToCdd(
if (!is_default_set && default_media.IsValid()) if (!is_default_set && default_media.IsValid())
media.AddDefaultOption(default_media, true); media.AddDefaultOption(default_media, true);
if (media.IsValid()) { DCHECK(media.IsValid());
media.SaveTo(&description); media.SaveTo(&description);
} else {
NOTREACHED();
}
} }
if (!semantic_info.dpis.empty()) { if (!semantic_info.dpis.empty()) {
DpiCapability dpi; printer::DpiCapability dpi;
Dpi default_dpi(semantic_info.default_dpi.width(), printer::Dpi default_dpi(semantic_info.default_dpi.width(),
semantic_info.default_dpi.height()); semantic_info.default_dpi.height());
bool is_default_set = false; bool is_default_set = false;
for (size_t i = 0; i < semantic_info.dpis.size(); ++i) { for (size_t i = 0; i < semantic_info.dpis.size(); ++i) {
Dpi new_dpi(semantic_info.dpis[i].width(), printer::Dpi new_dpi(semantic_info.dpis[i].width(),
semantic_info.dpis[i].height()); semantic_info.dpis[i].height());
if (new_dpi.IsValid() && !dpi.Contains(new_dpi)) { if (new_dpi.IsValid() && !dpi.Contains(new_dpi)) {
if (!default_dpi.IsValid()) if (!default_dpi.IsValid())
default_dpi = new_dpi; default_dpi = new_dpi;
...@@ -156,47 +149,45 @@ base::Value PrinterSemanticCapsAndDefaultsToCdd( ...@@ -156,47 +149,45 @@ base::Value PrinterSemanticCapsAndDefaultsToCdd(
} }
if (!is_default_set && default_dpi.IsValid()) if (!is_default_set && default_dpi.IsValid())
dpi.AddDefaultOption(default_dpi, true); dpi.AddDefaultOption(default_dpi, true);
if (dpi.IsValid()) { DCHECK(dpi.IsValid());
dpi.SaveTo(&description); dpi.SaveTo(&description);
} else {
NOTREACHED();
}
} }
OrientationCapability orientation; printer::OrientationCapability orientation;
orientation.AddDefaultOption(OrientationType::PORTRAIT, true); orientation.AddDefaultOption(printer::OrientationType::PORTRAIT, true);
orientation.AddOption(OrientationType::LANDSCAPE); orientation.AddOption(printer::OrientationType::LANDSCAPE);
orientation.AddOption(OrientationType::AUTO_ORIENTATION); orientation.AddOption(printer::OrientationType::AUTO_ORIENTATION);
orientation.SaveTo(&description); orientation.SaveTo(&description);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
PinCapability pin; printer::PinCapability pin;
pin.set_value(semantic_info.pin_supported); pin.set_value(semantic_info.pin_supported);
pin.SaveTo(&description); pin.SaveTo(&description);
if (base::FeatureList::IsEnabled(printing::kAdvancedPpdAttributes) && if (base::FeatureList::IsEnabled(printing::kAdvancedPpdAttributes) &&
!semantic_info.advanced_capabilities.empty()) { !semantic_info.advanced_capabilities.empty()) {
VendorCapabilities vendor_capabilities; printer::VendorCapabilities vendor_capabilities;
for (const auto& capability : semantic_info.advanced_capabilities) { for (const auto& capability : semantic_info.advanced_capabilities) {
std::string capability_name = capability.display_name.empty() std::string capability_name = capability.display_name.empty()
? capability.name ? capability.name
: capability.display_name; : capability.display_name;
if (!capability.values.empty()) { if (!capability.values.empty()) {
SelectVendorCapability select_capability; printer::SelectVendorCapability select_capability;
for (const auto& value : capability.values) { for (const auto& value : capability.values) {
std::string localized_value = std::string localized_value =
value.display_name.empty() ? value.name : value.display_name; value.display_name.empty() ? value.name : value.display_name;
select_capability.AddDefaultOption( select_capability.AddDefaultOption(
SelectVendorCapabilityOption(value.name, localized_value), printer::SelectVendorCapabilityOption(value.name,
localized_value),
value.is_default); value.is_default);
} }
vendor_capabilities.AddOption(VendorCapability( vendor_capabilities.AddOption(printer::VendorCapability(
capability.name, capability_name, std::move(select_capability))); capability.name, capability_name, std::move(select_capability)));
} else { } else {
vendor_capabilities.AddOption( vendor_capabilities.AddOption(printer::VendorCapability(
VendorCapability(capability.name, capability_name, capability.name, capability_name,
TypedValueVendorCapability( printer::TypedValueVendorCapability(
ToCloudValueType(base::Value::Type::STRING)))); ToCloudValueType(base::Value::Type::STRING))));
} }
} }
vendor_capabilities.SaveTo(&description); vendor_capabilities.SaveTo(&description);
......
...@@ -10,9 +10,12 @@ ...@@ -10,9 +10,12 @@
#include "components/ui_devtools/ui_element.h" #include "components/ui_devtools/ui_element.h"
namespace ui_devtools { namespace ui_devtools {
namespace {
using namespace ui_devtools::protocol; namespace CSS = protocol::CSS;
using protocol::Array;
using protocol::Response;
namespace {
const char kHeight[] = "height"; const char kHeight[] = "height";
const char kWidth[] = "width"; const char kWidth[] = "width";
...@@ -44,8 +47,8 @@ std::unique_ptr<CSS::SourceRange> BuildDefaultSelectorSourceRange() { ...@@ -44,8 +47,8 @@ std::unique_ptr<CSS::SourceRange> BuildDefaultSelectorSourceRange() {
.build(); .build();
} }
std::unique_ptr<protocol::Array<int>> BuildDefaultMatchingSelectors() { std::unique_ptr<Array<int>> BuildDefaultMatchingSelectors() {
auto matching_selectors = std::make_unique<protocol::Array<int>>(); auto matching_selectors = std::make_unique<Array<int>>();
// Add index 0 to matching delectors array, so frontend uses the class mame // Add index 0 to matching delectors array, so frontend uses the class mame
// from the selectors array as the header for the properties section // from the selectors array as the header for the properties section
...@@ -64,7 +67,7 @@ std::unique_ptr<CSS::CSSProperty> BuildCSSProperty(const std::string& name, ...@@ -64,7 +67,7 @@ std::unique_ptr<CSS::CSSProperty> BuildCSSProperty(const std::string& name,
std::unique_ptr<Array<CSS::CSSProperty>> BuildCSSProperties( std::unique_ptr<Array<CSS::CSSProperty>> BuildCSSProperties(
const std::vector<UIElement::UIProperty>& properties_vector) { const std::vector<UIElement::UIProperty>& properties_vector) {
auto css_properties = std::make_unique<Array<protocol::CSS::CSSProperty>>(); auto css_properties = std::make_unique<Array<CSS::CSSProperty>>();
for (const auto& property : properties_vector) { for (const auto& property : properties_vector) {
css_properties->emplace_back( css_properties->emplace_back(
BuildCSSProperty(property.name_, property.value_)); BuildCSSProperty(property.name_, property.value_));
...@@ -75,36 +78,31 @@ std::unique_ptr<Array<CSS::CSSProperty>> BuildCSSProperties( ...@@ -75,36 +78,31 @@ std::unique_ptr<Array<CSS::CSSProperty>> BuildCSSProperties(
std::unique_ptr<CSS::CSSStyle> BuildCSSStyle( std::unique_ptr<CSS::CSSStyle> BuildCSSStyle(
std::string stylesheet_uid, std::string stylesheet_uid,
const std::vector<UIElement::UIProperty>& properties) { const std::vector<UIElement::UIProperty>& properties) {
return protocol::CSS::CSSStyle::create() return CSS::CSSStyle::create()
.setRange(BuildDefaultPropertySourceRange()) .setRange(BuildDefaultPropertySourceRange())
.setCssProperties(BuildCSSProperties(properties)) .setCssProperties(BuildCSSProperties(properties))
.setShorthandEntries( .setShorthandEntries(std::make_unique<Array<CSS::ShorthandEntry>>())
std::make_unique<Array<protocol::CSS::ShorthandEntry>>())
.setStyleSheetId(stylesheet_uid) .setStyleSheetId(stylesheet_uid)
.build(); .build();
} }
std::unique_ptr<protocol::Array<protocol::CSS::Value>> BuildSelectors( std::unique_ptr<Array<CSS::Value>> BuildSelectors(const std::string& name) {
const std::string& name) { auto selectors = std::make_unique<Array<CSS::Value>>();
auto selectors = std::make_unique<protocol::Array<protocol::CSS::Value>>(); selectors->emplace_back(CSS::Value::create()
selectors->emplace_back(protocol::CSS::Value::create()
.setText(name) .setText(name)
.setRange(BuildDefaultSelectorSourceRange()) .setRange(BuildDefaultSelectorSourceRange())
.build()); .build());
return selectors; return selectors;
} }
std::unique_ptr<protocol::CSS::SelectorList> BuildSelectorList( std::unique_ptr<CSS::SelectorList> BuildSelectorList(const std::string& name) {
const std::string& name) { return CSS::SelectorList::create().setSelectors(BuildSelectors(name)).build();
return protocol::CSS::SelectorList::create()
.setSelectors(BuildSelectors(name))
.build();
} }
std::unique_ptr<protocol::CSS::CSSRule> BuildCSSRule( std::unique_ptr<CSS::CSSRule> BuildCSSRule(
std::string stylesheet_uid, std::string stylesheet_uid,
const UIElement::ClassProperties& class_properties) { const UIElement::ClassProperties& class_properties) {
return protocol::CSS::CSSRule::create() return CSS::CSSRule::create()
.setStyleSheetId(stylesheet_uid) .setStyleSheetId(stylesheet_uid)
.setSelectorList(BuildSelectorList(class_properties.class_name_)) .setSelectorList(BuildSelectorList(class_properties.class_name_))
.setStyle(BuildCSSStyle(stylesheet_uid, class_properties.properties_)) .setStyle(BuildCSSStyle(stylesheet_uid, class_properties.properties_))
...@@ -164,8 +162,9 @@ Response ParseProperties(const std::string& style_text, ...@@ -164,8 +162,9 @@ Response ParseProperties(const std::string& style_text,
for (size_t i = 0; i < tokens.size() - 1; i += 2) { for (size_t i = 0; i < tokens.size() - 1; i += 2) {
const std::string& property = tokens.at(i); const std::string& property = tokens.at(i);
int value; int value;
if (!base::StringToInt(tokens.at(i + 1), &value)) if (!base::StringToInt(tokens.at(i + 1), &value)) {
return Response::Error("Unable to parse value for property=" + property); return Response::Error("Unable to parse value for property=" + property);
}
if (property == kHeight) if (property == kHeight)
bounds->set_height(std::max(0, value)); bounds->set_height(std::max(0, value));
...@@ -183,12 +182,12 @@ Response ParseProperties(const std::string& style_text, ...@@ -183,12 +182,12 @@ Response ParseProperties(const std::string& style_text,
return Response::OK(); return Response::OK();
} }
std::unique_ptr<protocol::CSS::CSSStyleSheetHeader> std::unique_ptr<CSS::CSSStyleSheetHeader> BuildObjectForStyleSheetInfo(
BuildObjectForStyleSheetInfo(std::string stylesheet_uid, std::string stylesheet_uid,
std::string url_path, std::string url_path,
int line) { int line) {
std::unique_ptr<protocol::CSS::CSSStyleSheetHeader> result = std::unique_ptr<CSS::CSSStyleSheetHeader> result =
protocol::CSS::CSSStyleSheetHeader::create() CSS::CSSStyleSheetHeader::create()
.setStyleSheetId(stylesheet_uid) .setStyleSheetId(stylesheet_uid)
.setSourceURL(kChromiumCodeSearchSrcURL + url_path + .setSourceURL(kChromiumCodeSearchSrcURL + url_path +
"?l=" + base::NumberToString(line)) "?l=" + base::NumberToString(line))
...@@ -220,8 +219,7 @@ Response CSSAgent::disable() { ...@@ -220,8 +219,7 @@ Response CSSAgent::disable() {
Response CSSAgent::getMatchedStylesForNode( Response CSSAgent::getMatchedStylesForNode(
int node_id, int node_id,
protocol::Maybe<protocol::Array<protocol::CSS::RuleMatch>>* protocol::Maybe<Array<CSS::RuleMatch>>* matched_css_rules) {
matched_css_rules) {
UIElement* ui_element = dom_agent_->GetElementFromNodeId(node_id); UIElement* ui_element = dom_agent_->GetElementFromNodeId(node_id);
if (!ui_element) if (!ui_element)
return NodeNotFoundError(node_id); return NodeNotFoundError(node_id);
...@@ -248,8 +246,8 @@ Response CSSAgent::getStyleSheetText(const protocol::String& style_sheet_id, ...@@ -248,8 +246,8 @@ Response CSSAgent::getStyleSheetText(const protocol::String& style_sheet_id,
return Response::Error("Stylesheet id not found"); return Response::Error("Stylesheet id not found");
if (GetSourceCode(sources[stylesheet_id].path_, result)) if (GetSourceCode(sources[stylesheet_id].path_, result))
return protocol::Response::OK(); return Response::OK();
return protocol::Response::Error("Could not read source file"); return Response::Error("Could not read source file");
} }
Response CSSAgent::setStyleTexts( Response CSSAgent::setStyleTexts(
...@@ -331,15 +329,15 @@ bool CSSAgent::SetPropertiesForUIElement(UIElement* ui_element, ...@@ -331,15 +329,15 @@ bool CSSAgent::SetPropertiesForUIElement(UIElement* ui_element,
return false; return false;
} }
std::unique_ptr<protocol::Array<protocol::CSS::RuleMatch>> std::unique_ptr<Array<CSS::RuleMatch>> CSSAgent::BuildMatchedStyles(
CSSAgent::BuildMatchedStyles(UIElement* ui_element) { UIElement* ui_element) {
auto result = std::make_unique<protocol::Array<protocol::CSS::RuleMatch>>(); auto result = std::make_unique<Array<CSS::RuleMatch>>();
std::vector<UIElement::ClassProperties> properties_vector = std::vector<UIElement::ClassProperties> properties_vector =
GetClassPropertiesWithBounds(ui_element); GetClassPropertiesWithBounds(ui_element);
for (size_t i = 0; i < properties_vector.size(); i++) { for (size_t i = 0; i < properties_vector.size(); i++) {
result->emplace_back( result->emplace_back(
protocol::CSS::RuleMatch::create() CSS::RuleMatch::create()
.setRule(BuildCSSRule(BuildStylesheetUId(ui_element->node_id(), i), .setRule(BuildCSSRule(BuildStylesheetUId(ui_element->node_id(), i),
properties_vector[i])) properties_vector[i]))
.setMatchingSelectors(BuildDefaultMatchingSelectors()) .setMatchingSelectors(BuildDefaultMatchingSelectors())
......
...@@ -26,9 +26,10 @@ ...@@ -26,9 +26,10 @@
#endif // defined(USE_AURA) #endif // defined(USE_AURA)
namespace ui_devtools { namespace ui_devtools {
namespace {
using namespace ui_devtools::protocol; namespace DOM = protocol::DOM;
namespace {
class TestView : public views::View { class TestView : public views::View {
public: public:
...@@ -44,7 +45,7 @@ class TestView : public views::View { ...@@ -44,7 +45,7 @@ class TestView : public views::View {
std::string GetAttributeValue(const std::string& attribute, DOM::Node* node) { std::string GetAttributeValue(const std::string& attribute, DOM::Node* node) {
EXPECT_TRUE(node->hasAttributes()); EXPECT_TRUE(node->hasAttributes());
Array<std::string>* attributes = node->getAttributes(nullptr); protocol::Array<std::string>* attributes = node->getAttributes(nullptr);
for (size_t i = 0; i < attributes->size() - 1; i += 2) { for (size_t i = 0; i < attributes->size() - 1; i += 2) {
if ((*attributes)[i] == attribute) if ((*attributes)[i] == attribute)
return (*attributes)[i + 1]; return (*attributes)[i + 1];
...@@ -56,7 +57,7 @@ DOM::Node* FindNodeWithID(int id, DOM::Node* root) { ...@@ -56,7 +57,7 @@ DOM::Node* FindNodeWithID(int id, DOM::Node* root) {
if (id == root->getNodeId()) { if (id == root->getNodeId()) {
return root; return root;
} }
Array<DOM::Node>* children = root->getChildren(nullptr); protocol::Array<DOM::Node>* children = root->getChildren(nullptr);
for (size_t i = 0; i < children->size(); i++) { for (size_t i = 0; i < children->size(); i++) {
if (DOM::Node* node = FindNodeWithID(id, (*children)[i].get())) if (DOM::Node* node = FindNodeWithID(id, (*children)[i].get()))
return node; return node;
...@@ -116,8 +117,8 @@ class DOMAgentTest : public views::ViewsTestBase { ...@@ -116,8 +117,8 @@ class DOMAgentTest : public views::ViewsTestBase {
void SetUp() override { void SetUp() override {
fake_frontend_channel_ = std::make_unique<FakeFrontendChannel>(); fake_frontend_channel_ = std::make_unique<FakeFrontendChannel>();
uber_dispatcher_ = uber_dispatcher_ = std::make_unique<protocol::UberDispatcher>(
std::make_unique<UberDispatcher>(fake_frontend_channel_.get()); fake_frontend_channel_.get());
dom_agent_ = DOMAgentViews::Create(); dom_agent_ = DOMAgentViews::Create();
dom_agent_->Init(uber_dispatcher_.get()); dom_agent_->Init(uber_dispatcher_.get());
css_agent_ = std::make_unique<CSSAgent>(dom_agent_.get()); css_agent_ = std::make_unique<CSSAgent>(dom_agent_.get());
...@@ -197,7 +198,7 @@ class DOMAgentTest : public views::ViewsTestBase { ...@@ -197,7 +198,7 @@ class DOMAgentTest : public views::ViewsTestBase {
return false; return false;
} }
Array<DOM::Node>* children = root->getChildren(nullptr); protocol::Array<DOM::Node>* children = root->getChildren(nullptr);
size_t child_index = 0; size_t child_index = 0;
views::Widget* widget = views::Widget::GetWidgetForNativeView(window); views::Widget* widget = views::Widget::GetWidgetForNativeView(window);
if (widget && if (widget &&
...@@ -221,7 +222,7 @@ class DOMAgentTest : public views::ViewsTestBase { ...@@ -221,7 +222,7 @@ class DOMAgentTest : public views::ViewsTestBase {
return false; return false;
} }
Array<DOM::Node>* children = root->getChildren(nullptr); protocol::Array<DOM::Node>* children = root->getChildren(nullptr);
views::View* root_view = widget->GetRootView(); views::View* root_view = widget->GetRootView();
return root_view return root_view
? ElementTreeMatchesDOMTree(root_view, (*children)[0].get()) ? ElementTreeMatchesDOMTree(root_view, (*children)[0].get())
...@@ -235,7 +236,7 @@ class DOMAgentTest : public views::ViewsTestBase { ...@@ -235,7 +236,7 @@ class DOMAgentTest : public views::ViewsTestBase {
return false; return false;
} }
Array<DOM::Node>* children = root->getChildren(nullptr); protocol::Array<DOM::Node>* children = root->getChildren(nullptr);
std::vector<views::View*> child_views = view->GetChildrenInZOrder(); std::vector<views::View*> child_views = view->GetChildrenInZOrder();
const size_t child_count = child_views.size(); const size_t child_count = child_views.size();
if (child_count != children->size()) if (child_count != children->size())
...@@ -257,7 +258,7 @@ class DOMAgentTest : public views::ViewsTestBase { ...@@ -257,7 +258,7 @@ class DOMAgentTest : public views::ViewsTestBase {
std::unique_ptr<aura::Window> top_window; std::unique_ptr<aura::Window> top_window;
#endif #endif
private: private:
std::unique_ptr<UberDispatcher> uber_dispatcher_; std::unique_ptr<protocol::UberDispatcher> uber_dispatcher_;
std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_; std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_;
std::unique_ptr<DOMAgentViews> dom_agent_; std::unique_ptr<DOMAgentViews> dom_agent_;
std::unique_ptr<CSSAgent> css_agent_; std::unique_ptr<CSSAgent> css_agent_;
......
...@@ -28,8 +28,6 @@ namespace ui_devtools { ...@@ -28,8 +28,6 @@ namespace ui_devtools {
namespace { namespace {
using namespace ui_devtools::protocol;
void DrawRulerText(const base::string16& utf16_text, void DrawRulerText(const base::string16& utf16_text,
const gfx::Point& p, const gfx::Point& p,
gfx::Canvas* canvas, gfx::Canvas* canvas,
...@@ -385,7 +383,7 @@ void OverlayAgentViews::SetPinnedNodeId(int node_id) { ...@@ -385,7 +383,7 @@ void OverlayAgentViews::SetPinnedNodeId(int node_id) {
} }
protocol::Response OverlayAgentViews::setInspectMode( protocol::Response OverlayAgentViews::setInspectMode(
const String& in_mode, const protocol::String& in_mode,
protocol::Maybe<protocol::Overlay::HighlightConfig> in_highlightConfig) { protocol::Maybe<protocol::Overlay::HighlightConfig> in_highlightConfig) {
pinned_id_ = 0; pinned_id_ = 0;
if (in_mode.compare("searchForNode") == 0) { if (in_mode.compare("searchForNode") == 0) {
...@@ -405,7 +403,7 @@ protocol::Response OverlayAgentViews::highlightNode( ...@@ -405,7 +403,7 @@ protocol::Response OverlayAgentViews::highlightNode(
protocol::Response OverlayAgentViews::hideHighlight() { protocol::Response OverlayAgentViews::hideHighlight() {
if (layer_for_highlighting_ && layer_for_highlighting_->visible()) if (layer_for_highlighting_ && layer_for_highlighting_->visible())
layer_for_highlighting_->SetVisible(false); layer_for_highlighting_->SetVisible(false);
return Response::OK(); return protocol::Response::OK();
} }
void OverlayAgentViews::ShowDistancesInHighlightOverlay(int pinned_id, void OverlayAgentViews::ShowDistancesInHighlightOverlay(int pinned_id,
...@@ -467,13 +465,14 @@ void OverlayAgentViews::ShowDistancesInHighlightOverlay(int pinned_id, ...@@ -467,13 +465,14 @@ void OverlayAgentViews::ShowDistancesInHighlightOverlay(int pinned_id,
} }
} }
Response OverlayAgentViews::HighlightNode(int node_id, bool show_size) { protocol::Response OverlayAgentViews::HighlightNode(int node_id,
bool show_size) {
UIElement* element = dom_agent()->GetElementFromNodeId(node_id); UIElement* element = dom_agent()->GetElementFromNodeId(node_id);
if (!element) if (!element)
return Response::Error("No node found with that id"); return protocol::Response::Error("No node found with that id");
if (element->type() == UIElementType::ROOT) if (element->type() == UIElementType::ROOT)
return Response::Error("Cannot highlight root node."); return protocol::Response::Error("Cannot highlight root node.");
if (!layer_for_highlighting_) { if (!layer_for_highlighting_) {
layer_for_highlighting_.reset(new ui::Layer(ui::LayerType::LAYER_TEXTURED)); layer_for_highlighting_.reset(new ui::Layer(ui::LayerType::LAYER_TEXTURED));
...@@ -486,7 +485,7 @@ Response OverlayAgentViews::HighlightNode(int node_id, bool show_size) { ...@@ -486,7 +485,7 @@ Response OverlayAgentViews::HighlightNode(int node_id, bool show_size) {
show_size_on_canvas_ = show_size; show_size_on_canvas_ = show_size;
layer_for_highlighting_->SetVisible( layer_for_highlighting_->SetVisible(
UpdateHighlight(element->GetNodeWindowAndScreenBounds())); UpdateHighlight(element->GetNodeWindowAndScreenBounds()));
return Response::OK(); return protocol::Response::OK();
} }
void OverlayAgentViews::OnMouseEvent(ui::MouseEvent* event) { void OverlayAgentViews::OnMouseEvent(ui::MouseEvent* event) {
......
...@@ -72,8 +72,6 @@ namespace ui_devtools { ...@@ -72,8 +72,6 @@ namespace ui_devtools {
// hierarchy is a tree again can be ambiguous and may not follow the tree // hierarchy is a tree again can be ambiguous and may not follow the tree
// structure. Current approach of handling these states needs revisiting. // structure. Current approach of handling these states needs revisiting.
using namespace ui_devtools::protocol;
DOMAgentViz::DOMAgentViz(viz::FrameSinkManagerImpl* frame_sink_manager) DOMAgentViz::DOMAgentViz(viz::FrameSinkManagerImpl* frame_sink_manager)
: frame_sink_manager_(frame_sink_manager), : frame_sink_manager_(frame_sink_manager),
surface_manager_(frame_sink_manager->surface_manager()) {} surface_manager_(frame_sink_manager->surface_manager()) {}
...@@ -242,10 +240,10 @@ SurfaceElement* DOMAgentViz::GetRootSurfaceElement() { ...@@ -242,10 +240,10 @@ SurfaceElement* DOMAgentViz::GetRootSurfaceElement() {
return it->second.get(); return it->second.get();
} }
std::unique_ptr<DOM::Node> DOMAgentViz::BuildTreeForFrameSink( std::unique_ptr<protocol::DOM::Node> DOMAgentViz::BuildTreeForFrameSink(
UIElement* parent_element, UIElement* parent_element,
const viz::FrameSinkId& parent_id) { const viz::FrameSinkId& parent_id) {
auto children = std::make_unique<Array<DOM::Node>>(); auto children = std::make_unique<protocol::Array<protocol::DOM::Node>>();
// Once the FrameSinkElement is created it calls this function to build its // Once the FrameSinkElement is created it calls this function to build its
// subtree. We iterate through |parent_element|'s children and // subtree. We iterate through |parent_element|'s children and
...@@ -267,10 +265,10 @@ std::unique_ptr<DOM::Node> DOMAgentViz::BuildTreeForFrameSink( ...@@ -267,10 +265,10 @@ std::unique_ptr<DOM::Node> DOMAgentViz::BuildTreeForFrameSink(
std::move(children), parent_element->node_id()); std::move(children), parent_element->node_id());
} }
std::unique_ptr<DOM::Node> DOMAgentViz::BuildTreeForSurface( std::unique_ptr<protocol::DOM::Node> DOMAgentViz::BuildTreeForSurface(
UIElement* parent_element, UIElement* parent_element,
const viz::SurfaceId& parent_id) { const viz::SurfaceId& parent_id) {
auto children = std::make_unique<Array<DOM::Node>>(); auto children = std::make_unique<protocol::Array<protocol::DOM::Node>>();
// Once the SurfaceElement is created it calls this function to build its // Once the SurfaceElement is created it calls this function to build its
// subtree. We iterate through |parent_element|'s children and // subtree. We iterate through |parent_element|'s children and
...@@ -347,7 +345,7 @@ std::vector<UIElement*> DOMAgentViz::CreateChildrenForRoot() { ...@@ -347,7 +345,7 @@ std::vector<UIElement*> DOMAgentViz::CreateChildrenForRoot() {
return children; return children;
} }
std::unique_ptr<DOM::Node> DOMAgentViz::BuildTreeForUIElement( std::unique_ptr<protocol::DOM::Node> DOMAgentViz::BuildTreeForUIElement(
UIElement* ui_element) { UIElement* ui_element) {
if (ui_element->type() == UIElementType::FRAMESINK) { if (ui_element->type() == UIElementType::FRAMESINK) {
return BuildTreeForFrameSink(ui_element, return BuildTreeForFrameSink(ui_element,
......
...@@ -22,7 +22,6 @@ const char* kTestShaderSource = ...@@ -22,7 +22,6 @@ const char* kTestShaderSource =
"" ""
"#include <metal_stdlib>\n" "#include <metal_stdlib>\n"
"#include <simd/simd.h>\n" "#include <simd/simd.h>\n"
"using namespace metal;\n"
"typedef struct {\n" "typedef struct {\n"
" float4 clipSpacePosition [[position]];\n" " float4 clipSpacePosition [[position]];\n"
" float4 color;\n" " float4 color;\n"
......
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