OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bookmarks/bookmark_bubble_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
6 | 6 |
7 #include "base/string16.h" | 7 #include "base/string16.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 if (!initialized) { | 180 if (!initialized) { |
181 kTitleColor = color_utils::GetReadableColor(SkColorSetRGB(6, 45, 117), | 181 kTitleColor = color_utils::GetReadableColor(SkColorSetRGB(6, 45, 117), |
182 Bubble::kBackgroundColor); | 182 Bubble::kBackgroundColor); |
183 kCloseImage = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 183 kCloseImage = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
184 IDR_INFO_BUBBLE_CLOSE); | 184 IDR_INFO_BUBBLE_CLOSE); |
185 | 185 |
186 initialized = true; | 186 initialized = true; |
187 } | 187 } |
188 | 188 |
189 remove_link_ = new views::Link(UTF16ToWide(l10n_util::GetStringUTF16( | 189 remove_link_ = new views::Link(UTF16ToWide(l10n_util::GetStringUTF16( |
190 IDS_BOOMARK_BUBBLE_REMOVE_BOOKMARK))); | 190 IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK))); |
191 remove_link_->set_listener(this); | 191 remove_link_->set_listener(this); |
192 | 192 |
193 edit_button_ = new views::NativeTextButton( | 193 edit_button_ = new views::NativeTextButton( |
194 this, UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOMARK_BUBBLE_OPTIONS))); | 194 this, |
| 195 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS))); |
195 | 196 |
196 close_button_ = new views::NativeTextButton( | 197 close_button_ = new views::NativeTextButton( |
197 this, UTF16ToWide(l10n_util::GetStringUTF16(IDS_DONE))); | 198 this, UTF16ToWide(l10n_util::GetStringUTF16(IDS_DONE))); |
198 close_button_->SetIsDefault(true); | 199 close_button_->SetIsDefault(true); |
199 | 200 |
200 views::Label* combobox_label = new views::Label( | 201 views::Label* combobox_label = new views::Label( |
201 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOMARK_BUBBLE_FOLDER_TEXT))); | 202 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_FOLDER_TEXT))); |
202 | 203 |
203 parent_combobox_ = new views::Combobox(&parent_model_); | 204 parent_combobox_ = new views::Combobox(&parent_model_); |
204 parent_combobox_->SetSelectedItem(parent_model_.node_parent_index()); | 205 parent_combobox_->SetSelectedItem(parent_model_.node_parent_index()); |
205 parent_combobox_->set_listener(this); | 206 parent_combobox_->set_listener(this); |
206 parent_combobox_->SetAccessibleName( | 207 parent_combobox_->SetAccessibleName( |
207 WideToUTF16Hack(combobox_label->GetText())); | 208 WideToUTF16Hack(combobox_label->GetText())); |
208 | 209 |
209 views::Label* title_label = new views::Label( | 210 views::Label* title_label = new views::Label( |
210 UTF16ToWide(l10n_util::GetStringUTF16( | 211 UTF16ToWide(l10n_util::GetStringUTF16( |
211 newly_bookmarked_ ? IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED : | 212 newly_bookmarked_ ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED : |
212 IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK))); | 213 IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK))); |
213 title_label->SetFont( | 214 title_label->SetFont( |
214 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); | 215 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); |
215 title_label->SetColor(kTitleColor); | 216 title_label->SetColor(kTitleColor); |
216 | 217 |
217 GridLayout* layout = new GridLayout(this); | 218 GridLayout* layout = new GridLayout(this); |
218 SetLayoutManager(layout); | 219 SetLayoutManager(layout); |
219 | 220 |
220 ColumnSet* cs = layout->AddColumnSet(0); | 221 ColumnSet* cs = layout->AddColumnSet(0); |
221 | 222 |
222 // Top (title) row. | 223 // Top (title) row. |
(...skipping 23 matching lines...) Expand all Loading... |
246 cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0, | 247 cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0, |
247 GridLayout::USE_PREF, 0, 0); | 248 GridLayout::USE_PREF, 0, 0); |
248 | 249 |
249 layout->StartRow(0, 0); | 250 layout->StartRow(0, 0); |
250 layout->AddView(title_label); | 251 layout->AddView(title_label); |
251 layout->AddView(remove_link_); | 252 layout->AddView(remove_link_); |
252 | 253 |
253 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 254 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
254 layout->StartRow(0, 2); | 255 layout->StartRow(0, 2); |
255 layout->AddView(new views::Label(UTF16ToWide( | 256 layout->AddView(new views::Label(UTF16ToWide( |
256 l10n_util::GetStringUTF16(IDS_BOOMARK_BUBBLE_TITLE_TEXT)))); | 257 l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_TITLE_TEXT)))); |
257 title_tf_ = new views::Textfield(); | 258 title_tf_ = new views::Textfield(); |
258 title_tf_->SetText(GetTitle()); | 259 title_tf_->SetText(GetTitle()); |
259 layout->AddView(title_tf_); | 260 layout->AddView(title_tf_); |
260 | 261 |
261 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 262 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
262 | 263 |
263 layout->StartRow(0, 2); | 264 layout->StartRow(0, 2); |
264 layout->AddView(combobox_label); | 265 layout->AddView(combobox_label); |
265 layout->AddView(parent_combobox_); | 266 layout->AddView(parent_combobox_); |
266 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 267 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 bool BookmarkBubbleView::CloseOnEscape() { | 334 bool BookmarkBubbleView::CloseOnEscape() { |
334 return delegate_ ? delegate_->CloseOnEscape() : true; | 335 return delegate_ ? delegate_->CloseOnEscape() : true; |
335 } | 336 } |
336 | 337 |
337 bool BookmarkBubbleView::FadeInOnShow() { | 338 bool BookmarkBubbleView::FadeInOnShow() { |
338 return false; | 339 return false; |
339 } | 340 } |
340 | 341 |
341 std::wstring BookmarkBubbleView::accessible_name() { | 342 std::wstring BookmarkBubbleView::accessible_name() { |
342 return UTF16ToWide( | 343 return UTF16ToWide( |
343 l10n_util::GetStringUTF16(IDS_BOOMARK_BUBBLE_ADD_BOOKMARK)); | 344 l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_ADD_BOOKMARK)); |
344 } | 345 } |
345 | 346 |
346 void BookmarkBubbleView::Close() { | 347 void BookmarkBubbleView::Close() { |
347 ApplyEdits(); | 348 ApplyEdits(); |
348 GetWidget()->Close(); | 349 GetWidget()->Close(); |
349 } | 350 } |
350 | 351 |
351 void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { | 352 void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { |
352 if (sender == edit_button_) { | 353 if (sender == edit_button_) { |
353 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Edit")); | 354 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Edit")); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 const BookmarkNode* new_parent = | 423 const BookmarkNode* new_parent = |
423 parent_model_.GetNodeAt(parent_combobox_->selected_item()); | 424 parent_model_.GetNodeAt(parent_combobox_->selected_item()); |
424 if (new_parent != node->parent()) { | 425 if (new_parent != node->parent()) { |
425 UserMetrics::RecordAction( | 426 UserMetrics::RecordAction( |
426 UserMetricsAction("BookmarkBubble_ChangeParent")); | 427 UserMetricsAction("BookmarkBubble_ChangeParent")); |
427 model->Move(node, new_parent, new_parent->child_count()); | 428 model->Move(node, new_parent, new_parent->child_count()); |
428 } | 429 } |
429 } | 430 } |
430 } | 431 } |
431 } | 432 } |
OLD | NEW |