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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/tab_contents/tab_util.h" | 10 #include "chrome/browser/tab_contents/tab_util.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 StarsView::StarsView(double rating) | 107 StarsView::StarsView(double rating) |
108 : rating_(rating) { | 108 : rating_(rating) { |
109 const int kSpacing = 1; // Spacing between stars in pixels. | 109 const int kSpacing = 1; // Spacing between stars in pixels. |
110 | 110 |
111 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 111 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
112 SetLayoutManager( | 112 SetLayoutManager( |
113 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, kSpacing)); | 113 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, kSpacing)); |
114 | 114 |
115 for (int i = 0; i < 5; ++i) { | 115 for (int i = 0; i < 5; ++i) { |
116 views::ImageView* image = new views::ImageView(); | 116 views::ImageView* image = new views::ImageView(); |
117 image->SetImage(rb.GetBitmapNamed( | 117 image->SetImage(rb.GetImageSkiaNamed( |
118 WebIntentPicker::GetNthStarImageIdFromCWSRating(rating, i))); | 118 WebIntentPicker::GetNthStarImageIdFromCWSRating(rating, i))); |
119 AddChildView(image); | 119 AddChildView(image); |
120 } | 120 } |
121 | 121 |
122 // TODO(binji): Add tooltip with text rating | 122 // TODO(binji): Add tooltip with text rating |
123 // "Average Rating: X.XX stars (YYYYY)" | 123 // "Average Rating: X.XX stars (YYYYY)" |
124 // Y = "1: Hated it, 2: Disliked it, 3: It was okay, 4: Liked it, | 124 // Y = "1: Hated it, 2: Disliked it, 3: It was okay, 4: Liked it, |
125 // 5: Loved it" | 125 // 5: Loved it" |
126 // Choose Y based on rounded X. | 126 // Choose Y based on rounded X. |
127 } | 127 } |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 }; | 497 }; |
498 | 498 |
499 SuggestedExtensionsRowView::SuggestedExtensionsRowView( | 499 SuggestedExtensionsRowView::SuggestedExtensionsRowView( |
500 const WebIntentPickerModel::SuggestedExtension* extension, | 500 const WebIntentPickerModel::SuggestedExtension* extension, |
501 Delegate* delegate) | 501 Delegate* delegate) |
502 : extension_(extension), | 502 : extension_(extension), |
503 delegate_(delegate) { | 503 delegate_(delegate) { |
504 SetLayoutManager(new SuggestedExtensionsLayout); | 504 SetLayoutManager(new SuggestedExtensionsLayout); |
505 | 505 |
506 icon_ = new views::ImageView(); | 506 icon_ = new views::ImageView(); |
507 icon_->SetImage(extension_->icon.ToSkBitmap()); | 507 icon_->SetImage(extension_->icon.ToImageSkia()); |
508 AddChildView(icon_); | 508 AddChildView(icon_); |
509 | 509 |
510 string16 elided_title = ui::ElideText( | 510 string16 elided_title = ui::ElideText( |
511 extension_->title, gfx::Font(), kTitleLinkMaxWidth, ui::ELIDE_AT_END); | 511 extension_->title, gfx::Font(), kTitleLinkMaxWidth, ui::ELIDE_AT_END); |
512 title_link_ = new views::Link(elided_title); | 512 title_link_ = new views::Link(elided_title); |
513 title_link_->set_listener(this); | 513 title_link_->set_listener(this); |
514 AddChildView(title_link_); | 514 AddChildView(title_link_); |
515 | 515 |
516 stars_ = new StarsView(extension_->average_rating); | 516 stars_ = new StarsView(extension_->average_rating); |
517 AddChildView(stars_); | 517 AddChildView(stars_); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 views::ColumnSet* full_cs = grid_layout->AddColumnSet(1); | 917 views::ColumnSet* full_cs = grid_layout->AddColumnSet(1); |
918 full_cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | 918 full_cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, |
919 GridLayout::USE_PREF, 0, 0); | 919 GridLayout::USE_PREF, 0, 0); |
920 | 920 |
921 const WebIntentPickerModel::InstalledService* service = | 921 const WebIntentPickerModel::InstalledService* service = |
922 model_->GetInstalledServiceWithURL(model_->inline_disposition_url()); | 922 model_->GetInstalledServiceWithURL(model_->inline_disposition_url()); |
923 | 923 |
924 // Header row. | 924 // Header row. |
925 grid_layout->StartRow(0, 0); | 925 grid_layout->StartRow(0, 0); |
926 views::ImageView* icon = new views::ImageView(); | 926 views::ImageView* icon = new views::ImageView(); |
927 icon->SetImage(service->favicon.ToSkBitmap()); | 927 icon->SetImage(service->favicon.ToImageSkia()); |
928 grid_layout->AddView(icon); | 928 grid_layout->AddView(icon); |
929 | 929 |
930 string16 elided_title = ui::ElideText( | 930 string16 elided_title = ui::ElideText( |
931 service->title, gfx::Font(), kTitleLinkMaxWidth, ui::ELIDE_AT_END); | 931 service->title, gfx::Font(), kTitleLinkMaxWidth, ui::ELIDE_AT_END); |
932 views::Label* title = new views::Label(elided_title); | 932 views::Label* title = new views::Label(elided_title); |
933 grid_layout->AddView(title); | 933 grid_layout->AddView(title); |
934 | 934 |
935 choose_another_service_link_ = new views::Link( | 935 choose_another_service_link_ = new views::Link( |
936 l10n_util::GetStringUTF16(IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE)); | 936 l10n_util::GetStringUTF16(IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE)); |
937 grid_layout->AddView(choose_another_service_link_); | 937 grid_layout->AddView(choose_another_service_link_); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 GetWindowBoundsForClientBounds(client_bounds); | 1150 GetWindowBoundsForClientBounds(client_bounds); |
1151 // TODO(binji): figure out how to get the constrained dialog centered... | 1151 // TODO(binji): figure out how to get the constrained dialog centered... |
1152 window_->SetSize(new_window_bounds.size()); | 1152 window_->SetSize(new_window_bounds.size()); |
1153 } | 1153 } |
1154 | 1154 |
1155 #if defined(USE_CLOSE_BUTTON) | 1155 #if defined(USE_CLOSE_BUTTON) |
1156 views::ImageButton* WebIntentPickerViews::CreateCloseButton() { | 1156 views::ImageButton* WebIntentPickerViews::CreateCloseButton() { |
1157 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1157 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
1158 views::ImageButton* close_button = new views::ImageButton(this); | 1158 views::ImageButton* close_button = new views::ImageButton(this); |
1159 close_button->SetImage(views::CustomButton::BS_NORMAL, | 1159 close_button->SetImage(views::CustomButton::BS_NORMAL, |
1160 rb.GetBitmapNamed(IDR_CLOSE_BAR)); | 1160 rb.GetImageSkiaNamed(IDR_CLOSE_BAR)); |
1161 close_button->SetImage(views::CustomButton::BS_HOT, | 1161 close_button->SetImage(views::CustomButton::BS_HOT, |
1162 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); | 1162 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_H)); |
1163 close_button->SetImage(views::CustomButton::BS_PUSHED, | 1163 close_button->SetImage(views::CustomButton::BS_PUSHED, |
1164 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); | 1164 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_P)); |
1165 return close_button; | 1165 return close_button; |
1166 } | 1166 } |
1167 #endif | 1167 #endif |
OLD | NEW |