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