Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5498)

Unified Diff: chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc

Issue 2793443003: Removed NOTIFICATION_BROWSER_CLOSING notification (Closed)
Patch Set: Removed NOTIFICATION_BROWSER_CLOSING as separate patch Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
index 810a42a37de4174f582a99b28d97ea04aec2b11c..3e6ab08bfb67cb8a733ae02fc4dbc4f80c4e324b 100644
--- a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
@@ -15,7 +15,6 @@
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "base/memory/ptr_util.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
@@ -33,7 +32,6 @@
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "ui/aura/window.h"
@@ -110,7 +108,8 @@ BrowserShortcutLauncherItemController::BrowserShortcutLauncherItemController(
ash::ShelfModel* shelf_model)
: LauncherItemController(ash::AppLaunchId(extension_misc::kChromeAppId),
launcher_controller),
- shelf_model_(shelf_model) {
+ shelf_model_(shelf_model),
+ browser_list_observer_(this) {
// Tag all open browser windows with the appropriate shelf id property. This
// associates each window with the shelf item for the active web contents.
for (auto* browser : *BrowserList::GetInstance()) {
@@ -219,7 +218,7 @@ void BrowserShortcutLauncherItemController::ItemSelected(
MenuItemList BrowserShortcutLauncherItemController::GetAppMenuItems(
int event_flags) {
browser_menu_items_.clear();
- registrar_.RemoveAll();
+ browser_list_observer_.RemoveAll();
MenuItemList items;
bool found_tabbed_browser = false;
@@ -250,15 +249,15 @@ MenuItemList BrowserShortcutLauncherItemController::GetAppMenuItems(
}
}
browser_menu_items_.push_back(browser);
- registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING,
- content::Source<Browser>(browser));
+ if (!browser_list_observer_.IsObservingSources())
+ browser_list_observer_.Add(BrowserList::GetInstance());
}
// If only windowed applications are open, we return an empty list to
// enforce the creation of a new browser.
if (!found_tabbed_browser) {
items.clear();
browser_menu_items_.clear();
- registrar_.RemoveAll();
+ browser_list_observer_.RemoveAll();
}
return items;
}
@@ -291,7 +290,7 @@ void BrowserShortcutLauncherItemController::ExecuteCommand(
}
browser_menu_items_.clear();
- registrar_.RemoveAll();
+ browser_list_observer_.RemoveAll();
}
void BrowserShortcutLauncherItemController::Close() {
@@ -393,18 +392,12 @@ BrowserShortcutLauncherItemController::GetListOfActiveBrowsers() {
return active_browsers;
}
-void BrowserShortcutLauncherItemController::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_BROWSER_CLOSING, type);
- Browser* browser = content::Source<Browser>(source).ptr();
+void BrowserShortcutLauncherItemController::OnBrowserCloseStarted(
+ Browser* browser) {
DCHECK(browser);
BrowserList::BrowserVector::iterator item = std::find(
browser_menu_items_.begin(), browser_menu_items_.end(), browser);
- DCHECK(item != browser_menu_items_.end());
// Clear the entry for the closed browser and leave other indices intact.
- *item = nullptr;
- registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING,
- content::Source<Browser>(browser));
+ if (item != browser_menu_items_.end())
+ *item = nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698