| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/status_bubble_views.h" | 5 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "cc/paint/paint_flags.h" |
| 18 #include "chrome/browser/themes/theme_properties.h" | 19 #include "chrome/browser/themes/theme_properties.h" |
| 19 #include "components/url_formatter/elide_url.h" | 20 #include "components/url_formatter/elide_url.h" |
| 20 #include "components/url_formatter/url_formatter.h" | 21 #include "components/url_formatter/url_formatter.h" |
| 21 #include "services/service_manager/runner/common/client_util.h" | 22 #include "services/service_manager/runner/common/client_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" |
| 24 #include "third_party/skia/include/pathops/SkPathOps.h" | 25 #include "third_party/skia/include/pathops/SkPathOps.h" |
| 25 #include "ui/base/theme_provider.h" | 26 #include "ui/base/theme_provider.h" |
| 26 #include "ui/display/display.h" | 27 #include "ui/display/display.h" |
| 27 #include "ui/display/screen.h" | 28 #include "ui/display/screen.h" |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // further and further outside the window as the scale increases. | 450 // further and further outside the window as the scale increases. |
| 450 const int inset = shadow_thickness_pixels - 1; | 451 const int inset = shadow_thickness_pixels - 1; |
| 451 bubble_rect.Inset(style_ == STYLE_STANDARD_RIGHT ? 0 : inset, 0, | 452 bubble_rect.Inset(style_ == STYLE_STANDARD_RIGHT ? 0 : inset, 0, |
| 452 style_ == STYLE_STANDARD_RIGHT ? inset : 0, inset); | 453 style_ == STYLE_STANDARD_RIGHT ? inset : 0, inset); |
| 453 // Align to pixel centers now that the layout is correct. | 454 // Align to pixel centers now that the layout is correct. |
| 454 bubble_rect.Inset(0.5, 0.5); | 455 bubble_rect.Inset(0.5, 0.5); |
| 455 | 456 |
| 456 SkPath path; | 457 SkPath path; |
| 457 path.addRoundRect(gfx::RectFToSkRect(bubble_rect), rad); | 458 path.addRoundRect(gfx::RectFToSkRect(bubble_rect), rad); |
| 458 | 459 |
| 459 SkPaint paint; | 460 cc::PaintFlags paint; |
| 460 paint.setStyle(SkPaint::kStroke_Style); | 461 paint.setStyle(cc::PaintFlags::kStroke_Style); |
| 461 paint.setStrokeWidth(1); | 462 paint.setStrokeWidth(1); |
| 462 paint.setAntiAlias(true); | 463 paint.setAntiAlias(true); |
| 463 | 464 |
| 464 SkPath stroke_path; | 465 SkPath stroke_path; |
| 465 paint.getFillPath(path, &stroke_path); | 466 paint.getFillPath(path, &stroke_path); |
| 466 | 467 |
| 467 // Get the fill path by subtracting the shadow so they align neatly. | 468 // Get the fill path by subtracting the shadow so they align neatly. |
| 468 SkPath fill_path; | 469 SkPath fill_path; |
| 469 Op(path, stroke_path, kDifference_SkPathOp, &fill_path); | 470 Op(path, stroke_path, kDifference_SkPathOp, &fill_path); |
| 470 paint.setStyle(SkPaint::kFill_Style); | 471 paint.setStyle(cc::PaintFlags::kFill_Style); |
| 471 const SkColor bubble_color = | 472 const SkColor bubble_color = |
| 472 theme_provider_->GetColor(ThemeProperties::COLOR_TOOLBAR); | 473 theme_provider_->GetColor(ThemeProperties::COLOR_TOOLBAR); |
| 473 paint.setColor(bubble_color); | 474 paint.setColor(bubble_color); |
| 474 canvas->sk_canvas()->drawPath(fill_path, paint); | 475 canvas->sk_canvas()->drawPath(fill_path, paint); |
| 475 | 476 |
| 476 paint.setColor(kShadowColor); | 477 paint.setColor(kShadowColor); |
| 477 canvas->sk_canvas()->drawPath(stroke_path, paint); | 478 canvas->sk_canvas()->drawPath(stroke_path, paint); |
| 478 | 479 |
| 479 canvas->Restore(); | 480 canvas->Restore(); |
| 480 | 481 |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 void StatusBubbleViews::SetBubbleWidth(int width) { | 952 void StatusBubbleViews::SetBubbleWidth(int width) { |
| 952 size_.set_width(width); | 953 size_.set_width(width); |
| 953 SetBounds(original_position_.x(), original_position_.y(), | 954 SetBounds(original_position_.x(), original_position_.y(), |
| 954 size_.width(), size_.height()); | 955 size_.width(), size_.height()); |
| 955 } | 956 } |
| 956 | 957 |
| 957 void StatusBubbleViews::CancelExpandTimer() { | 958 void StatusBubbleViews::CancelExpandTimer() { |
| 958 if (expand_timer_factory_.HasWeakPtrs()) | 959 if (expand_timer_factory_.HasWeakPtrs()) |
| 959 expand_timer_factory_.InvalidateWeakPtrs(); | 960 expand_timer_factory_.InvalidateWeakPtrs(); |
| 960 } | 961 } |
| OLD | NEW |