Skip to content

Commit

Permalink
Remove NOTIFIACTION_SIDERBAR_CHANGED from Mac Port
Browse files Browse the repository at this point in the history
Now we are not depending on notification system anymore.
  • Loading branch information
ryumiel committed Jun 1, 2015
1 parent 606ffb5 commit 39964ab
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
7 changes: 0 additions & 7 deletions chrome/browser/chrome_notification_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,6 @@ enum NotificationType {
// content::WebContents object, the details are None.
NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,

// Sidebar -----------------------------------------------------------------

// Sent when the sidebar state is changed.
// The source is a SidebarManager instance, the details are the changed
// SidebarContainer object.
NOTIFICATION_SIDEBAR_CHANGED,

// Sync --------------------------------------------------------------------

// The sync service has finished the datatype configuration process. The
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/sidebar/sidebar_manager_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#ifndef CHROME_BROWSER_SIDEBAR_SIDEBAR_MANAGER_OBSERVER_H_
#define CHROME_BROWSER_SIDEBAR_SIDEBAR_MANAGER_OBSERVER_H_

namespace content {
class WebContents;
};

class SidebarManagerObserver {
public:
// Called when sidebar is shown
Expand Down
14 changes: 8 additions & 6 deletions chrome/browser/ui/cocoa/browser_window_cocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/mac/scoped_nsobject.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/extensions/extension_keybinding_registry.h"
#include "chrome/browser/sidebar/sidebar_manager_observer.h"
#include "chrome/browser/signin/signin_header_helper.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
Expand Down Expand Up @@ -36,7 +37,7 @@ class BrowserWindowCocoa
: public BrowserWindow,
public ExclusiveAccessContext,
public extensions::ExtensionKeybindingRegistry::Delegate,
public content::NotificationObserver,
public SidebarManagerObserver,
public SearchModelObserver {
public:
BrowserWindowCocoa(Browser* browser,
Expand Down Expand Up @@ -158,10 +159,6 @@ class BrowserWindowCocoa
int GetRenderViewHeightInsetWithDetachedBookmarkBar() override;
void ExecuteExtensionCommand(const extensions::Extension* extension,
const extensions::Command& command) override;
// content::NotificationObserver overrides:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;

ExclusiveAccessContext* GetExclusiveAccessContext() override;

Expand All @@ -185,13 +182,18 @@ class BrowserWindowCocoa
// Returns the cocoa-world BrowserWindowController
BrowserWindowController* cocoa_controller() { return controller_; }

// Handle SidebarManager events
void OnSidebarShown(content::WebContents* tab,
const std::string& content_id) override;
void OnSidebarHidden(content::WebContents* tab,
const std::string& content_id) override;

protected:
void DestroyBrowser() override;

private:
NSWindow* window() const; // Accessor for the (current) |NSWindow|.
void UpdateSidebarForContents(content::WebContents* tab_contents);
content::NotificationRegistrar registrar_;
Browser* browser_; // weak, owned by controller
BrowserWindowController* controller_; // weak, owns us
base::scoped_nsobject<NSString> pending_window_title_;
Expand Down
30 changes: 13 additions & 17 deletions chrome/browser/ui/cocoa/browser_window_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ - (void)validateText:(NSString*)text {
controller_(controller),
initial_show_state_(ui::SHOW_STATE_DEFAULT),
attention_request_id_(0) {
registrar_.Add(
this, chrome::NOTIFICATION_SIDEBAR_CHANGED,
content::Source<SidebarManager>(SidebarManager::GetInstance()));

gfx::Rect bounds;
chrome::GetSavedWindowBoundsAndShowState(browser_,
&bounds,
&initial_show_state_);

browser_->search_model()->AddObserver(this);

SidebarManager *sidebar_manager = SidebarManager::GetInstance();
sidebar_manager->AddObserver(this);
}

BrowserWindowCocoa::~BrowserWindowCocoa() {
Expand Down Expand Up @@ -788,20 +788,6 @@ new OneClickSigninDialogController(
const SearchModel::State& new_state) {
}

void BrowserWindowCocoa::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_SIDEBAR_CHANGED:
UpdateSidebarForContents(
content::Details<SidebarContainer>(details)->web_contents());
break;
default:
NOTREACHED(); // we don't ask for anything else!
break;
}
}

void BrowserWindowCocoa::DestroyBrowser() {
[controller_ destroyBrowser];

Expand Down Expand Up @@ -871,3 +857,13 @@ new OneClickSigninDialogController(
if (statusBubble)
statusBubble->Hide();
}

void BrowserWindowCocoa::OnSidebarShown(content::WebContents* tab,
const std::string& content_id) {
UpdateSidebarForContents(tab);
}

void BrowserWindowCocoa::OnSidebarHidden(content::WebContents* tab,
const std::string& content_id) {
UpdateSidebarForContents(tab);
}

0 comments on commit 39964ab

Please sign in to comment.