Commit 95b906e5 authored by Hidehiko Abe's avatar Hidehiko Abe Committed by Commit Bot

Replace chrome::NewEmptyWindow by ash::NewWindowDelegate.

This is preparation to support LaCrOS Chrome.

BUG=chromium:1043804
TEST=Ran tryjob.

Change-Id: I6036f44cedab76560d6d1c0031aa030870707a11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2084774Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarNancy Wang <nancylingwang@chromium.org>
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759614}
parent d591a086
......@@ -10,6 +10,7 @@
#include <vector>
#include "ash/public/cpp/app_list/app_list_controller.h"
#include "ash/public/cpp/new_window_delegate.h"
#include "ash/public/cpp/tablet_mode.h"
#include "base/bind.h"
#include "base/metrics/histogram_functions.h"
......@@ -482,11 +483,8 @@ AppListControllerDelegate::Pinnable AppListClientImpl::GetPinnable(
ChromeLauncherController::instance()->profile());
}
void AppListClientImpl::CreateNewWindow(Profile* profile, bool incognito) {
if (incognito)
chrome::NewEmptyWindow(profile->GetPrimaryOTRProfile());
else
chrome::NewEmptyWindow(profile);
void AppListClientImpl::CreateNewWindow(bool incognito) {
ash::NewWindowDelegate::GetInstance()->NewWindow(incognito);
}
void AppListClientImpl::OpenURL(Profile* profile,
......
......@@ -108,7 +108,7 @@ class AppListClientImpl
void PinApp(const std::string& app_id) override;
void UnpinApp(const std::string& app_id) override;
Pinnable GetPinnable(const std::string& app_id) override;
void CreateNewWindow(Profile* profile, bool incognito) override;
void CreateNewWindow(bool incognito) override;
void OpenURL(Profile* profile,
const GURL& url,
ui::PageTransition transition,
......
......@@ -182,10 +182,10 @@ IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest, CreateNewWindow) {
EXPECT_EQ(0U, chrome::GetBrowserCount(
browser()->profile()->GetPrimaryOTRProfile()));
controller->CreateNewWindow(browser()->profile(), false);
controller->CreateNewWindow(/*incognito=*/false);
EXPECT_EQ(2U, chrome::GetBrowserCount(browser()->profile()));
controller->CreateNewWindow(browser()->profile(), true);
controller->CreateNewWindow(/*incognito=*/true);
EXPECT_EQ(1U, chrome::GetBrowserCount(
browser()->profile()->GetPrimaryOTRProfile()));
}
......@@ -337,7 +337,7 @@ IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest,
// Create an incognito browser so that we can close the regular one without
// exiting the test.
controller->CreateNewWindow(profile, true);
controller->CreateNewWindow(/*incognito=*/true);
EXPECT_EQ(1U, chrome::GetBrowserCount(profile_otr));
// Creating incognito browser should not update the launch time.
EXPECT_EQ(time_recorded1,
......@@ -352,7 +352,7 @@ IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest,
// Launch another regular browser.
const base::Time time_before_launch = base::Time::Now();
controller->CreateNewWindow(profile, false);
controller->CreateNewWindow(/*incognito=*/false);
const base::Time time_after_launch = base::Time::Now();
EXPECT_EQ(1U, chrome::GetBrowserCount(profile));
......@@ -362,7 +362,7 @@ IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest,
EXPECT_GE(time_after_launch, time_recorded2);
// Creating a second regular browser should not update the launch time.
controller->CreateNewWindow(profile, false);
controller->CreateNewWindow(/*incognito=*/false);
EXPECT_EQ(2U, chrome::GetBrowserCount(profile));
EXPECT_EQ(time_recorded2,
prefs->GetLastLaunchTime(extension_misc::kChromeAppId));
......
......@@ -82,7 +82,7 @@ class AppListControllerDelegate {
// Handle the "create window" context menu items of Chrome App.
// |incognito| is true to create an incognito window.
virtual void CreateNewWindow(Profile* profile, bool incognito) = 0;
virtual void CreateNewWindow(bool incognito) = 0;
// Opens the URL.
virtual void OpenURL(Profile* profile,
......
......@@ -113,11 +113,11 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) {
break;
case ash::APP_CONTEXT_MENU_NEW_WINDOW:
controller()->CreateNewWindow(profile(), false);
controller()->CreateNewWindow(/*incognito=*/false);
break;
case ash::APP_CONTEXT_MENU_NEW_INCOGNITO_WINDOW:
controller()->CreateNewWindow(profile(), true);
controller()->CreateNewWindow(/*incognito=*/true);
break;
case ash::STOP_APP:
......
......@@ -203,9 +203,9 @@ void ExtensionAppContextMenu::ExecuteCommand(int command_id, int event_flags) {
extension_menu_items_->ExecuteCommand(command_id, nullptr, nullptr,
content::ContextMenuParams());
} else if (command_id == ash::APP_CONTEXT_MENU_NEW_WINDOW) {
controller()->CreateNewWindow(profile(), false);
controller()->CreateNewWindow(/*incognito=*/false);
} else if (command_id == ash::APP_CONTEXT_MENU_NEW_INCOGNITO_WINDOW) {
controller()->CreateNewWindow(profile(), true);
controller()->CreateNewWindow(/*incognito=*/true);
} else {
AppContextMenu::ExecuteCommand(command_id, event_flags);
}
......
......@@ -51,9 +51,7 @@ void TestAppListControllerDelegate::DoShowAppInfoFlow(
const std::string& extension_id) {
}
void TestAppListControllerDelegate::CreateNewWindow(Profile* profile,
bool incognito) {
}
void TestAppListControllerDelegate::CreateNewWindow(bool incognito) {}
void TestAppListControllerDelegate::OpenURL(Profile* profile,
const GURL& url,
......
......@@ -26,7 +26,7 @@ class TestAppListControllerDelegate : public AppListControllerDelegate {
bool IsAppOpen(const std::string& app_id) const override;
void DoShowAppInfoFlow(Profile* profile,
const std::string& extension_id) override;
void CreateNewWindow(Profile* profile, bool incognito) override;
void CreateNewWindow(bool incognito) override;
void OpenURL(Profile* profile,
const GURL& url,
ui::PageTransition transition,
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/ui/ash/launcher/app_service/app_service_shelf_context_menu.h"
#include "ash/public/cpp/app_menu_constants.h"
#include "ash/public/cpp/new_window_delegate.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
......@@ -130,11 +131,11 @@ void AppServiceShelfContextMenu::ExecuteCommand(int command_id,
ShelfContextMenu::ExecuteCommand(ash::MENU_OPEN_NEW, event_flags);
return;
}
chrome::NewEmptyWindow(controller()->profile());
ash::NewWindowDelegate::GetInstance()->NewWindow(/*incognito=*/false);
break;
case ash::MENU_NEW_INCOGNITO_WINDOW:
chrome::NewEmptyWindow(controller()->profile()->GetOffTheRecordProfile());
ash::NewWindowDelegate::GetInstance()->NewWindow(/*incognito=*/true);
break;
case ash::STOP_APP:
......
......@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
#include "ash/public/cpp/new_window_delegate.h"
#include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/wm/desks/desks_util.h"
......@@ -198,7 +199,7 @@ void BrowserShortcutLauncherItemController::ItemSelected(
ash::ShelfLaunchSource source,
ItemSelectedCallback callback) {
if (event && (event->flags() & ui::EF_CONTROL_DOWN)) {
chrome::NewEmptyWindow(ChromeLauncherController::instance()->profile());
ash::NewWindowDelegate::GetInstance()->NewWindow(/*incognito=*/false);
std::move(callback).Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, {});
return;
}
......@@ -216,7 +217,7 @@ void BrowserShortcutLauncherItemController::ItemSelected(
Browser* last_browser = chrome::FindTabbedBrowser(profile, true);
if (!last_browser) {
chrome::NewEmptyWindow(profile);
ash::NewWindowDelegate::GetInstance()->NewWindow(/*incognito=*/false);
std::move(callback).Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, {});
return;
}
......@@ -346,7 +347,7 @@ BrowserShortcutLauncherItemController::ActivateOrAdvanceToNextBrowser() {
}
// If there are no suitable browsers we create a new one.
if (items.empty()) {
chrome::NewEmptyWindow(ChromeLauncherController::instance()->profile());
ash::NewWindowDelegate::GetInstance()->NewWindow(/*incognito=*/false);
return ash::SHELF_ACTION_NEW_WINDOW_CREATED;
}
Browser* browser = BrowserList::GetInstance()->GetLastActive();
......
......@@ -7,6 +7,7 @@
#include <utility>
#include "ash/public/cpp/app_menu_constants.h"
#include "ash/public/cpp/new_window_delegate.h"
#include "base/bind.h"
#include "chrome/browser/extensions/context_menu_matcher.h"
#include "chrome/browser/extensions/extension_util.h"
......@@ -201,10 +202,10 @@ void ExtensionShelfContextMenu::ExecuteCommand(int command_id,
SetLaunchType(extensions::LAUNCH_TYPE_FULLSCREEN);
break;
case ash::MENU_NEW_WINDOW:
chrome::NewEmptyWindow(controller()->profile());
ash::NewWindowDelegate::GetInstance()->NewWindow(/*incognito=*/false);
break;
case ash::MENU_NEW_INCOGNITO_WINDOW:
chrome::NewEmptyWindow(controller()->profile()->GetOffTheRecordProfile());
ash::NewWindowDelegate::GetInstance()->NewWindow(/*incognito=*/true);
break;
default:
if (extension_items_) {
......
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