BrowserWindowInterface* const browser_window_interface =
Qikai Zhongnit: I think this can be `const BrowserWindowInterface*`
Initially, because `GetBrowserForMigrationOnly` was not marked as const, can not to use `const BrowserWindowInterface*` here. However, since other scenarios also required a const version of `GetBrowserForMigrationOnly`, I added `const Browser* GetBrowserForMigrationOnly() const = 0;`. And updated here.
if (!browser_window_interface) {
return nullptr;
}
Browser* const last_active_browser =
browser_window_interface->GetBrowserForMigrationOnly();
return last_active_browser->window()->GetThemeProvider();
Qikai Zhongoptional:
```
return browser_window_interface
? browser_window_interface->GetBrowserForMigrationOnly()
->window()->GetThemeProvider()
: nullptr;
```
Done
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
CQ Dry Run passed, please help review, thanks~
And can I ignore Code Coverage Check since it is just a migrate CL?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Overall looks good - just some initial comments.
Also would we be able to split the chrome/browser/ash and chrome/browser/chromeos changes into a separate CL? (it will make reviews easier as DEPS files will require a specific ChromeOS owner)
if (!has_browser_windows &&
We could also use `GetLastActiveBrowserWindowInterfaceWithAnyProfile()` here (which will return nullptr if there are no open browsers)
std::set<BrowserWindowInterface*> active_browsers_;
Are we able to preserve const for the set here? (i.e. `std::set<const BrowserWindowInterface*>`?
It looks like it may be possible (we'd need to preserve const in the returned pointers of the anonymous functions and const on some of the pointer variables in the method impls).
? browser_window_interface
->GetActiveTabInterface()
->GetContents()
->GetVisibleURL()
.spec()
: "unknown")
nit: Could we update `GetUrlOfActiveTab()` to take a `BrowserWindowInterface`? It's a relatively simple function and should clean this up slightly.
if (any_open) {
I think we should just be able to use `HasBrowsersForProfile(browser->GetProfile())` here
is_diagnostic_app_open = true;
nit: Should we also return false here?
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[this](BrowserWindowInterface* browser_window_interface) {
browser_window_interface->GetTabStripModel()->RemoveObserver(this);
return true;
});
nit: We should be able to elide the `TabStripModel::RemoveObserver()` call completely (see destructor [here](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/tabs/tab_strip_model_observer.cc;l=342;drc=ff17d15d2d56c9a26f8f696d0fa05b845f5db386)).
std::vector<BrowserWindowInterface*> browsers_to_close;
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[profile,
&browsers_to_close](BrowserWindowInterface* browser_window_interface) {
if (browser_window_interface->GetProfile() == profile) {
browsers_to_close.push_back(browser_window_interface);
}
return true;
});
for (BrowserWindowInterface* browser_window_interface : browsers_to_close) {
browser_window_interface->GetWindow()->Close();
}
nit: It looks like it should just work to close the browsers in the iteration loop (since it handles cases where Browsers are destroyed during iteration). i.e.
```
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[profile,
&browsers_to_close](BrowserWindowInterface* browser_window_interface) {
if (browser_window_interface->GetProfile() == profile) {
browser_window_interface->GetWindow()->Close();
}
return true;
});
```
if (browser_window_interface &&
browser_window_interface->GetBrowserForMigrationOnly()
->window()
->GetDownloadBubbleUIController()) {
browser_window_interface->GetBrowserForMigrationOnly()
->window()
->GetDownloadBubbleUIController()
->HandleButtonPressed();
}
return true;
nit: We can get this from `BrowserWindowFeatures` also.
```
DownloadToolbarUIController* download_controller =
browser_window_interface->GetFeatures().download_toolbar_ui_controller());
DownloadBubbleUIController* bubble_ui_controller = download_controller
? download_controller->bubble_controller()
: nullptr;
if (bubble_ui_controller) {
bubble_ui_controller->HandleButtonPressed();
}
```
BrowserWindowInterface* FindOtherBrowserWindowInterface(Browser* browser) {
BrowserWindowInterface* found = nullptr;
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[browser, &found](BrowserWindowInterface* browser_window_interface) {
if (browser_window_interface == browser) {
return true;
}
found = browser_window_interface;
return false;
});
return found;
}
We should remove this and update clients to use `ui_test_utils::GetBrowserNotInSet({browser})` instead.
BrowserWindowInterface* iwa_browser = nullptr;
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[&iwa_browser](BrowserWindowInterface* browser_window_interface) {
iwa_browser = browser_window_interface;
return false;
});
nit: We should be able to just use `GetLastActiveBrowserWindowInterfaceWithAnyProfile();`
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
We could add the following utility to the fixture
```
int CountBrowsersForType(BrowserWindowInterface::Type type) {
return ui_test_utils::FindMatchingBrowsers(
[type](BrowserWindowInterface* browser) {
return browser->GetType() == type;
});
}
```
Then below becomes
```
EXPECT_EQ(num_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_POPUP);
EXPECT_EQ(num_app_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP);
```
Also the test below can be
```
const int expected_app_popups = BrowserList::GetInstance::size() - 1;
EXPECT_NE(browser()->GetType(), BrowserWindowInterface::Type::TYPE_APP_POPUP);
EXPECT_EQ(expected_app_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP)
```
ui_test_utils::NavigateToURLWithDisposition(
browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_NO_WAIT);
ui_test_utils::WaitForBrowserToOpen();
nit: We should wait for the creation of the second Browser as follows
```
ui_test_utils::BrowserCreatedObserver browser_created_observer;
ui_test_utils::NavigateToURLWithDisposition(
browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_NO_WAIT);
BrowserWindowInterface* second_browser = browser_created_observer.Wait();
EXECT_TRUE(second_browser);
chrome::CloseWindow(second_browser);
```
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Thanks for the changes, left some comments.
ui::BaseWindow* base_window = browser_window_interface->GetWindow();
found_window = base_window ? base_window->GetNativeWindow() : nullptr;
nit:
```suggestion
if (ui::BaseWindow* const base_window =
browser_window_interface->GetWindow()) {
found_window = base_window->GetNativeWindow();
}
```
aura::Window* window =
nit:
```suggestion
aura::Window* const window =
```
BrowserWindowInterface* restore_app_browser =
nit (also applicable to other BWI* decls below in this file):
```suggestion
BrowserWindowInterface* const restore_app_browser =
```
aura::Window* native_window =
nit:
```suggestion
aura::Window* const native_window =
```
const auto* tab_strip_model =
nit:
```suggestion
const auto* const tab_strip_model =
```
BrowserWindowInterface* browser_window_interface =
nit (also applicable to other BWI* decls below in this file):
```suggestion
BrowserWindowInterface* const browser_window_interface =
```
TabStripModel* tab_strip_model = browser_window_interface->GetTabStripModel();
nit:
```suggestion
TabStripModel* const tab_strip_model = browser_window_interface->GetTabStripModel();
```
auto* tab_strip_model = new_browser->GetTabStripModel();
nit:
```suggestion
auto* const tab_strip_model = new_browser->GetTabStripModel();
```
GetAllBrowserWindowInterfaces();
curious: why can't this use `ForEachCurrentBrowserWindowInterfaceOrderedByActivation`?
CloseBrowserAndSetTimer(
I think this function and `closing_browsers_` could be trivially updated to take/use `BrowserWindowInterface` as well.
content::WebContents* target_contents =
nit:
```suggestion
content::WebContents* const target_contents =
```
BrowserList* browser_list = BrowserList::GetInstance();
browser_list->AddObserver(this);
nit:
```suggestion
BrowserList::GetInstance()->AddObserver(this);
```
TabStripModel* tab_strip_model =
nit:
```suggestion
TabStripModel* const tab_strip_model =
```
if (!browser->IsAttemptingToCloseBrowser()) {
this is technically accessible through `GetTabStripModel()->delegate()->IsAttemptingToCloseBrowser();`
Swapping to this would allow changing `target_browser` to BWI* and moving the GetBrowserForMigrationOnly() down only to where `target_browser` is passed into the navigation params creation below.
Not sure if this is "cleaner" or not but wanted to call out the option.
Thoughts @tl...@chromium.org?
ui::BaseWindow* window = browser_window_interface->GetWindow();
nit:
```suggestion
ui::BaseWindow* const window = browser_window_interface->GetWindow();
```
BrowserWindowInterface* app_browser_window =
FindOtherBrowserWindowInterface(browser());
ASSERT_TRUE(app_browser_window->GetType() ==
BrowserWindowInterface::TYPE_APP);
nit:
```suggestion
ASSERT_TRUE(FindOtherBrowserWindowInterface(browser())->GetType() ==
BrowserWindowInterface::TYPE_APP);
```
TabStripModel* tab_strip = browser_window_interface->GetTabStripModel();
nit:
```suggestion
TabStripModel* const tab_strip = browser_window_interface->GetTabStripModel();
```
TabStripModel* target_tab_strip =
browser_window_interface->GetTabStripModel();
active_contents.push_back(target_tab_strip->GetActiveWebContents());
nit:
```suggestion
active_contents.push_back(browser_window_interface->GetTabStripModel()
->GetActiveWebContents());
```
TabStripModel* tab_strip_model =
nit:
```suggestion
TabStripModel* const tab_strip_model =
```
auto* tab = tab_strip_model->GetTabAtIndex(i);
nit:
```suggestion
auto* const tab = tab_strip_model->GetTabAtIndex(i);
```
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
Could this use `GetLastActiveBrowserWindowInterfaceWithAnyProfile()` instead of the loop?
if (auto* browser_view =
nit:
```suggestion
if (auto* const browser_view =
```
if (auto* browser_view = BrowserView::GetBrowserViewForBrowser(
nit:
```suggestion
if (auto* const browser_view = BrowserView::GetBrowserViewForBrowser(
```
if (auto* browser_view =
nit:
```suggestion
if (auto* const browser_view =
```
GetAllBrowserWindowInterfaces()) {
Could this use `ForEachCurrentAndNewBrowserWindowInterfaceOrderedByActivation()`?
const AppBrowserController* app_controller =
browser_window_interface->GetFeatures().app_browser_controller();
nit:
```suggestion
const AppBrowserController* const app_controller =
browser_window_interface->GetAppBrowserController();
```
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
if (!browser->IsAttemptingToCloseBrowser()) {
this is technically accessible through `GetTabStripModel()->delegate()->IsAttemptingToCloseBrowser();`
Swapping to this would allow changing `target_browser` to BWI* and moving the GetBrowserForMigrationOnly() down only to where `target_browser` is passed into the navigation params creation below.
Not sure if this is "cleaner" or not but wanted to call out the option.
Thoughts @tl...@chromium.org?
This is true and Alex is right - though I suspect you meant we should go through `BWI::capabilities()` (I didn't realize this was on capabilities and this is a good suggestion)
Thank you very much for your patience in reviewing. All comments have been fixed.
I have reset the files in the ash and chromeos folders. I will submit them separately in the second CL.
We could also use `GetLastActiveBrowserWindowInterfaceWithAnyProfile()` here (which will return nullptr if there are no open browsers)
Marked as resolved.
ui::BaseWindow* base_window = browser_window_interface->GetWindow();
found_window = base_window ? base_window->GetNativeWindow() : nullptr;
nit:
```suggestion
if (ui::BaseWindow* const base_window =
browser_window_interface->GetWindow()) {
found_window = base_window->GetNativeWindow();
}
```
Marked as resolved.
nit:
```suggestion
aura::Window* const window =
```
Marked as resolved.
nit (also applicable to other BWI* decls below in this file):
```suggestion
BrowserWindowInterface* const restore_app_browser =
```
restore_app_browser will be reassigned later.
nit:
```suggestion
aura::Window* const native_window =
```
Marked as resolved.
Are we able to preserve const for the set here? (i.e. `std::set<const BrowserWindowInterface*>`?
It looks like it may be possible (we'd need to preserve const in the returned pointers of the anonymous functions and const on some of the pointer variables in the method impls).
Done
nit:
```suggestion
const auto* const tab_strip_model =
```
Marked as resolved.
nit (also applicable to other BWI* decls below in this file):
```suggestion
BrowserWindowInterface* const browser_window_interface =
```
Marked as resolved.
TabStripModel* tab_strip_model = browser_window_interface->GetTabStripModel();
nit:
```suggestion
TabStripModel* const tab_strip_model = browser_window_interface->GetTabStripModel();
```
Marked as resolved.
auto* tab_strip_model = new_browser->GetTabStripModel();
nit:
```suggestion
auto* const tab_strip_model = new_browser->GetTabStripModel();
```
Marked as resolved.
curious: why can't this use `ForEachCurrentBrowserWindowInterfaceOrderedByActivation`?
This test depends on the browser creation order.
? browser_window_interface
->GetActiveTabInterface()
->GetContents()
->GetVisibleURL()
.spec()
: "unknown")
nit: Could we update `GetUrlOfActiveTab()` to take a `BrowserWindowInterface`? It's a relatively simple function and should clean this up slightly.
Marked as resolved.
I think this function and `closing_browsers_` could be trivially updated to take/use `BrowserWindowInterface` as well.
Done
I think we should just be able to use `HasBrowsersForProfile(browser->GetProfile())` here
Nice!
I think we should just be able to use `HasBrowsersForProfile(browser->GetProfile())` here
Nice!
nit:
```suggestion
content::WebContents* const target_contents =
```
Marked as resolved.
nit: Should we also return false here?
Marked as resolved.
BrowserList* browser_list = BrowserList::GetInstance();
browser_list->AddObserver(this);
nit:
```suggestion
BrowserList::GetInstance()->AddObserver(this);
```
Marked as resolved.
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[this](BrowserWindowInterface* browser_window_interface) {
browser_window_interface->GetTabStripModel()->RemoveObserver(this);
return true;
});
nit: We should be able to elide the `TabStripModel::RemoveObserver()` call completely (see destructor [here](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/tabs/tab_strip_model_observer.cc;l=342;drc=ff17d15d2d56c9a26f8f696d0fa05b845f5db386)).
Marked as resolved.
```suggestion
TabStripModel* const tab_strip_model =
Qikai Zhong```
Marked as resolved.
std::vector<BrowserWindowInterface*> browsers_to_close;
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[profile,
&browsers_to_close](BrowserWindowInterface* browser_window_interface) {
if (browser_window_interface->GetProfile() == profile) {
browsers_to_close.push_back(browser_window_interface);
}
return true;
});
for (BrowserWindowInterface* browser_window_interface : browsers_to_close) {
browser_window_interface->GetWindow()->Close();
}
nit: It looks like it should just work to close the browsers in the iteration loop (since it handles cases where Browsers are destroyed during iteration). i.e.
```
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[profile,
&browsers_to_close](BrowserWindowInterface* browser_window_interface) {
if (browser_window_interface->GetProfile() == profile) {
browser_window_interface->GetWindow()->Close();
}
return true;
});
```
Marked as resolved.
if (!browser->IsAttemptingToCloseBrowser()) {
this is technically accessible through `GetTabStripModel()->delegate()->IsAttemptingToCloseBrowser();`
Swapping to this would allow changing `target_browser` to BWI* and moving the GetBrowserForMigrationOnly() down only to where `target_browser` is passed into the navigation params creation below.
Not sure if this is "cleaner" or not but wanted to call out the option.
Thoughts @tl...@chromium.org?
Yes, update to `browser_window_interface->capabilities()->IsAttemptingToCloseBrowser()`
ui::BaseWindow* window = browser_window_interface->GetWindow();
nit:
```suggestion
ui::BaseWindow* const window = browser_window_interface->GetWindow();
```
Marked as resolved.
if (browser_window_interface &&
browser_window_interface->GetBrowserForMigrationOnly()
->window()
->GetDownloadBubbleUIController()) {
browser_window_interface->GetBrowserForMigrationOnly()
->window()
->GetDownloadBubbleUIController()
->HandleButtonPressed();
}
return true;
nit: We can get this from `BrowserWindowFeatures` also.
```
DownloadToolbarUIController* download_controller =
browser_window_interface->GetFeatures().download_toolbar_ui_controller());
DownloadBubbleUIController* bubble_ui_controller = download_controller
? download_controller->bubble_controller()
: nullptr;
if (bubble_ui_controller) {
bubble_ui_controller->HandleButtonPressed();
}
```
Marked as resolved.
BrowserWindowInterface* FindOtherBrowserWindowInterface(Browser* browser) {
BrowserWindowInterface* found = nullptr;
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[browser, &found](BrowserWindowInterface* browser_window_interface) {
if (browser_window_interface == browser) {
return true;
}
found = browser_window_interface;
return false;
});
return found;
}
We should remove this and update clients to use `ui_test_utils::GetBrowserNotInSet({browser})` instead.
Marked as resolved.
BrowserWindowInterface* app_browser_window =
FindOtherBrowserWindowInterface(browser());
ASSERT_TRUE(app_browser_window->GetType() ==
BrowserWindowInterface::TYPE_APP);
nit:
```suggestion
ASSERT_TRUE(FindOtherBrowserWindowInterface(browser())->GetType() ==
BrowserWindowInterface::TYPE_APP);
```
app_browser_window is used in many places later.
BrowserWindowInterface* iwa_browser = nullptr;
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
[&iwa_browser](BrowserWindowInterface* browser_window_interface) {
iwa_browser = browser_window_interface;
return false;
});
nit: We should be able to just use `GetLastActiveBrowserWindowInterfaceWithAnyProfile();`
Marked as resolved.
TabStripModel* tab_strip = browser_window_interface->GetTabStripModel();
nit:
```suggestion
TabStripModel* const tab_strip = browser_window_interface->GetTabStripModel();
```
Marked as resolved.
TabStripModel* target_tab_strip =
browser_window_interface->GetTabStripModel();
active_contents.push_back(target_tab_strip->GetActiveWebContents());
nit:
```suggestion
active_contents.push_back(browser_window_interface->GetTabStripModel()
->GetActiveWebContents());
```
Marked as resolved.
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
We could add the following utility to the fixture
```
int CountBrowsersForType(BrowserWindowInterface::Type type) {
return ui_test_utils::FindMatchingBrowsers(
[type](BrowserWindowInterface* browser) {
return browser->GetType() == type;
});
}
```Then below becomes
```
EXPECT_EQ(num_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_POPUP);
EXPECT_EQ(num_app_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP);
```Also the test below can be
```
const int expected_app_popups = BrowserList::GetInstance::size() - 1;
EXPECT_NE(browser()->GetType(), BrowserWindowInterface::Type::TYPE_APP_POPUP);
EXPECT_EQ(expected_app_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP)
```
Done. But don't we also have to migrate `BrowseList::GetInstance::size()` in these days?
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
We could add the following utility to the fixture
```
int CountBrowsersForType(BrowserWindowInterface::Type type) {
return ui_test_utils::FindMatchingBrowsers(
[type](BrowserWindowInterface* browser) {
return browser->GetType() == type;
});
}
```Then below becomes
```
EXPECT_EQ(num_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_POPUP);
EXPECT_EQ(num_app_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP);
```Also the test below can be
```
const int expected_app_popups = BrowserList::GetInstance::size() - 1;
EXPECT_NE(browser()->GetType(), BrowserWindowInterface::Type::TYPE_APP_POPUP);
EXPECT_EQ(expected_app_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP)
```
Done, But is it reasonable to continue using `BrowserList::GetInstance::size()` here? Don’t we want to migrate it eventually?
ui_test_utils::NavigateToURLWithDisposition(
browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_NO_WAIT);
ui_test_utils::WaitForBrowserToOpen();
nit: We should wait for the creation of the second Browser as follows
```
ui_test_utils::BrowserCreatedObserver browser_created_observer;
ui_test_utils::NavigateToURLWithDisposition(
browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_NO_WAIT);
BrowserWindowInterface* second_browser = browser_created_observer.Wait();
EXECT_TRUE(second_browser);
chrome::CloseWindow(second_browser);
```
Marked as resolved.
```suggestion
TabStripModel* const tab_strip_model =
Qikai Zhong```
Marked as resolved.
nit:
```suggestion
auto* const tab = tab_strip_model->GetTabAtIndex(i);
```
Marked as resolved.
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
Could this use `GetLastActiveBrowserWindowInterfaceWithAnyProfile()` instead of the loop?
Marked as resolved.
nit:
```suggestion
if (auto* const browser_view =
```
Marked as resolved.
if (auto* browser_view = BrowserView::GetBrowserViewForBrowser(
nit:
```suggestion
if (auto* const browser_view = BrowserView::GetBrowserViewForBrowser(
```
Marked as resolved.
nit:
```suggestion
if (auto* const browser_view =
```
Marked as resolved.
Could this use `ForEachCurrentAndNewBrowserWindowInterfaceOrderedByActivation()`?
Updated to `ForEachCurrentAndNewBrowserWindowInterfaceOrderedByActivation()`
const AppBrowserController* app_controller =
browser_window_interface->GetFeatures().app_browser_controller();
nit:
```suggestion
const AppBrowserController* const app_controller =
browser_window_interface->GetAppBrowserController();
```
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Thanks for splitting - overall looks good just some minor comments
[result](BrowserWindowInterface* browser_window_interface) {
aside: Not for this change but in case it helps going forward - we can simply use `browser` for the `BWI` variable name instead of `browser_window_interface` (very minor point but it can often reduce verbosity / improve line wrapping in a few places).
GetAllBrowserWindowInterfaces();
nit: We should unify on `ForEachCurrentBrowserWindowInterfaceOrderedByActivation` here (we may or may not want to remove `GetAllBrowserWindowInterfaces()` later on but that's a separate discussion).
Browser* target_browser =
create_new_window
? nullptr
: target_browser_interface->GetBrowserForMigrationOnly();
NavigateParams params = CreateNavigateParams(
profile, gurl, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, create_new_window,
create_in_background, target_browser);
nit: This is the only client for `CreateNavigateParams()` - we could probably just modify that to take the `target_browser_interface` + use `BWI::GetBrowserForMigrationOnly()` in `CreateNavigateParams()` to avoid needing to define the `target_browser` here.
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
Qikai ZhongWe could add the following utility to the fixture
```
int CountBrowsersForType(BrowserWindowInterface::Type type) {
return ui_test_utils::FindMatchingBrowsers(
[type](BrowserWindowInterface* browser) {
return browser->GetType() == type;
});
}
```Then below becomes
```
EXPECT_EQ(num_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_POPUP);
EXPECT_EQ(num_app_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP);
```Also the test below can be
```
const int expected_app_popups = BrowserList::GetInstance::size() - 1;
EXPECT_NE(browser()->GetType(), BrowserWindowInterface::Type::TYPE_APP_POPUP);
EXPECT_EQ(expected_app_popups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP)
```
Done. But don't we also have to migrate `BrowseList::GetInstance::size()` in these days?
That's a good point. The tests states the expected number of popup browsers above so we can probably do something like
```
constexpr int kExpectedAppPopups = 2;
EXPECT_TRUE(WaitForTabsPopupsApps(browser(), 0, 0, kExpectedAppPopups));
EXPECT_NE(browser()->GetType(), BrowserWindowInterface::Type::TYPE_APP_POPUP);
EXPECT_EQ(kExpectedAppPopups,
CountBrowsersForType(BrowserWindowInterface::Type::TYPE_APP_POPUP)
```
if (!is_android || is_desktop_android) {
QQ - Is `is_desktop_android` needed if the include and code that uses it is gated behind `!BUILDFLAG(IS_ANDROID)`?
browser_window_interface->GetBrowserForMigrationOnly()
nit: Not necessary here since `GetActiveTabInterface()` is on `BWI`
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
nit: We should unify on `ForEachCurrentBrowserWindowInterfaceOrderedByActivation` here (we may or may not want to remove `GetAllBrowserWindowInterfaces()` later on but that's a separate discussion).
Some cases in `NavigationEntryRemoverTest` depend on the browser creation order. I plan to put all cases that depend on the creation order into a separate CL.
Browser* target_browser =
create_new_window
? nullptr
: target_browser_interface->GetBrowserForMigrationOnly();
NavigateParams params = CreateNavigateParams(
profile, gurl, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, create_new_window,
create_in_background, target_browser);
nit: This is the only client for `CreateNavigateParams()` - we could probably just modify that to take the `target_browser_interface` + use `BWI::GetBrowserForMigrationOnly()` in `CreateNavigateParams()` to avoid needing to define the `target_browser` here.
Marked as resolved.
ForEachCurrentBrowserWindowInterfaceOrderedByActivation(
Marked as resolved.
QQ - Is `is_desktop_android` needed if the include and code that uses it is gated behind `!BUILDFLAG(IS_ANDROID)`?
This is needed, it is to fix the gn check. You can find the detail in the checks section of patch 8.
browser_window_interface->GetBrowserForMigrationOnly()
nit: Not necessary here since `GetActiveTabInterface()` is on `BWI`
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[bedrock] Migrate BrowserList begin/end Part 1.
The main content is to migrate BrowserList::begin() / BrowserList::end()
to the BrowserWindowInterface api.
Throughout this migration process, convert Browser* references to
BrowserWindowInterface* wherever feasible.
This CL migrates files in chrome/browser/[a-g]* directories as the first
part. Subsequent CLs will cover remaining directories in alphabetical
order.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |