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

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

Issue 3212005: Unify sidebar identification in the chrome.experimental.sidebar extension API... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years, 3 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
« no previous file with comments | « chrome/browser/sidebar/sidebar_container.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 SidebarContainer* was_active_host = 76 SidebarContainer* was_active_host =
77 was_active_sidebar_contents == NULL ? NULL : 77 was_active_sidebar_contents == NULL ? NULL :
78 FindSidebarContainerFor(was_active_sidebar_contents); 78 FindSidebarContainerFor(was_active_sidebar_contents);
79 SidebarContainer* active_host = 79 SidebarContainer* active_host =
80 active_sidebar_contents == NULL ? NULL : 80 active_sidebar_contents == NULL ? NULL :
81 FindSidebarContainerFor(active_sidebar_contents); 81 FindSidebarContainerFor(active_sidebar_contents);
82 82
83 if (was_active_host != NULL) { 83 if (was_active_host != NULL) {
84 ExtensionSidebarEventRouter::OnStateChanged( 84 ExtensionSidebarEventRouter::OnStateChanged(
85 was_active_sidebar_contents->profile(), 85 was_active_sidebar_contents->profile(),
86 was_active_host->GetTabId(), was_active_host->content_id(), 86 was_active_host->tab_contents(), was_active_host->content_id(),
87 extension_sidebar_constants::kShownState); 87 extension_sidebar_constants::kShownState);
88 } 88 }
89 89
90 if (active_host != NULL) { 90 if (active_host != NULL) {
91 ExtensionSidebarEventRouter::OnStateChanged( 91 ExtensionSidebarEventRouter::OnStateChanged(
92 active_sidebar_contents->profile(), 92 active_sidebar_contents->profile(),
93 active_host->GetTabId(), active_host->content_id(), 93 active_host->tab_contents(), active_host->content_id(),
94 extension_sidebar_constants::kActiveState); 94 extension_sidebar_constants::kActiveState);
95 } 95 }
96 } 96 }
97 97
98 void SidebarManager::ShowSidebar(TabContents* tab, 98 void SidebarManager::ShowSidebar(TabContents* tab,
99 const std::string& content_id) { 99 const std::string& content_id) {
100 DCHECK(!content_id.empty()); 100 DCHECK(!content_id.empty());
101 SidebarContainer* host = GetSidebarContainerFor(tab, content_id); 101 SidebarContainer* host = GetSidebarContainerFor(tab, content_id);
102 if (!host) { 102 if (!host) {
103 host = new SidebarContainer(tab, content_id, this); 103 host = new SidebarContainer(tab, content_id, this);
104 RegisterSidebarContainerFor(tab, host); 104 RegisterSidebarContainerFor(tab, host);
105 } 105 }
106 106
107 host->Show(); 107 host->Show();
108 108
109 ExtensionSidebarEventRouter::OnStateChanged( 109 ExtensionSidebarEventRouter::OnStateChanged(
110 tab->profile(), host->GetTabId(), content_id, 110 tab->profile(), tab, content_id,
111 extension_sidebar_constants::kShownState); 111 extension_sidebar_constants::kShownState);
112 } 112 }
113 113
114 void SidebarManager::ExpandSidebar(TabContents* tab, 114 void SidebarManager::ExpandSidebar(TabContents* tab,
115 const std::string& content_id) { 115 const std::string& content_id) {
116 DCHECK(!content_id.empty()); 116 DCHECK(!content_id.empty());
117 TabToSidebarHostMap::iterator it = tab_to_sidebar_host_.find(tab); 117 TabToSidebarHostMap::iterator it = tab_to_sidebar_host_.find(tab);
118 if (it == tab_to_sidebar_host_.end()) 118 if (it == tab_to_sidebar_host_.end())
119 return; 119 return;
120 // If it's already active, bail out. 120 // If it's already active, bail out.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const std::string& content_id) { 153 const std::string& content_id) {
154 DCHECK(!content_id.empty()); 154 DCHECK(!content_id.empty());
155 TabToSidebarHostMap::iterator it = tab_to_sidebar_host_.find(tab); 155 TabToSidebarHostMap::iterator it = tab_to_sidebar_host_.find(tab);
156 if (it == tab_to_sidebar_host_.end()) 156 if (it == tab_to_sidebar_host_.end())
157 return; 157 return;
158 if (it->second.active_content_id == content_id) 158 if (it->second.active_content_id == content_id)
159 it->second.active_content_id.clear(); 159 it->second.active_content_id.clear();
160 160
161 SidebarContainer* host = GetSidebarContainerFor(tab, content_id); 161 SidebarContainer* host = GetSidebarContainerFor(tab, content_id);
162 DCHECK(host); 162 DCHECK(host);
163 int tab_id = host->GetTabId();
164 163
165 UnregisterSidebarContainerFor(tab, content_id); 164 UnregisterSidebarContainerFor(tab, content_id);
166 165
167 ExtensionSidebarEventRouter::OnStateChanged( 166 ExtensionSidebarEventRouter::OnStateChanged(
168 tab->profile(), tab_id, content_id, 167 tab->profile(), tab, content_id,
169 extension_sidebar_constants::kHiddenState); 168 extension_sidebar_constants::kHiddenState);
170 } 169 }
171 170
172 void SidebarManager::NavigateSidebar(TabContents* tab, 171 void SidebarManager::NavigateSidebar(TabContents* tab,
173 const std::string& content_id, 172 const std::string& content_id,
174 const GURL& url) { 173 const GURL& url) {
175 DCHECK(!content_id.empty()); 174 DCHECK(!content_id.empty());
176 SidebarContainer* host = GetSidebarContainerFor(tab, content_id); 175 SidebarContainer* host = GetSidebarContainerFor(tab, content_id);
177 if (!host) 176 if (!host)
178 return; 177 return;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 313
315 DCHECK(GetSidebarContainerFor(tab, content_id) == sidebar_host); 314 DCHECK(GetSidebarContainerFor(tab, content_id) == sidebar_host);
316 DCHECK(sidebar_host_to_tab_.find(sidebar_host)->second == tab); 315 DCHECK(sidebar_host_to_tab_.find(sidebar_host)->second == tab);
317 DCHECK(tab_to_sidebar_host_[tab].active_content_id != content_id); 316 DCHECK(tab_to_sidebar_host_[tab].active_content_id != content_id);
318 317
319 tab_to_sidebar_host_[tab].content_id_to_sidebar_host.erase(content_id); 318 tab_to_sidebar_host_[tab].content_id_to_sidebar_host.erase(content_id);
320 if (tab_to_sidebar_host_[tab].content_id_to_sidebar_host.empty()) 319 if (tab_to_sidebar_host_[tab].content_id_to_sidebar_host.empty())
321 tab_to_sidebar_host_.erase(tab); 320 tab_to_sidebar_host_.erase(tab);
322 sidebar_host_to_tab_.erase(sidebar_host); 321 sidebar_host_to_tab_.erase(sidebar_host);
323 } 322 }
OLDNEW
« no previous file with comments | « chrome/browser/sidebar/sidebar_container.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698