| 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 "ash/system/network/tray_network.h" | 5 #include "ash/system/network/tray_network.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
| 11 #include "ash/system/tray/tray_constants.h" | 11 #include "ash/system/tray/tray_constants.h" |
| 12 #include "ash/system/tray/tray_details_view.h" | 12 #include "ash/system/tray/tray_details_view.h" |
| 13 #include "ash/system/tray/tray_item_more.h" | 13 #include "ash/system/tray/tray_item_more.h" |
| 14 #include "ash/system/tray/tray_item_view.h" | 14 #include "ash/system/tray/tray_item_view.h" |
| 15 #include "ash/system/tray/tray_notification_view.h" |
| 15 #include "ash/system/tray/tray_views.h" | 16 #include "ash/system/tray/tray_views.h" |
| 16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 17 #include "grit/ash_strings.h" | 18 #include "grit/ash_strings.h" |
| 18 #include "grit/ui_resources_standard.h" | 19 #include "grit/ui_resources_standard.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/font.h" | 24 #include "ui/gfx/font.h" |
| 24 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 private: | 655 private: |
| 655 TrayNetwork* tray_; | 656 TrayNetwork* tray_; |
| 656 TrayNetwork::ErrorType error_type_; | 657 TrayNetwork::ErrorType error_type_; |
| 657 | 658 |
| 658 DISALLOW_COPY_AND_ASSIGN(NetworkErrorView); | 659 DISALLOW_COPY_AND_ASSIGN(NetworkErrorView); |
| 659 }; | 660 }; |
| 660 | 661 |
| 661 class NetworkNotificationView : public TrayNotificationView { | 662 class NetworkNotificationView : public TrayNotificationView { |
| 662 public: | 663 public: |
| 663 explicit NetworkNotificationView(TrayNetwork* tray) | 664 explicit NetworkNotificationView(TrayNetwork* tray) |
| 664 : TrayNotificationView(0), | 665 : TrayNotificationView(tray, 0) { |
| 665 tray_(tray) { | |
| 666 CreateErrorView(); | 666 CreateErrorView(); |
| 667 InitView(network_error_view_); | 667 InitView(network_error_view_); |
| 668 SetIconImage(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 668 SetIconImage(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 669 GetErrorIcon(network_error_view_->error_type()))); | 669 GetErrorIcon(network_error_view_->error_type()))); |
| 670 } | 670 } |
| 671 | 671 |
| 672 // Overridden from TrayNotificationView. | 672 // Overridden from TrayNotificationView. |
| 673 virtual void OnClose() OVERRIDE { | 673 virtual void OnClose() OVERRIDE { |
| 674 tray_->ClearNetworkError(network_error_view_->error_type()); | 674 tray_network()->ClearNetworkError(network_error_view_->error_type()); |
| 675 } | 675 } |
| 676 | 676 |
| 677 // Overridden from views::View. | 677 virtual void OnClickAction() OVERRIDE { |
| 678 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE { | 678 tray()->PopupDetailedView(0, true); |
| 679 tray_->PopupDetailedView(0, true); | |
| 680 return true; | |
| 681 } | 679 } |
| 682 | 680 |
| 683 void Update() { | 681 void Update() { |
| 684 CreateErrorView(); | 682 CreateErrorView(); |
| 685 UpdateViewAndImage(network_error_view_, | 683 UpdateViewAndImage(network_error_view_, |
| 686 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 684 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 687 GetErrorIcon(network_error_view_->error_type()))); | 685 GetErrorIcon(network_error_view_->error_type()))); |
| 688 } | 686 } |
| 689 | 687 |
| 690 private: | 688 private: |
| 689 TrayNetwork* tray_network() { |
| 690 return static_cast<TrayNetwork*>(tray()); |
| 691 } |
| 692 |
| 691 void CreateErrorView() { | 693 void CreateErrorView() { |
| 692 // Display the first (highest priority) error. | 694 // Display the first (highest priority) error. |
| 693 CHECK(!tray_->errors()->messages().empty()); | 695 CHECK(!tray_network()->errors()->messages().empty()); |
| 694 NetworkErrors::ErrorMap::const_iterator iter = | 696 NetworkErrors::ErrorMap::const_iterator iter = |
| 695 tray_->errors()->messages().begin(); | 697 tray_network()->errors()->messages().begin(); |
| 696 network_error_view_ = | 698 network_error_view_ = |
| 697 new NetworkErrorView(tray_, iter->first, iter->second); | 699 new NetworkErrorView(tray_network(), iter->first, iter->second); |
| 698 } | 700 } |
| 699 | 701 |
| 700 TrayNetwork* tray_; | |
| 701 tray::NetworkErrorView* network_error_view_; | 702 tray::NetworkErrorView* network_error_view_; |
| 702 | 703 |
| 703 DISALLOW_COPY_AND_ASSIGN(NetworkNotificationView); | 704 DISALLOW_COPY_AND_ASSIGN(NetworkNotificationView); |
| 704 }; | 705 }; |
| 705 | 706 |
| 706 } // namespace tray | 707 } // namespace tray |
| 707 | 708 |
| 708 TrayNetwork::TrayNetwork() | 709 TrayNetwork::TrayNetwork() |
| 709 : tray_(NULL), | 710 : tray_(NULL), |
| 710 default_(NULL), | 711 default_(NULL), |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 | 799 |
| 799 void TrayNetwork::LinkClicked(ErrorType error_type) { | 800 void TrayNetwork::LinkClicked(ErrorType error_type) { |
| 800 tray::NetworkErrors::ErrorMap::const_iterator iter = | 801 tray::NetworkErrors::ErrorMap::const_iterator iter = |
| 801 errors()->messages().find(error_type); | 802 errors()->messages().find(error_type); |
| 802 if (iter != errors()->messages().end() && iter->second.delegate) | 803 if (iter != errors()->messages().end() && iter->second.delegate) |
| 803 iter->second.delegate->NotificationLinkClicked(); | 804 iter->second.delegate->NotificationLinkClicked(); |
| 804 } | 805 } |
| 805 | 806 |
| 806 } // namespace internal | 807 } // namespace internal |
| 807 } // namespace ash | 808 } // namespace ash |
| OLD | NEW |