reland: chromeos: add SingleProcessMash mode

This makes Ash create an Env if passed SingleProcessMash. In addition this
makes all window creation go through a factory that ensures the right env is
supplied.

See https://docs.google.com/document/d/11ha_KioDdXe4iZS2AML1foKnCJlNKm7Q1hFr6VW8dV4/edit
for more details.

This also adds the feature to ui/base.

BUG=847992
TEST=covered by tests
[email protected]

Change-Id: I446ba2dd7a05702cfca41a0e0d657d6606cc28e5
Reviewed-on: https://chromium-review.googlesource.com/1172054
Reviewed-by: Scott Violet <[email protected]>
Commit-Queue: Scott Violet <[email protected]>
Cr-Commit-Position: refs/heads/master@{#582454}
diff --git a/ash/window_user_data_unittest.cc b/ash/window_user_data_unittest.cc
index 352d584..1ee1dc3 100644
--- a/ash/window_user_data_unittest.cc
+++ b/ash/window_user_data_unittest.cc
@@ -7,6 +7,7 @@
 #include <memory>
 
 #include "ash/test/ash_test_base.h"
+#include "ash/window_factory.h"
 #include "ash/window_user_data.h"
 #include "ui/aura/window.h"
 #include "ui/compositor/layer_type.h"
@@ -34,10 +35,10 @@
 // Verifies clear() deletes the data associated with a window.
 TEST_F(WindowUserDataTest, ClearDestroys) {
   WindowUserData<Data> user_data;
-  aura::Window window(nullptr, aura::client::WINDOW_TYPE_UNKNOWN);
-  window.Init(ui::LAYER_NOT_DRAWN);
+  std::unique_ptr<aura::Window> window = window_factory::NewWindow();
+  window->Init(ui::LAYER_NOT_DRAWN);
   bool data_deleted = false;
-  user_data.Set(&window, std::make_unique<Data>(&data_deleted));
+  user_data.Set(window.get(), std::make_unique<Data>(&data_deleted));
   EXPECT_FALSE(data_deleted);
   user_data.clear();
   EXPECT_TRUE(data_deleted);
@@ -46,8 +47,7 @@
 // Verifies Set() called with an existing window replaces the existing data.
 TEST_F(WindowUserDataTest, ReplaceDestroys) {
   WindowUserData<Data> user_data;
-  std::unique_ptr<aura::Window> window(std::make_unique<aura::Window>(
-      nullptr, aura::client::WINDOW_TYPE_UNKNOWN));
+  std::unique_ptr<aura::Window> window = window_factory::NewWindow();
   window->Init(ui::LAYER_NOT_DRAWN);
   bool data1_deleted = false;
   user_data.Set(window.get(), std::make_unique<Data>(&data1_deleted));
@@ -66,12 +66,12 @@
 // Verifies Set() with null deletes existing data.
 TEST_F(WindowUserDataTest, NullClears) {
   WindowUserData<Data> user_data;
-  aura::Window window(nullptr, aura::client::WINDOW_TYPE_UNKNOWN);
-  window.Init(ui::LAYER_NOT_DRAWN);
+  std::unique_ptr<aura::Window> window = window_factory::NewWindow();
+  window->Init(ui::LAYER_NOT_DRAWN);
   bool data1_deleted = false;
-  user_data.Set(&window, std::make_unique<Data>(&data1_deleted));
+  user_data.Set(window.get(), std::make_unique<Data>(&data1_deleted));
   EXPECT_FALSE(data1_deleted);
-  user_data.Set(&window, nullptr);
+  user_data.Set(window.get(), nullptr);
   EXPECT_TRUE(data1_deleted);
   EXPECT_TRUE(user_data.GetWindows().empty());
 }