| OLD | NEW |
| 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_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "content/browser/tab_contents/tab_contents.h" | 16 #include "content/browser/tab_contents/tab_contents.h" |
| 16 #include "content/common/notification_service.h" | 17 #include "content/common/notification_service.h" |
| 17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 18 | 19 |
| 19 struct SidebarManager::SidebarStateForTab { | 20 struct SidebarManager::SidebarStateForTab { |
| 20 // Sidebars linked to this tab. | 21 // Sidebars linked to this tab. |
| 21 ContentIdToSidebarHostMap content_id_to_sidebar_host; | 22 ContentIdToSidebarHostMap content_id_to_sidebar_host; |
| 22 // Content id of the currently active (expanded and visible) sidebar. | 23 // Content id of the currently active (expanded and visible) sidebar. |
| 23 std::string active_content_id; | 24 std::string active_content_id; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 const NotificationDetails& details) { | 225 const NotificationDetails& details) { |
| 225 if (type == NotificationType::TAB_CONTENTS_DESTROYED) { | 226 if (type == NotificationType::TAB_CONTENTS_DESTROYED) { |
| 226 HideAllSidebars(Source<TabContents>(source).ptr()); | 227 HideAllSidebars(Source<TabContents>(source).ptr()); |
| 227 } else { | 228 } else { |
| 228 NOTREACHED() << "Got a notification we didn't register for!"; | 229 NOTREACHED() << "Got a notification we didn't register for!"; |
| 229 } | 230 } |
| 230 } | 231 } |
| 231 | 232 |
| 232 void SidebarManager::UpdateSidebar(SidebarContainer* host) { | 233 void SidebarManager::UpdateSidebar(SidebarContainer* host) { |
| 233 NotificationService::current()->Notify( | 234 NotificationService::current()->Notify( |
| 234 NotificationType::SIDEBAR_CHANGED, | 235 chrome::SIDEBAR_CHANGED, |
| 235 Source<SidebarManager>(this), | 236 Source<SidebarManager>(this), |
| 236 Details<SidebarContainer>(host)); | 237 Details<SidebarContainer>(host)); |
| 237 } | 238 } |
| 238 | 239 |
| 239 void SidebarManager::HideAllSidebars(TabContents* tab) { | 240 void SidebarManager::HideAllSidebars(TabContents* tab) { |
| 240 TabToSidebarHostMap::iterator tab_it = tab_to_sidebar_host_.find(tab); | 241 TabToSidebarHostMap::iterator tab_it = tab_to_sidebar_host_.find(tab); |
| 241 if (tab_it == tab_to_sidebar_host_.end()) | 242 if (tab_it == tab_to_sidebar_host_.end()) |
| 242 return; | 243 return; |
| 243 const ContentIdToSidebarHostMap& hosts = | 244 const ContentIdToSidebarHostMap& hosts = |
| 244 tab_it->second.content_id_to_sidebar_host; | 245 tab_it->second.content_id_to_sidebar_host; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 322 |
| 322 DCHECK(GetSidebarContainerFor(tab, content_id) == sidebar_host); | 323 DCHECK(GetSidebarContainerFor(tab, content_id) == sidebar_host); |
| 323 DCHECK(sidebar_host_to_tab_.find(sidebar_host)->second == tab); | 324 DCHECK(sidebar_host_to_tab_.find(sidebar_host)->second == tab); |
| 324 DCHECK(tab_to_sidebar_host_[tab].active_content_id != content_id); | 325 DCHECK(tab_to_sidebar_host_[tab].active_content_id != content_id); |
| 325 | 326 |
| 326 tab_to_sidebar_host_[tab].content_id_to_sidebar_host.erase(content_id); | 327 tab_to_sidebar_host_[tab].content_id_to_sidebar_host.erase(content_id); |
| 327 if (tab_to_sidebar_host_[tab].content_id_to_sidebar_host.empty()) | 328 if (tab_to_sidebar_host_[tab].content_id_to_sidebar_host.empty()) |
| 328 tab_to_sidebar_host_.erase(tab); | 329 tab_to_sidebar_host_.erase(tab); |
| 329 sidebar_host_to_tab_.erase(sidebar_host); | 330 sidebar_host_to_tab_.erase(sidebar_host); |
| 330 } | 331 } |
| OLD | NEW |