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

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

Issue 1073005: Move RTL related functions from app/l10n_util to base/i18n/rtl... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/status_bubble_views.h" 5 #include "chrome/browser/views/status_bubble_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/animation.h" 9 #include "app/animation.h"
10 #include "app/gfx/canvas.h" 10 #include "app/gfx/canvas.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "app/text_elider.h" 13 #include "app/text_elider.h"
14 #include "base/i18n/rtl.h"
14 #include "base/message_loop.h" 15 #include "base/message_loop.h"
15 #include "base/string_util.h" 16 #include "base/string_util.h"
16 #include "chrome/browser/browser_theme_provider.h" 17 #include "chrome/browser/browser_theme_provider.h"
17 #include "gfx/point.h" 18 #include "gfx/point.h"
18 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
19 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
21 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
22 #include "third_party/skia/include/core/SkPaint.h" 23 #include "third_party/skia/include/core/SkPaint.h"
23 #include "third_party/skia/include/core/SkPath.h" 24 #include "third_party/skia/include/core/SkPath.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 491 }
491 492
492 gfx::Size StatusBubbleViews::GetPreferredSize() { 493 gfx::Size StatusBubbleViews::GetPreferredSize() {
493 return gfx::Size(0, ResourceBundle::GetSharedInstance().GetFont( 494 return gfx::Size(0, ResourceBundle::GetSharedInstance().GetFont(
494 ResourceBundle::BaseFont).height() + kTotalVerticalPadding); 495 ResourceBundle::BaseFont).height() + kTotalVerticalPadding);
495 } 496 }
496 497
497 void StatusBubbleViews::SetBounds(int x, int y, int w, int h) { 498 void StatusBubbleViews::SetBounds(int x, int y, int w, int h) {
498 // If the UI layout is RTL, we need to mirror the position of the bubble 499 // If the UI layout is RTL, we need to mirror the position of the bubble
499 // relative to the parent. 500 // relative to the parent.
500 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { 501 if (base::i18n::IsRTL()) {
501 gfx::Rect frame_bounds; 502 gfx::Rect frame_bounds;
502 frame_->GetBounds(&frame_bounds, false); 503 frame_->GetBounds(&frame_bounds, false);
503 int mirrored_x = frame_bounds.width() - x - w; 504 int mirrored_x = frame_bounds.width() - x - w;
504 position_.SetPoint(mirrored_x, y); 505 position_.SetPoint(mirrored_x, y);
505 } else { 506 } else {
506 position_.SetPoint(x, y); 507 position_.SetPoint(x, y);
507 } 508 }
508 509
509 size_.SetSize(w, h); 510 size_.SetSize(w, h);
510 Reposition(); 511 Reposition();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 gfx::Rect popup_bounds; 552 gfx::Rect popup_bounds;
552 popup_->GetBounds(&popup_bounds, true); 553 popup_->GetBounds(&popup_bounds, true);
553 int text_width = static_cast<int>(popup_bounds.width() - 554 int text_width = static_cast<int>(popup_bounds.width() -
554 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); 555 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1);
555 url_text_ = gfx::ElideUrl(url, view_->Label::GetFont(), text_width, 556 url_text_ = gfx::ElideUrl(url, view_->Label::GetFont(), text_width,
556 languages); 557 languages);
557 558
558 // An URL is always treated as a left-to-right string. On right-to-left UIs 559 // An URL is always treated as a left-to-right string. On right-to-left UIs
559 // we need to explicitly mark the URL as LTR to make sure it is displayed 560 // we need to explicitly mark the URL as LTR to make sure it is displayed
560 // correctly. 561 // correctly.
561 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT && 562 if (base::i18n::IsRTL() && !url_text_.empty())
562 !url_text_.empty()) 563 base::i18n::WrapStringWithLTRFormatting(&url_text_);
563 l10n_util::WrapStringWithLTRFormatting(&url_text_);
564 564
565 if (IsFrameVisible()) 565 if (IsFrameVisible())
566 view_->SetText(url_text_); 566 view_->SetText(url_text_);
567 } 567 }
568 568
569 void StatusBubbleViews::Hide() { 569 void StatusBubbleViews::Hide() {
570 status_text_ = std::wstring(); 570 status_text_ = std::wstring();
571 url_text_ = std::wstring(); 571 url_text_ = std::wstring();
572 if (view_) 572 if (view_)
573 view_->Hide(); 573 view_->Hide();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 } 679 }
680 } 680 }
681 681
682 bool StatusBubbleViews::IsFrameVisible() { 682 bool StatusBubbleViews::IsFrameVisible() {
683 if (!frame_->IsVisible()) 683 if (!frame_->IsVisible())
684 return false; 684 return false;
685 685
686 views::Window* window = frame_->GetWindow(); 686 views::Window* window = frame_->GetWindow();
687 return !window || !window->IsMinimized(); 687 return !window || !window->IsMinimized();
688 } 688 }
OLDNEW
« no previous file with comments | « chrome/browser/views/options/passwords_page_view.cc ('k') | chrome/browser/views/tabs/dragged_tab_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698