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

Side by Side Diff: chrome/browser/views/browser_actions_container.cc

Issue 246037: Integrate browser actions with the wrench menu. Browser actions (Closed)
Patch Set: alphabetize Created 11 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
« no previous file with comments | « chrome/browser/views/browser_actions_container.h ('k') | chrome/browser/views/toolbar_view.h » ('j') | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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/views/browser_actions_container.h" 5 #include "chrome/browser/views/browser_actions_container.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "chrome/browser/extensions/extension_browser_event_router.h" 8 #include "chrome/browser/extensions/extension_browser_event_router.h"
9 #include "chrome/browser/extensions/extensions_service.h" 9 #include "chrome/browser/extensions/extensions_service.h"
10 #include "chrome/browser/extensions/extension_tabs_module.h" 10 #include "chrome/browser/extensions/extension_tabs_module.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 134
135 void BrowserActionsContainer::RefreshBrowserActionViews() { 135 void BrowserActionsContainer::RefreshBrowserActionViews() {
136 ExtensionsService* extension_service = profile_->GetExtensionsService(); 136 ExtensionsService* extension_service = profile_->GetExtensionsService();
137 if (!extension_service) // The |extension_service| can be NULL in Incognito. 137 if (!extension_service) // The |extension_service| can be NULL in Incognito.
138 return; 138 return;
139 139
140 std::vector<ContextualAction*> browser_actions; 140 std::vector<ContextualAction*> browser_actions;
141 browser_actions = extension_service->GetBrowserActions(); 141 browser_actions = extension_service->GetBrowserActions();
142 142
143 if (browser_action_views_.size() != browser_actions.size()) { 143 DeleteBrowserActionViews();
144 DeleteBrowserActionViews(); 144 for (size_t i = 0; i < browser_actions.size(); ++i) {
145 Extension* extension = extension_service->GetExtensionById(
146 browser_actions[i]->extension_id());
147 DCHECK(extension);
145 148
146 for (size_t i = 0; i < browser_actions.size(); ++i) { 149 // Only show browser actions that have an icon.
147 Extension* extension = extension_service->GetExtensionById( 150 if (browser_actions[i]->icon_paths().size() > 0) {
148 browser_actions[i]->extension_id());
149 DCHECK(extension);
150
151 BrowserActionImageView* view = 151 BrowserActionImageView* view =
152 new BrowserActionImageView(browser_actions[i], extension, this); 152 new BrowserActionImageView(browser_actions[i], extension, this);
153 browser_action_views_.push_back(view); 153 browser_action_views_.push_back(view);
154 AddChildView(view); 154 AddChildView(view);
155 } 155 }
156 } 156 }
157 } 157 }
158 158
159 void BrowserActionsContainer::DeleteBrowserActionViews() { 159 void BrowserActionsContainer::DeleteBrowserActionViews() {
160 if (!browser_action_views_.empty()) { 160 if (!browser_action_views_.empty()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 const NotificationSource& source, 198 const NotificationSource& source,
199 const NotificationDetails& details) { 199 const NotificationDetails& details) {
200 if (type == NotificationType::EXTENSION_LOADED || 200 if (type == NotificationType::EXTENSION_LOADED ||
201 type == NotificationType::EXTENSION_UNLOADED || 201 type == NotificationType::EXTENSION_UNLOADED ||
202 type == NotificationType::EXTENSION_UNLOADED_DISABLED) { 202 type == NotificationType::EXTENSION_UNLOADED_DISABLED) {
203 RefreshBrowserActionViews(); 203 RefreshBrowserActionViews();
204 } else { 204 } else {
205 NOTREACHED() << L"Received unexpected notification"; 205 NOTREACHED() << L"Received unexpected notification";
206 } 206 }
207 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/views/browser_actions_container.h ('k') | chrome/browser/views/toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698