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

Side by Side Diff: chrome/browser/sidebar/sidebar_manager.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sidebar/sidebar_manager.h" 5 #include "chrome/browser/sidebar/sidebar_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/extensions/extension_sidebar_api.h" 11 #include "chrome/browser/extensions/extension_sidebar_api.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sidebar/sidebar_container.h" 13 #include "chrome/browser/sidebar/sidebar_container.h"
14 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/common/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 19
20 struct SidebarManager::SidebarStateForTab { 20 struct SidebarManager::SidebarStateForTab {
21 // Sidebars linked to this tab. 21 // Sidebars linked to this tab.
22 ContentIdToSidebarHostMap content_id_to_sidebar_host; 22 ContentIdToSidebarHostMap content_id_to_sidebar_host;
23 // Content id of the currently active (expanded and visible) sidebar. 23 // Content id of the currently active (expanded and visible) sidebar.
24 std::string active_content_id; 24 std::string active_content_id;
25 }; 25 };
26 26
27 // static 27 // static
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 const content::NotificationSource& source, 232 const content::NotificationSource& source,
233 const content::NotificationDetails& details) { 233 const content::NotificationDetails& details) {
234 if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { 234 if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) {
235 HideAllSidebars(content::Source<TabContents>(source).ptr()); 235 HideAllSidebars(content::Source<TabContents>(source).ptr());
236 } else { 236 } else {
237 NOTREACHED() << "Got a notification we didn't register for!"; 237 NOTREACHED() << "Got a notification we didn't register for!";
238 } 238 }
239 } 239 }
240 240
241 void SidebarManager::UpdateSidebar(SidebarContainer* host) { 241 void SidebarManager::UpdateSidebar(SidebarContainer* host) {
242 NotificationService::current()->Notify( 242 content::NotificationService::current()->Notify(
243 chrome::NOTIFICATION_SIDEBAR_CHANGED, 243 chrome::NOTIFICATION_SIDEBAR_CHANGED,
244 content::Source<SidebarManager>(this), 244 content::Source<SidebarManager>(this),
245 content::Details<SidebarContainer>(host)); 245 content::Details<SidebarContainer>(host));
246 } 246 }
247 247
248 void SidebarManager::HideAllSidebars(TabContents* tab) { 248 void SidebarManager::HideAllSidebars(TabContents* tab) {
249 TabToSidebarHostMap::iterator tab_it = tab_to_sidebar_host_.find(tab); 249 TabToSidebarHostMap::iterator tab_it = tab_to_sidebar_host_.find(tab);
250 if (tab_it == tab_to_sidebar_host_.end()) 250 if (tab_it == tab_to_sidebar_host_.end())
251 return; 251 return;
252 const ContentIdToSidebarHostMap& hosts = 252 const ContentIdToSidebarHostMap& hosts =
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 DCHECK(GetSidebarContainerFor(tab, content_id) == sidebar_host); 331 DCHECK(GetSidebarContainerFor(tab, content_id) == sidebar_host);
332 DCHECK(sidebar_host_to_tab_.find(sidebar_host)->second == tab); 332 DCHECK(sidebar_host_to_tab_.find(sidebar_host)->second == tab);
333 DCHECK(tab_to_sidebar_host_[tab].active_content_id != content_id); 333 DCHECK(tab_to_sidebar_host_[tab].active_content_id != content_id);
334 334
335 tab_to_sidebar_host_[tab].content_id_to_sidebar_host.erase(content_id); 335 tab_to_sidebar_host_[tab].content_id_to_sidebar_host.erase(content_id);
336 if (tab_to_sidebar_host_[tab].content_id_to_sidebar_host.empty()) 336 if (tab_to_sidebar_host_[tab].content_id_to_sidebar_host.empty())
337 tab_to_sidebar_host_.erase(tab); 337 tab_to_sidebar_host_.erase(tab);
338 sidebar_host_to_tab_.erase(sidebar_host); 338 sidebar_host_to_tab_.erase(sidebar_host);
339 } 339 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service_unittest.cc ('k') | chrome/browser/spellchecker/spellcheck_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698