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

Unified Diff: chrome/browser/views/browser_actions_container.cc

Issue 276010: Remove the implicit wrench menu items for browser actions. (Closed)
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_browser_actions_api.cc ('k') | chrome/browser/views/toolbar_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/browser_actions_container.cc
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index 1c0733fc292d6cf4d9e47a72f51481dbc3072c47..df6d905783533c9df8f67fb29d095bb78d556292 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -133,13 +133,14 @@ BrowserActionButton::BrowserActionButton(
// Load the images this view needs asynchronously on the file thread. We'll
// get a call back into OnImageLoaded if the image loads successfully. If not,
// the ImageView will have no image and will not appear in the browser chrome.
- DCHECK(!browser_action->icon_paths().empty());
- const std::vector<std::string>& icon_paths = browser_action->icon_paths();
- browser_action_icons_.resize(icon_paths.size());
- tracker_ = new ImageLoadingTracker(this, icon_paths.size());
- for (std::vector<std::string>::const_iterator iter = icon_paths.begin();
- iter != icon_paths.end(); ++iter) {
- tracker_->PostLoadImageTask(extension->GetResource(*iter));
+ if (!browser_action->icon_paths().empty()) {
+ const std::vector<std::string>& icon_paths = browser_action->icon_paths();
+ browser_action_icons_.resize(icon_paths.size());
+ tracker_ = new ImageLoadingTracker(this, icon_paths.size());
+ for (std::vector<std::string>::const_iterator iter = icon_paths.begin();
+ iter != icon_paths.end(); ++iter) {
+ tracker_->PostLoadImageTask(extension->GetResource(*iter));
+ }
}
registrar_.Add(this, NotificationType::EXTENSION_BROWSER_ACTION_UPDATED,
@@ -174,9 +175,16 @@ void BrowserActionButton::OnImageLoaded(SkBitmap* image, size_t index) {
void BrowserActionButton::OnStateUpdated() {
SkBitmap* image = browser_action_state_->icon();
- if (!image)
- image = &browser_action_icons_[browser_action_state_->icon_index()];
- SetIcon(*image);
+ if (!image) {
+ if (static_cast<size_t>(browser_action_state_->icon_index()) <
+ browser_action_icons_.size()) {
+ image = &browser_action_icons_[browser_action_state_->icon_index()];
+ }
+ }
+
+ if (image)
+ SetIcon(*image);
+
SetTooltipText(ASCIIToWide(browser_action_state_->title()));
panel_->OnBrowserActionVisibilityChanged();
GetParent()->SchedulePaint();
@@ -414,13 +422,10 @@ void BrowserActionsContainer::RefreshBrowserActionViews() {
browser_actions[i]->extension_id());
DCHECK(extension);
- // Only show browser actions that have an icon.
- if (browser_actions[i]->icon_paths().size() > 0) {
- BrowserActionView* view =
- new BrowserActionView(browser_actions[i], extension, this);
- browser_action_views_.push_back(view);
- AddChildView(view);
- }
+ BrowserActionView* view =
+ new BrowserActionView(browser_actions[i], extension, this);
+ browser_action_views_.push_back(view);
+ AddChildView(view);
}
}
« no previous file with comments | « chrome/browser/extensions/extension_browser_actions_api.cc ('k') | chrome/browser/views/toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698