Commit f933e705 authored by Alexander Alekseev's avatar Alexander Alekseev Committed by Commit Bot

Chrome OS: Add Discover window UI.

This CL adds Chrome OS Discover UI in separate window.

Window need further changes to match the specs, but this
change mostly adds infrastructure.

Bug: 864686

Change-Id: I2834d8f9efb3660050a31768508992acb1f3f262
Reviewed-on: https://chromium-review.googlesource.com/1182880
Commit-Queue: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586034}
parent 71d55291
......@@ -24,6 +24,9 @@ constexpr char kInternalAppIdContinueReading[] =
// Generated as crx_file::id_util::GenerateId("org.chromium.camera").
constexpr char kInternalAppIdCamera[] = "iniodglblcgmngkgdipeiclkdjjpnlbn";
// Generated as crx_file::id_util::GenerateId("org.chromium.discover").
constexpr char kInternalAppIdDiscover[] = "pjdncmlmjhcebmcacdddfacepcjmfaoo";
} // namespace app_list
#endif // ASH_PUBLIC_CPP_APP_LIST_INTERNAL_APP_ID_CONSTANTS_H_
......@@ -18,6 +18,7 @@
<include name="IDR_SHORTCUT_VIEWER_LOGO_192" file="unscaled_resources/shortcut_viewer_logo_192.png" type="BINDATA" />
<include name="IDR_SETTINGS_LOGO_192" file="unscaled_resources/settings_logo_192.png" type="BINDATA" />
<include name="IDR_CAMERA_LOGO_192" file="unscaled_resources/camera_logo_192.png" type="BINDATA" />
<include name="IDR_DISCOVER_APP_192" file="unscaled_resources/discover_app_logo_192.png" type="BINDATA" />
</includes>
</release>
</grit>
......@@ -5053,6 +5053,9 @@
<message name="IDS_INTERNAL_APP_CAMERA" desc="The name of the Camera app in the app list.">
Camera
</message>
<message name="IDS_INTERNAL_APP_DISCOVER" desc="Name for the Discover app in the app list.">
Discover
</message>
<!-- Launcher Settings shortcuts -->
<message name="IDS_LAUNCHER_SHORTCUTS_BLUETOOTH" desc="The name of bluetooth shortcut.">
......
......@@ -38,8 +38,8 @@
<structure name="IDR_OOBE_ENROLLMENT_CSS" file="resources\chromeos\login\oobe_screen_oauth_enrollment.css" flattenhtml="true" type="chrome_html" />
<structure name="IDR_OOBE_ENROLLMENT_JS" file="resources\chromeos\login\oobe_screen_oauth_enrollment.js" flattenhtml="true" type="chrome_html" />
<structure name="IDR_KEYBOARD_UTILS_JS" file="resources\chromeos\keyboard\keyboard_utils.js" flattenhtml="true" type="chrome_html" />
<structure name="IDR_CHROMEOS_DISCOVER_HTML" file="resources\chromeos\login\discover\discover_app.html" flattenhtml="true" type="chrome_html"/>
<structure name="IDR_CHROMEOS_DISCOVER_JS" file="resources\chromeos\login\discover\discover_app.js" flattenhtml="true" type="chrome_html"/>
<structure name="IDR_CHROMEOS_DISCOVER_APP_HTML" file="resources\chromeos\login\discover\discover_app.html" flattenhtml="true" type="chrome_html"/>
<structure name="IDR_CHROMEOS_DISCOVER_APP_JS" file="resources\chromeos\login\discover\discover_app.js" flattenhtml="true" type="chrome_html"/>
<structure name="IDR_CUSTOM_ELEMENTS_OOBE_HTML" file="resources\chromeos\login\custom_elements_oobe.html" flattenhtml="true" type="chrome_html" />
<structure name="IDR_CUSTOM_ELEMENTS_OOBE_JS" file="resources\chromeos\login\custom_elements_oobe.js" flattenhtml="true" type="chrome_html" />
<structure name="IDR_CUSTOM_ELEMENTS_LOCK_HTML" file="resources\chromeos\login\custom_elements_lock.html" flattenhtml="true" type="chrome_html" />
......
......@@ -1805,6 +1805,8 @@ jumbo_split_static_library("ui") {
"ash/launcher/chrome_launcher_controller.h",
"ash/launcher/chrome_launcher_controller_util.cc",
"ash/launcher/chrome_launcher_controller_util.h",
"ash/launcher/discover_window_observer.cc",
"ash/launcher/discover_window_observer.h",
"ash/launcher/extension_app_window_launcher_controller.cc",
"ash/launcher/extension_app_window_launcher_controller.h",
"ash/launcher/extension_app_window_launcher_item_controller.cc",
......@@ -1987,6 +1989,9 @@ jumbo_split_static_library("ui") {
"webui/chromeos/login/discover/discover_manager.h",
"webui/chromeos/login/discover/discover_ui.cc",
"webui/chromeos/login/discover/discover_ui.h",
"webui/chromeos/login/discover/discover_window_manager.cc",
"webui/chromeos/login/discover/discover_window_manager.h",
"webui/chromeos/login/discover/discover_window_manager_observer.h",
"webui/chromeos/login/discover/modules/discover_module_welcome.cc",
"webui/chromeos/login/discover/modules/discover_module_welcome.h",
"webui/chromeos/login/discover_screen_handler.cc",
......
......@@ -7,6 +7,7 @@
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
#include "base/logging.h"
#include "base/metrics/user_metrics.h"
#include "base/no_destructor.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
......@@ -41,6 +42,10 @@
#include "ui/gfx/image/image_skia_operations.h"
#include "url/gurl.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h"
#endif
namespace app_list {
namespace {
......@@ -73,7 +78,14 @@ const std::vector<InternalApp>& GetInternalAppList(bool is_guest_mode) {
/*recommendable=*/true,
/*searchable=*/false,
/*show_in_launcher=*/false, InternalAppName::kContinueReading,
/*searchable_string_resource_id=*/0}});
/*searchable_string_resource_id=*/0},
{kInternalAppIdDiscover, IDS_INTERNAL_APP_DISCOVER,
IDR_DISCOVER_APP_192,
/*recommendable=*/false,
/*searchable=*/true,
/*show_in_launcher=*/true, InternalAppName::kDiscover,
/*searchable_string_resource_id=*/IDS_INTERNAL_APP_DISCOVER}});
static base::NoDestructor<std::vector<InternalApp>> internal_app_list;
internal_app_list->clear();
......@@ -164,6 +176,12 @@ void OpenInternalApp(const std::string& app_id,
chrome::ShowSettingsSubPageForProfile(profile, std::string());
} else if (app_id == kInternalAppIdCamera) {
ShowCameraApp(app_id, profile, event_flags);
} else if (app_id == kInternalAppIdDiscover) {
#if defined(OS_CHROMEOS)
base::RecordAction(base::UserMetricsAction("ShowDiscover"));
chromeos::DiscoverWindowManager::GetInstance()
->ShowChromeDiscoverPageForProfile(profile);
#endif
}
}
......
......@@ -22,7 +22,8 @@ enum class InternalAppName {
kSettings = 1,
kContinueReading = 2,
kCamera = 3,
kMaxValue = kCamera,
kDiscover = 4,
kMaxValue = kDiscover,
};
// Metadata about an internal app.
......
......@@ -20,6 +20,7 @@
#include "chrome/browser/ui/app_list/app_list_syncable_service.h"
#include "chrome/browser/ui/app_list/app_sync_ui_state_observer.h"
#include "chrome/browser/ui/ash/launcher/crostini_app_window_shelf_controller.h"
#include "chrome/browser/ui/ash/launcher/discover_window_observer.h"
#include "chrome/browser/ui/ash/launcher/launcher_app_updater.h"
#include "chrome/browser/ui/ash/launcher/settings_window_observer.h"
#include "components/prefs/pref_change_registrar.h"
......@@ -404,6 +405,10 @@ class ChromeLauncherController
// An observer that manages the shelf title and icon for settings windows.
SettingsWindowObserver settings_window_observer_;
// An observer that manages the shelf title and icon for Chrome OS Discover
// windows.
DiscoverWindowObserver dicover_window_observer_;
// Used to load the images for app items.
std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/launcher/discover_window_observer.h"
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
#include "ash/public/cpp/shelf_item.h"
#include "ash/public/cpp/window_properties.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
#include "services/ui/public/interfaces/window_manager.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/base/class_property.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
namespace {
// A helper class that updates the title of Chrome OS Discover browser windows.
class AuraWindowDiscoverTitleTracker : public aura::WindowTracker {
public:
AuraWindowDiscoverTitleTracker() = default;
~AuraWindowDiscoverTitleTracker() override = default;
// aura::WindowTracker:
void OnWindowTitleChanged(aura::Window* window) override {
// Name the window "Discover" instead of "Google Chrome - Discover".
window->SetTitle(l10n_util::GetStringUTF16(IDS_INTERNAL_APP_DISCOVER));
}
private:
DISALLOW_COPY_AND_ASSIGN(AuraWindowDiscoverTitleTracker);
};
} // namespace
DiscoverWindowObserver::DiscoverWindowObserver() {
aura_window_tracker_ = std::make_unique<AuraWindowDiscoverTitleTracker>();
chromeos::DiscoverWindowManager::GetInstance()->AddObserver(this);
}
DiscoverWindowObserver::~DiscoverWindowObserver() {
chromeos::DiscoverWindowManager::GetInstance()->RemoveObserver(this);
}
void DiscoverWindowObserver::OnNewDiscoverWindow(Browser* discover_browser) {
aura::Window* window = discover_browser->window()->GetNativeWindow();
window->SetTitle(l10n_util::GetStringUTF16(IDS_INTERNAL_APP_DISCOVER));
const ash::ShelfID shelf_id(app_list::kInternalAppIdDiscover);
window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize()));
window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_APP);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
// The new gfx::ImageSkia instance is owned by the window itself.
window->SetProperty(
aura::client::kWindowIconKey,
new gfx::ImageSkia(*rb.GetImageSkiaNamed(IDR_DISCOVER_APP_192)));
aura_window_tracker_->Add(window);
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_DISCOVER_WINDOW_OBSERVER_H_
#define CHROME_BROWSER_UI_ASH_LAUNCHER_DISCOVER_WINDOW_OBSERVER_H_
#include <memory>
#include "base/macros.h"
#include "chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager_observer.h"
#include "ui/aura/window_tracker.h"
// Sets the window title and shelf item properties for Discover windows.
class DiscoverWindowObserver : public chromeos::DiscoverWindowManagerObserver {
public:
DiscoverWindowObserver();
~DiscoverWindowObserver() override;
// chromeos::DiscoverWindowManagerObserver:
void OnNewDiscoverWindow(Browser* discover_browser) override;
private:
// Set of windows whose title is forced to 'Settings.'
std::unique_ptr<aura::WindowTracker> aura_window_tracker_;
DISALLOW_COPY_AND_ASSIGN(DiscoverWindowObserver);
};
#endif // CHROME_BROWSER_UI_ASH_LAUNCHER_DISCOVER_WINDOW_OBSERVER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager_observer.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_contents.h"
#include "ui/gfx/geometry/rect.h"
#include "url/gurl.h"
namespace chromeos {
// static
DiscoverWindowManager* DiscoverWindowManager::GetInstance() {
static base::NoDestructor<DiscoverWindowManager> window_manager;
return window_manager.get();
}
void DiscoverWindowManager::AddObserver(
DiscoverWindowManagerObserver* observer) {
observers_.AddObserver(observer);
}
void DiscoverWindowManager::RemoveObserver(
const DiscoverWindowManagerObserver* observer) {
observers_.RemoveObserver(observer);
}
void DiscoverWindowManager::ShowChromeDiscoverPageForProfile(Profile* profile) {
const GURL gurl(chrome::kChromeUIDiscoverURL);
// Use the original (non off-the-record) profile for discover unless
// this is a guest session.
if (!profile->IsGuestSession() && profile->IsOffTheRecord())
profile = profile->GetOriginalProfile();
// Look for an existing browser window.
Browser* browser = FindBrowserForProfile(profile);
if (browser) {
DCHECK(browser->profile() == profile);
const content::WebContents* web_contents =
browser->tab_strip_model()->GetWebContentsAt(0);
if (web_contents && web_contents->GetURL() == gurl) {
browser->window()->Show();
return;
}
NavigateParams params(browser, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK);
params.window_action = NavigateParams::SHOW_WINDOW;
params.user_gesture = true;
Navigate(&params);
return;
}
// No existing browser window, create one.
NavigateParams params(profile, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK);
params.disposition = WindowOpenDisposition::NEW_POPUP;
params.trusted_source = true;
params.window_action = NavigateParams::SHOW_WINDOW;
params.user_gesture = true;
params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE;
// Adjust window size by the title bar size.
// TODO(https://crbug.com/864686): remove this.
params.window_bounds = gfx::Rect(768, 640 + 32 /* FIXMEalemate) */);
Navigate(&params);
// operator[] not used because SessionID has no default constructor.
discover_session_map_.emplace(profile, SessionID::InvalidValue())
.first->second = params.browser->session_id();
DCHECK(params.browser->is_trusted_source());
for (DiscoverWindowManagerObserver& observer : observers_)
observer.OnNewDiscoverWindow(params.browser);
}
Browser* DiscoverWindowManager::FindBrowserForProfile(Profile* profile) {
ProfileSessionMap::iterator iter = discover_session_map_.find(profile);
if (iter != discover_session_map_.end())
return chrome::FindBrowserWithID(iter->second);
return nullptr;
}
bool DiscoverWindowManager::IsDiscoverBrowser(Browser* browser) const {
ProfileSessionMap::const_iterator iter =
discover_session_map_.find(browser->profile());
return (iter != discover_session_map_.end() &&
iter->second == browser->session_id());
}
DiscoverWindowManager::DiscoverWindowManager() = default;
DiscoverWindowManager::~DiscoverWindowManager() = default;
} // namespace chromeos
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_H_
#include <map>
#include "base/macros.h"
#include "base/no_destructor.h"
#include "base/observer_list.h"
#include "components/sessions/core/session_id.h"
class Browser;
class Profile;
namespace chromeos {
class DiscoverWindowManagerObserver;
// Manages Discover windows for CrOS. Each Profile is associated with a single
// Browser window for Discover UI that will be created when the separate
// Discover App is first opened.
class DiscoverWindowManager {
public:
static DiscoverWindowManager* GetInstance();
void AddObserver(DiscoverWindowManagerObserver* observer);
void RemoveObserver(const DiscoverWindowManagerObserver* observer);
// Shows a chrome://oobe/discover/ page in an an existing system
// Browser window for |profile| or creates a new one.
void ShowChromeDiscoverPageForProfile(Profile* profile);
// If a Browser Discover app window for |profile| has already been created,
// returns it, otherwise returns NULL.
Browser* FindBrowserForProfile(Profile* profile);
// Returns true if |browser| is a Discover app window.
bool IsDiscoverBrowser(Browser* browser) const;
private:
friend class base::NoDestructor<DiscoverWindowManager>;
using ProfileSessionMap = std::map<Profile*, SessionID>;
DiscoverWindowManager();
~DiscoverWindowManager();
base::ObserverList<DiscoverWindowManagerObserver> observers_;
ProfileSessionMap discover_session_map_;
DISALLOW_COPY_AND_ASSIGN(DiscoverWindowManager);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_OBSERVER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_OBSERVER_H_
#include "base/observer_list_types.h"
class Browser;
namespace chromeos {
class DiscoverWindowManagerObserver : public base::CheckedObserver {
public:
// Called when a new Discover App browser window is created.
virtual void OnNewDiscoverWindow(Browser* discover_browser) = 0;
protected:
~DiscoverWindowManagerObserver() override = default;
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_OBSERVER_H_
......@@ -100,9 +100,9 @@ namespace chromeos {
namespace {
const char* kKnownDisplayTypes[] = {
OobeUI::kAppLaunchSplashDisplay,
const char* kKnownDisplayTypes[] = {OobeUI::kAppLaunchSplashDisplay,
OobeUI::kArcKioskSplashDisplay,
OobeUI::kDiscoverDisplay,
OobeUI::kGaiaSigninDisplay,
OobeUI::kLockDisplay,
OobeUI::kLoginDisplay,
......@@ -119,6 +119,7 @@ constexpr char kCustomElementsHTMLPath[] = "custom_elements.html";
constexpr char kCustomElementsJSPath[] = "custom_elements.js";
constexpr char kCustomElementsUserPodHTMLPath[] =
"custom_elements_user_pod.html";
constexpr char kDiscoverJSPath[] = "discover_app.js";
constexpr char kKeyboardUtilsJSPath[] = "keyboard_utils.js";
constexpr char kLockJSPath[] = "lock.js";
constexpr char kLoginJSPath[] = "login.js";
......@@ -185,6 +186,7 @@ void AddEnterpriseEnrollmentResources(content::WebUIDataSource* source) {
}
// Default and non-shared resource definition for kOobeDisplay display type.
// chrome://oobe/oobe
void AddOobeDisplayTypeDefaultResources(content::WebUIDataSource* source) {
source->SetDefaultResource(IDR_OOBE_HTML);
source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS);
......@@ -193,6 +195,8 @@ void AddOobeDisplayTypeDefaultResources(content::WebUIDataSource* source) {
source->AddResourcePath(kCustomElementsJSPath, IDR_CUSTOM_ELEMENTS_OOBE_JS);
}
// Default and non-shared resource definition for kLockDisplay display type.
// chrome://oobe/lock
void AddLockDisplayTypeDefaultResources(content::WebUIDataSource* source) {
// TODO(crbug.com/810170): Remove the resource files associated with
// kShowNonMdLogin switch (IDR_LOCK_HTML/JS and IDR_LOGIN_HTML/JS and the
......@@ -202,18 +206,23 @@ void AddLockDisplayTypeDefaultResources(content::WebUIDataSource* source) {
source->AddResourcePath(kCustomElementsHTMLPath,
IDR_CUSTOM_ELEMENTS_LOCK_HTML);
source->AddResourcePath(kCustomElementsJSPath, IDR_CUSTOM_ELEMENTS_LOCK_JS);
source->AddResourcePath(kCustomElementsUserPodHTMLPath,
IDR_CUSTOM_ELEMENTS_USER_POD_HTML);
}
// Default and non-shared resource definition for kDiscoverDisplay display type.
// chrome://oobe/discover
void AddDiscoverDisplayTypeDefaultResources(content::WebUIDataSource* source) {
source->SetDefaultResource(IDR_CHROMEOS_DISCOVER_APP_HTML);
source->AddResourcePath(kDiscoverJSPath, IDR_CHROMEOS_DISCOVER_APP_JS);
}
// Default and non-shared resource definition for kLoginDisplay display type.
// chrome://oobe/login
void AddLoginDisplayTypeDefaultResources(content::WebUIDataSource* source) {
source->SetDefaultResource(IDR_MD_LOGIN_HTML);
source->AddResourcePath(kLoginJSPath, IDR_MD_LOGIN_JS);
source->AddResourcePath(kCustomElementsHTMLPath,
IDR_CUSTOM_ELEMENTS_LOGIN_HTML);
source->AddResourcePath(kCustomElementsJSPath, IDR_CUSTOM_ELEMENTS_LOGIN_JS);
source->AddResourcePath(kCustomElementsUserPodHTMLPath,
IDR_CUSTOM_ELEMENTS_USER_POD_HTML);
}
// Creates a WebUIDataSource for chrome://oobe
......@@ -233,6 +242,8 @@ content::WebUIDataSource* CreateOobeUIDataSource(
AddOobeDisplayTypeDefaultResources(source);
} else if (display_type == OobeUI::kLockDisplay) {
AddLockDisplayTypeDefaultResources(source);
} else if (display_type == OobeUI::kDiscoverDisplay) {
AddDiscoverDisplayTypeDefaultResources(source);
} else {
AddLoginDisplayTypeDefaultResources(source);
}
......@@ -245,6 +256,11 @@ content::WebUIDataSource* CreateOobeUIDataSource(
AddArcScreensResources(source);
AddEnterpriseEnrollmentResources(source);
}
if (display_type == OobeUI::kLockDisplay ||
display_type == OobeUI::kLoginDisplay) {
source->AddResourcePath(kCustomElementsUserPodHTMLPath,
IDR_CUSTOM_ELEMENTS_USER_POD_HTML);
}
source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS);
source->OverrideContentSecurityPolicyChildSrc(base::StringPrintf(
......@@ -263,6 +279,7 @@ content::WebUIDataSource* CreateOobeUIDataSource(
std::string GetDisplayType(const GURL& url) {
std::string path = url.path().size() ? url.path().substr(1) : "";
if (std::find(kKnownDisplayTypes,
kKnownDisplayTypes + arraysize(kKnownDisplayTypes),
path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) {
......@@ -283,28 +300,19 @@ bool IsRemoraRequisitioned() {
} // namespace
// static
const char OobeUI::kOobeDisplay[] = "oobe";
const char OobeUI::kLoginDisplay[] = "login";
const char OobeUI::kLockDisplay[] = "lock";
const char OobeUI::kUserAddingDisplay[] = "user-adding";
const char OobeUI::kAppLaunchSplashDisplay[] = "app-launch-splash";
const char OobeUI::kArcKioskSplashDisplay[] = "arc-kiosk-splash";
const char OobeUI::kDiscoverDisplay[] = "discover";
const char OobeUI::kGaiaSigninDisplay[] = "gaia-signin";
const char OobeUI::kLockDisplay[] = "lock";
const char OobeUI::kLoginDisplay[] = "login";
const char OobeUI::kOobeDisplay[] = "oobe";
const char OobeUI::kUserAddingDisplay[] = "user-adding";
OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
: WebUIController(web_ui) {
display_type_ = GetDisplayType(url);
void OobeUI::ConfigureOobeDisplay() {
network_state_informer_ = new NetworkStateInformer();
network_state_informer_->Init();
js_calls_container = std::make_unique<JSCallsContainer>();
auto core_handler =
std::make_unique<CoreOobeHandler>(this, js_calls_container.get());
core_handler_ = core_handler.get();
AddWebUIHandler(std::move(core_handler));
AddWebUIHandler(std::make_unique<NetworkDropdownHandler>());
AddScreenHandler(std::make_unique<UpdateScreenHandler>());
......@@ -363,8 +371,6 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
AddScreenHandler(std::make_unique<DemoPreferencesScreenHandler>());
AddScreenHandler(std::make_unique<DiscoverScreenHandler>());
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
ActiveDirectoryPasswordChangeScreenHandler*
......@@ -415,12 +421,9 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
auto kiosk_app_menu_handler =
std::make_unique<KioskAppMenuHandler>(network_state_informer_);
kiosk_app_menu_handler_ = kiosk_app_menu_handler.get();
web_ui->AddMessageHandler(std::move(kiosk_app_menu_handler));
base::DictionaryValue localized_strings;
GetLocalizedStrings(&localized_strings);
web_ui()->AddMessageHandler(std::move(kiosk_app_menu_handler));
Profile* profile = Profile::FromWebUI(web_ui);
Profile* profile = Profile::FromWebUI(web_ui());
// Set up the chrome://theme/ source, for Chrome logo.
ThemeSource* theme = new ThemeSource(profile);
content::URLDataSource::Add(profile, theme);
......@@ -430,23 +433,46 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
new AboutUIHTMLSource(chrome::kChromeUITermsHost, profile);
content::URLDataSource::Add(profile, about_source);
// Set up the chrome://oobe/ source.
content::WebUIDataSource* html_source =
CreateOobeUIDataSource(localized_strings, display_type_);
content::WebUIDataSource::Add(profile, html_source);
// Set up the chrome://userimage/ source.
UserImageSource* user_image_source = new UserImageSource();
content::URLDataSource::Add(profile, user_image_source);
// TabHelper is required for OOBE webui to make webview working on it.
content::WebContents* contents = web_ui->GetWebContents();
content::WebContents* contents = web_ui()->GetWebContents();
extensions::TabHelper::CreateForWebContents(contents);
if (IsRemoraRequisitioned())
oobe_display_chooser_ = std::make_unique<OobeDisplayChooser>();
}
OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
: WebUIController(web_ui) {
display_type_ = GetDisplayType(url);
js_calls_container = std::make_unique<JSCallsContainer>();
auto core_handler =
std::make_unique<CoreOobeHandler>(this, js_calls_container.get());
core_handler_ = core_handler.get();
AddWebUIHandler(std::move(core_handler));
if (display_type_ != OobeUI::kDiscoverDisplay)
ConfigureOobeDisplay();
if (display_type_ != OobeUI::kLockDisplay) {
AddScreenHandler(std::make_unique<DiscoverScreenHandler>());
}
base::DictionaryValue localized_strings;
GetLocalizedStrings(&localized_strings);
// Set up the chrome://oobe/ source.
content::WebUIDataSource* html_source =
CreateOobeUIDataSource(localized_strings, display_type_);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
}
OobeUI::~OobeUI() {
}
......
......@@ -218,6 +218,10 @@ class OobeUI : public content::WebUIController,
void AddWebUIHandler(std::unique_ptr<BaseWebUIHandler> handler);
void AddScreenHandler(std::unique_ptr<BaseScreenHandler> handler);
// Configures all the relevant screen shandlers and resources for OOBE/Login
// display type.
void ConfigureOobeDisplay();
// Type of UI.
std::string display_type_;
......
......@@ -194,6 +194,7 @@ const char kChromeUICertificateManagerDialogURL[] =
const char kChromeUICertificateManagerHost[] = "certificate-manager";
const char kChromeUICryptohomeHost[] = "cryptohome";
const char kChromeUIDeviceEmulatorHost[] = "device-emulator";
const char kChromeUIDiscoverURL[] = "chrome://oobe/discover";
const char kChromeUIFirstRunHost[] = "first-run";
const char kChromeUIFirstRunURL[] = "chrome://first-run/";
const char kChromeUIIntenetConfigDialogURL[] =
......
......@@ -191,6 +191,7 @@ extern const char kChromeUICertificateManagerDialogURL[];
extern const char kChromeUICertificateManagerHost[];
extern const char kChromeUICryptohomeHost[];
extern const char kChromeUIDeviceEmulatorHost[];
extern const char kChromeUIDiscoverURL[];
extern const char kChromeUIFirstRunHost[];
extern const char kChromeUIFirstRunURL[];
extern const char kChromeUIIntenetConfigDialogURL[];
......
......@@ -16211,6 +16211,14 @@ should be able to be added at any place in this file.
<description>Please enter the description of this user action.</description>
</action>
<action name="ShowDiscover">
<owner>alemate@chromium.org</owner>
<owner>zalcorn@chromium.org</owner>
<description>
The Chrome OS Discover App was displayed to the user.
</description>
</action>
<action name="ShowDisplayOptions">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
......
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