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

Side by Side Diff: chrome/browser/extensions/extension_shelf_model.cc

Issue 203023: add mole collapse/expand events. convert mappy to use this. (Closed)
Patch Set: add missing file Created 11 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions/extension_shelf_model.h" 5 #include "chrome/browser/extensions/extension_shelf_model.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/profile.h" 9 #include "chrome/browser/profile.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
11 #include "chrome/browser/extensions/extension_process_manager.h" 11 #include "chrome/browser/extensions/extension_process_manager.h"
12 #include "chrome/browser/extensions/extension_toolstrip_api.h"
12 #include "chrome/browser/extensions/extensions_service.h" 13 #include "chrome/browser/extensions/extensions_service.h"
14 #include "chrome/browser/renderer_host/render_view_host.h"
13 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/notification_service.h" 16 #include "chrome/common/notification_service.h"
15 17
16 ExtensionShelfModel::ExtensionShelfModel(Browser* browser) 18 ExtensionShelfModel::ExtensionShelfModel(Browser* browser)
17 : browser_(browser), ready_(false) { 19 : browser_(browser), ready_(false) {
18 // Watch extensions loaded and unloaded notifications. 20 // Watch extensions loaded and unloaded notifications.
19 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 21 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
20 NotificationService::AllSources()); 22 NotificationService::AllSources());
21 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 23 registrar_.Add(this, NotificationType::EXTENSION_LOADED,
22 NotificationService::AllSources()); 24 NotificationService::AllSources());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 127 }
126 128
127 void ExtensionShelfModel::ExpandToolstrip(iterator toolstrip, 129 void ExtensionShelfModel::ExpandToolstrip(iterator toolstrip,
128 const GURL& url, int height) { 130 const GURL& url, int height) {
129 if (toolstrip == end()) 131 if (toolstrip == end())
130 return; 132 return;
131 toolstrip->height = height; 133 toolstrip->height = height;
132 toolstrip->url = url; 134 toolstrip->url = url;
133 FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_, 135 FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
134 ToolstripChanged(toolstrip)); 136 ToolstripChanged(toolstrip));
137 int routing_id = toolstrip->host->render_view_host()->routing_id();
138 ToolstripEventRouter::OnToolstripExpanded(browser_->profile(),
139 routing_id,
140 url, height);
135 } 141 }
136 142
137 void ExtensionShelfModel::CollapseToolstrip(iterator toolstrip, 143 void ExtensionShelfModel::CollapseToolstrip(iterator toolstrip,
138 const GURL& url) { 144 const GURL& url) {
139 if (toolstrip == end()) 145 if (toolstrip == end())
140 return; 146 return;
141 toolstrip->height = 0; 147 toolstrip->height = 0;
142 toolstrip->url = url; 148 toolstrip->url = url;
143 FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_, 149 FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
144 ToolstripChanged(toolstrip)); 150 ToolstripChanged(toolstrip));
151 int routing_id = toolstrip->host->render_view_host()->routing_id();
152 ToolstripEventRouter::OnToolstripCollapsed(browser_->profile(),
153 routing_id,
154 url);
145 } 155 }
146 156
147 void ExtensionShelfModel::Observe(NotificationType type, 157 void ExtensionShelfModel::Observe(NotificationType type,
148 const NotificationSource& source, 158 const NotificationSource& source,
149 const NotificationDetails& details) { 159 const NotificationDetails& details) {
150 switch (type.value) { 160 switch (type.value) {
151 case NotificationType::EXTENSION_LOADED: 161 case NotificationType::EXTENSION_LOADED:
152 if (ready_) 162 if (ready_)
153 AddExtension(Details<Extension>(details).ptr()); 163 AddExtension(Details<Extension>(details).ptr());
154 break; 164 break;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // Any toolstrips remaining in |copy| were somehow missing from the prefs, 272 // Any toolstrips remaining in |copy| were somehow missing from the prefs,
263 // so just append them to the end. 273 // so just append them to the end.
264 for (iterator toolstrip = copy.begin(); 274 for (iterator toolstrip = copy.begin();
265 toolstrip != copy.end(); ++toolstrip) { 275 toolstrip != copy.end(); ++toolstrip) {
266 toolstrips_.push_back(*toolstrip); 276 toolstrips_.push_back(*toolstrip);
267 } 277 }
268 278
269 FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_, 279 FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
270 ShelfModelReloaded()); 280 ShelfModelReloaded());
271 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698