Commit 71eb7eaf authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove NOTIFICATION_PROFILE_DESTROYED from TouchBarNotificationBridge

Bug: 268984
Change-Id: I6bfa723fed79ef8d371b33a53595273237f3e3bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891584Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711238}
parent 17ca9339
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_command_ids.h"
#include "chrome/app/vector_icons/vector_icons.h" #include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/command_observer.h" #include "chrome/browser/command_observer.h"
#include "chrome/browser/command_updater.h" #include "chrome/browser/command_updater.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -23,6 +22,8 @@ ...@@ -23,6 +22,8 @@
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper_observer.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper_observer.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_command_controller.h" #include "chrome/browser/ui/browser_command_controller.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
#import "chrome/browser/ui/cocoa/touchbar/browser_window_touch_bar_controller.h" #import "chrome/browser/ui/cocoa/touchbar/browser_window_touch_bar_controller.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
...@@ -34,7 +35,6 @@ ...@@ -34,7 +35,6 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/url_formatter/url_formatter.h" #include "components/url_formatter/url_formatter.h"
#include "components/vector_icons/vector_icons.h" #include "components/vector_icons/vector_icons.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#import "skia/ext/skia_utils_mac.h" #import "skia/ext/skia_utils_mac.h"
...@@ -133,9 +133,9 @@ ui::TouchBarAction TouchBarActionFromCommand(int command) { ...@@ -133,9 +133,9 @@ ui::TouchBarAction TouchBarActionFromCommand(int command) {
// the profile preferences and the back/forward commands. // the profile preferences and the back/forward commands.
class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
: public CommandObserver, : public CommandObserver,
public BrowserListObserver,
public BookmarkTabHelperObserver, public BookmarkTabHelperObserver,
public TabStripModelObserver, public TabStripModelObserver,
public content::NotificationObserver,
public content::WebContentsObserver { public content::WebContentsObserver {
public: public:
TouchBarNotificationBridge(BrowserWindowDefaultTouchBar* owner, TouchBarNotificationBridge(BrowserWindowDefaultTouchBar* owner,
...@@ -165,13 +165,13 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge ...@@ -165,13 +165,13 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
base::BindRepeating(&TouchBarNotificationBridge::UpdateTouchBar, base::BindRepeating(&TouchBarNotificationBridge::UpdateTouchBar,
base::Unretained(this))); base::Unretained(this)));
notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, BrowserList::AddObserver(this);
content::Source<Profile>(profile));
} }
bool show_home_button() { return show_home_button_.GetValue(); } bool show_home_button() { return show_home_button_.GetValue(); }
~TouchBarNotificationBridge() override { ~TouchBarNotificationBridge() override {
BrowserList::RemoveObserver(this);
browser_->tab_strip_model()->RemoveObserver(this); browser_->tab_strip_model()->RemoveObserver(this);
UpdateWebContents(nullptr); UpdateWebContents(nullptr);
} }
...@@ -187,8 +187,8 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge ...@@ -187,8 +187,8 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
contents_ = new_contents; contents_ = new_contents;
// Stop observing the old WebContents and start observing the new one (if // Stop observing the old WebContents and start observing the new one (if
// nonnull). Qualified to disambiguate from NotificationObserver::Observe(). // nonnull).
WebContentsObserver::Observe(contents_); Observe(contents_);
BookmarkTabHelper* bookmark_helper = BookmarkTabHelper* bookmark_helper =
contents_ ? BookmarkTabHelper::FromWebContents(contents_) : nullptr; contents_ ? BookmarkTabHelper::FromWebContents(contents_) : nullptr;
...@@ -225,10 +225,8 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge ...@@ -225,10 +225,8 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
UpdateWebContents(selection.new_contents); UpdateWebContents(selection.new_contents);
} }
// NotificationObserver: void OnBrowserRemoved(Browser* browser) override {
void Observe(int type, if (browser == owner_.browser)
const content::NotificationSource& source,
const content::NotificationDetails& details) override {
owner_.browser = nullptr; owner_.browser = nullptr;
} }
...@@ -258,8 +256,6 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge ...@@ -258,8 +256,6 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
// Used to monitor the optional home button pref. // Used to monitor the optional home button pref.
BooleanPrefMember show_home_button_; BooleanPrefMember show_home_button_;
content::NotificationRegistrar notification_registrar_;
PrefChangeRegistrar profile_pref_registrar_; PrefChangeRegistrar profile_pref_registrar_;
DISALLOW_COPY_AND_ASSIGN(TouchBarNotificationBridge); DISALLOW_COPY_AND_ASSIGN(TouchBarNotificationBridge);
......
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