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

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

Issue 337035: Replace ExtensionAction with ExtensionAction2. (Closed)
Patch Set: Remove todo Created 11 years, 1 month 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/views/browser_actions_container.h" 5 #include "chrome/browser/views/browser_actions_container.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 browser_action_(extension->browser_action()), 53 browser_action_(extension->browser_action()),
54 extension_(extension), 54 extension_(extension),
55 tracker_(NULL), 55 tracker_(NULL),
56 panel_(panel) { 56 panel_(panel) {
57 set_alignment(TextButton::ALIGN_CENTER); 57 set_alignment(TextButton::ALIGN_CENTER);
58 58
59 // No UpdateState() here because View heirarchy not setup yet. Our parent 59 // No UpdateState() here because View heirarchy not setup yet. Our parent
60 // should call UpdateState() after creation. 60 // should call UpdateState() after creation.
61 61
62 registrar_.Add(this, NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, 62 registrar_.Add(this, NotificationType::EXTENSION_BROWSER_ACTION_UPDATED,
63 Source<ExtensionAction2>(browser_action_)); 63 Source<ExtensionAction>(browser_action_));
64 } 64 }
65 65
66 BrowserActionButton::~BrowserActionButton() { 66 BrowserActionButton::~BrowserActionButton() {
67 if (tracker_) { 67 if (tracker_) {
68 tracker_->StopTrackingImageLoad(); 68 tracker_->StopTrackingImageLoad();
69 tracker_ = NULL; // The tracker object will be deleted when we return. 69 tracker_ = NULL; // The tracker object will be deleted when we return.
70 } 70 }
71 } 71 }
72 72
73 gfx::Insets BrowserActionButton::GetInsets() const { 73 gfx::Insets BrowserActionButton::GetInsets() const {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 AddChildView(button_); 198 AddChildView(button_);
199 button_->UpdateState(); 199 button_->UpdateState();
200 } 200 }
201 201
202 void BrowserActionView::Layout() { 202 void BrowserActionView::Layout() {
203 button_->SetBounds(0, kControlVertOffset, width(), kButtonSize); 203 button_->SetBounds(0, kControlVertOffset, width(), kButtonSize);
204 } 204 }
205 205
206 void BrowserActionView::PaintChildren(gfx::Canvas* canvas) { 206 void BrowserActionView::PaintChildren(gfx::Canvas* canvas) {
207 View::PaintChildren(canvas); 207 View::PaintChildren(canvas);
208 ExtensionAction2* action = button()->browser_action(); 208 ExtensionAction* action = button()->browser_action();
209 int tab_id = panel_->GetCurrentTabId(); 209 int tab_id = panel_->GetCurrentTabId();
210 if (tab_id < 0) 210 if (tab_id < 0)
211 return; 211 return;
212 212
213 action->PaintBadge(canvas, gfx::Rect(width(), height()), tab_id); 213 action->PaintBadge(canvas, gfx::Rect(width(), height()), tab_id);
214 } 214 }
215 215
216 216
217 //////////////////////////////////////////////////////////////////////////////// 217 ////////////////////////////////////////////////////////////////////////////////
218 // BrowserActionsContainer 218 // BrowserActionsContainer
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 329 }
330 } 330 }
331 331
332 void BrowserActionsContainer::TestExecuteBrowserAction(int index) { 332 void BrowserActionsContainer::TestExecuteBrowserAction(int index) {
333 BrowserActionButton* button = browser_action_views_[index]->button(); 333 BrowserActionButton* button = browser_action_views_[index]->button();
334 OnBrowserActionExecuted(button); 334 OnBrowserActionExecuted(button);
335 } 335 }
336 336
337 void BrowserActionsContainer::OnBrowserActionExecuted( 337 void BrowserActionsContainer::OnBrowserActionExecuted(
338 BrowserActionButton* button) { 338 BrowserActionButton* button) {
339 ExtensionAction2* browser_action = button->browser_action(); 339 ExtensionAction* browser_action = button->browser_action();
340 340
341 // Popups just display. No notification to the extension. 341 // Popups just display. No notification to the extension.
342 // TODO(erikkay): should there be? 342 // TODO(erikkay): should there be?
343 if (button->IsPopup()) { 343 if (button->IsPopup()) {
344 // If we're showing the same popup, just hide it and return. 344 // If we're showing the same popup, just hide it and return.
345 bool same_showing = popup_ && button == popup_button_; 345 bool same_showing = popup_ && button == popup_button_;
346 346
347 // Always hide the current popup, even if it's not the same. 347 // Always hide the current popup, even if it's not the same.
348 // Only one popup should be visible at a time. 348 // Only one popup should be visible at a time.
349 HidePopup(); 349 HidePopup();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 std::min(static_cast<int>(browser_action_views_.size()), 452 std::min(static_cast<int>(browser_action_views_.size()),
453 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; 453 kMinimumNumberOfVisibleBrowserActions) * kButtonSize;
454 454
455 // Even if available_width is <= 0, we still return at least the |min_width|. 455 // Even if available_width is <= 0, we still return at least the |min_width|.
456 if (available_width <= 0) 456 if (available_width <= 0)
457 return min_width; 457 return min_width;
458 458
459 return std::max(min_width, available_width - available_width % kButtonSize + 459 return std::max(min_width, available_width - available_width % kButtonSize +
460 kHorizontalPadding * 2); 460 kHorizontalPadding * 2);
461 } 461 }
OLDNEW
« no previous file with comments | « chrome/browser/views/browser_actions_container.h ('k') | chrome/browser/views/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698