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

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

Issue 246107: [chromium-reviews] Fix for BrowserActions load/unload not changing Omnibox length. BrowserAction... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 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 "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 "chrome/browser/extensions/extension_browser_event_router.h" 10 #include "chrome/browser/extensions/extension_browser_event_router.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 368 }
369 } 369 }
370 370
371 void BrowserActionsContainer::Observe(NotificationType type, 371 void BrowserActionsContainer::Observe(NotificationType type,
372 const NotificationSource& source, 372 const NotificationSource& source,
373 const NotificationDetails& details) { 373 const NotificationDetails& details) {
374 if (type == NotificationType::EXTENSION_LOADED || 374 if (type == NotificationType::EXTENSION_LOADED ||
375 type == NotificationType::EXTENSION_UNLOADED || 375 type == NotificationType::EXTENSION_UNLOADED ||
376 type == NotificationType::EXTENSION_UNLOADED_DISABLED) { 376 type == NotificationType::EXTENSION_UNLOADED_DISABLED) {
377 RefreshBrowserActionViews(); 377 RefreshBrowserActionViews();
378
379 // All these actions may change visibility of BrowserActions.
380 OnBrowserActionVisibilityChanged();
378 } else { 381 } else {
379 NOTREACHED() << L"Received unexpected notification"; 382 NOTREACHED() << L"Received unexpected notification";
380 } 383 }
381 } 384 }
382 385
383 void BrowserActionsContainer::BubbleBrowserWindowMoved(BrowserBubble* bubble) { 386 void BrowserActionsContainer::BubbleBrowserWindowMoved(BrowserBubble* bubble) {
384 } 387 }
385 388
386 void BrowserActionsContainer::BubbleBrowserWindowClosing( 389 void BrowserActionsContainer::BubbleBrowserWindowClosing(
387 BrowserBubble* bubble) { 390 BrowserBubble* bubble) {
(...skipping 18 matching lines...) Expand all
406 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 409 for (size_t i = 0; i < browser_action_views_.size(); ++i) {
407 BrowserActionImageView* view = browser_action_views_[i]; 410 BrowserActionImageView* view = browser_action_views_[i];
408 const std::string& text = view->browser_action_state()->badge_text(); 411 const std::string& text = view->browser_action_state()->badge_text();
409 SkColor* color = view->browser_action_state()->badge_background_color(); 412 SkColor* color = view->browser_action_state()->badge_background_color();
410 413
411 if (!text.empty()) 414 if (!text.empty())
412 PaintBadge(canvas, browser_action_views_[i], *color, text); 415 PaintBadge(canvas, browser_action_views_[i], *color, text);
413 } 416 }
414 } 417 }
415 418
416 void BrowserActionsContainer::PaintBadge(gfx::Canvas* canvas, 419 void BrowserActionsContainer::PaintBadge(gfx::Canvas* canvas,
417 BrowserActionImageView* view, 420 BrowserActionImageView* view,
418 const SkColor& badge_color, 421 const SkColor& badge_color,
419 const std::string& text) { 422 const std::string& text) {
420 const int kTextSize = 8; 423 const int kTextSize = 8;
421 const int kBottomMargin = 6; 424 const int kBottomMargin = 6;
422 const int kPadding = 2; 425 const int kPadding = 2;
423 const int kBadgeHeight = 11; 426 const int kBadgeHeight = 11;
424 const int kMaxTextWidth = 23; 427 const int kMaxTextWidth = 23;
425 const int kCenterAlignThreshold = 20; // at than width, we center align 428 const int kCenterAlignThreshold = 20; // at than width, we center align
426 429
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // text was too large. 491 // text was too large.
489 rect.fLeft += kPadding; 492 rect.fLeft += kPadding;
490 rect.fRight -= kPadding; 493 rect.fRight -= kPadding;
491 canvas->clipRect(rect); 494 canvas->clipRect(rect);
492 canvas->drawText(text.c_str(), text.size(), 495 canvas->drawText(text.c_str(), text.size(),
493 rect.fLeft + (rect.width() - text_width) / 2, 496 rect.fLeft + (rect.width() - text_width) / 2,
494 rect.fTop + kTextSize + 1, 497 rect.fTop + kTextSize + 1,
495 text_paint); 498 text_paint);
496 canvas->restore(); 499 canvas->restore();
497 } 500 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698