OLD | NEW |
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/bookmark_bubble_view.h" | 5 #include "chrome/browser/views/bookmark_bubble_view.h" |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
11 #include "chrome/browser/bookmarks/bookmark_editor.h" | 11 #include "chrome/browser/bookmarks/bookmark_editor.h" |
12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/bookmarks/bookmark_utils.h" |
14 #include "chrome/browser/metrics/user_metrics.h" | 14 #include "chrome/browser/metrics/user_metrics.h" |
15 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
16 #include "chrome/browser/views/info_bubble.h" | 16 #include "chrome/browser/views/info_bubble.h" |
17 #include "chrome/common/notification_service.h" | 17 #include "chrome/common/notification_service.h" |
18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
20 #include "views/standard_layout.h" | 20 #include "views/standard_layout.h" |
21 #include "views/controls/button/native_button.h" | 21 #include "views/controls/button/native_button.h" |
22 #include "views/controls/textfield/textfield.h" | 22 #include "views/controls/textfield/textfield.h" |
23 | 23 |
24 using views::ComboBox; | 24 using views::Combobox; |
25 using views::ColumnSet; | 25 using views::ColumnSet; |
26 using views::GridLayout; | 26 using views::GridLayout; |
27 using views::Label; | 27 using views::Label; |
28 using views::Link; | 28 using views::Link; |
29 using views::NativeButton; | 29 using views::NativeButton; |
30 using views::View; | 30 using views::View; |
31 | 31 |
32 // Color of the title. | 32 // Color of the title. |
33 static const SkColor kTitleColor = SkColorSetRGB(6, 45, 117); | 33 static const SkColor kTitleColor = SkColorSetRGB(6, 45, 117); |
34 | 34 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 // And put the bookmark bar and other nodes at the end of the list. | 100 // And put the bookmark bar and other nodes at the end of the list. |
101 nodes_.push_back(bb_model->GetBookmarkBarNode()); | 101 nodes_.push_back(bb_model->GetBookmarkBarNode()); |
102 nodes_.push_back(bb_model->other_node()); | 102 nodes_.push_back(bb_model->other_node()); |
103 | 103 |
104 node_parent_index_ = static_cast<int>( | 104 node_parent_index_ = static_cast<int>( |
105 find(nodes_.begin(), nodes_.end(), node->GetParent()) - nodes_.begin()); | 105 find(nodes_.begin(), nodes_.end(), node->GetParent()) - nodes_.begin()); |
106 } | 106 } |
107 | 107 |
108 int BookmarkBubbleView::RecentlyUsedFoldersModel::GetItemCount( | 108 int BookmarkBubbleView::RecentlyUsedFoldersModel::GetItemCount( |
109 ComboBox* source) { | 109 Combobox* source) { |
110 return static_cast<int>(nodes_.size() + 1); | 110 return static_cast<int>(nodes_.size() + 1); |
111 } | 111 } |
112 | 112 |
113 std::wstring BookmarkBubbleView::RecentlyUsedFoldersModel::GetItemAt( | 113 std::wstring BookmarkBubbleView::RecentlyUsedFoldersModel::GetItemAt( |
114 ComboBox* source, int index) { | 114 Combobox* source, int index) { |
115 if (index == nodes_.size()) | 115 if (index == nodes_.size()) |
116 return l10n_util::GetString(IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER); | 116 return l10n_util::GetString(IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER); |
117 return nodes_[index]->GetTitle(); | 117 return nodes_[index]->GetTitle(); |
118 } | 118 } |
119 | 119 |
120 BookmarkNode* BookmarkBubbleView::RecentlyUsedFoldersModel::GetNodeAt( | 120 BookmarkNode* BookmarkBubbleView::RecentlyUsedFoldersModel::GetNodeAt( |
121 int index) { | 121 int index) { |
122 return nodes_[index]; | 122 return nodes_[index]; |
123 } | 123 } |
124 | 124 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 remove_link_ = new Link(l10n_util::GetString( | 227 remove_link_ = new Link(l10n_util::GetString( |
228 IDS_BOOMARK_BUBBLE_REMOVE_BOOKMARK)); | 228 IDS_BOOMARK_BUBBLE_REMOVE_BOOKMARK)); |
229 remove_link_->SetController(this); | 229 remove_link_->SetController(this); |
230 | 230 |
231 edit_button_ = new NativeButton( | 231 edit_button_ = new NativeButton( |
232 this, l10n_util::GetString(IDS_BOOMARK_BUBBLE_OPTIONS)); | 232 this, l10n_util::GetString(IDS_BOOMARK_BUBBLE_OPTIONS)); |
233 | 233 |
234 close_button_ = new NativeButton(this, l10n_util::GetString(IDS_CLOSE)); | 234 close_button_ = new NativeButton(this, l10n_util::GetString(IDS_CLOSE)); |
235 close_button_->SetIsDefault(true); | 235 close_button_->SetIsDefault(true); |
236 | 236 |
237 parent_combobox_ = new ComboBox(&parent_model_); | 237 parent_combobox_ = new Combobox(&parent_model_); |
238 parent_combobox_->SetSelectedItem(parent_model_.node_parent_index()); | 238 parent_combobox_->SetSelectedItem(parent_model_.node_parent_index()); |
239 parent_combobox_->SetListener(this); | 239 parent_combobox_->set_listener(this); |
240 | 240 |
241 Label* title_label = new Label(l10n_util::GetString( | 241 Label* title_label = new Label(l10n_util::GetString( |
242 newly_bookmarked_ ? IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED : | 242 newly_bookmarked_ ? IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED : |
243 IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK)); | 243 IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK)); |
244 title_label->SetFont( | 244 title_label->SetFont( |
245 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); | 245 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); |
246 title_label->SetColor(kTitleColor); | 246 title_label->SetColor(kTitleColor); |
247 | 247 |
248 GridLayout* layout = new GridLayout(this); | 248 GridLayout* layout = new GridLayout(this); |
249 SetLayoutManager(layout); | 249 SetLayoutManager(layout); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 DCHECK(source == remove_link_); | 327 DCHECK(source == remove_link_); |
328 UserMetrics::RecordAction(L"BookmarkBubble_Unstar", profile_); | 328 UserMetrics::RecordAction(L"BookmarkBubble_Unstar", profile_); |
329 | 329 |
330 // Set this so we remove the bookmark after the window closes. | 330 // Set this so we remove the bookmark after the window closes. |
331 remove_bookmark_ = true; | 331 remove_bookmark_ = true; |
332 apply_edits_ = false; | 332 apply_edits_ = false; |
333 | 333 |
334 Close(); | 334 Close(); |
335 } | 335 } |
336 | 336 |
337 void BookmarkBubbleView::ItemChanged(ComboBox* combo_box, | 337 void BookmarkBubbleView::ItemChanged(Combobox* combobox, |
338 int prev_index, | 338 int prev_index, |
339 int new_index) { | 339 int new_index) { |
340 if (new_index + 1 == parent_model_.GetItemCount(parent_combobox_)) { | 340 if (new_index + 1 == parent_model_.GetItemCount(parent_combobox_)) { |
341 UserMetrics::RecordAction(L"BookmarkBubble_EditFromCombobox", profile_); | 341 UserMetrics::RecordAction(L"BookmarkBubble_EditFromCombobox", profile_); |
342 | 342 |
343 ShowEditor(); | 343 ShowEditor(); |
344 return; | 344 return; |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 BookmarkModel* model = profile_->GetBookmarkModel(); | 410 BookmarkModel* model = profile_->GetBookmarkModel(); |
411 BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); | 411 BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); |
412 if (node) { | 412 if (node) { |
413 const std::wstring new_title = title_tf_->text(); | 413 const std::wstring new_title = title_tf_->text(); |
414 if (new_title != node->GetTitle()) { | 414 if (new_title != node->GetTitle()) { |
415 model->SetTitle(node, new_title); | 415 model->SetTitle(node, new_title); |
416 UserMetrics::RecordAction(L"BookmarkBubble_ChangeTitleInBubble", | 416 UserMetrics::RecordAction(L"BookmarkBubble_ChangeTitleInBubble", |
417 profile_); | 417 profile_); |
418 } | 418 } |
419 // Last index means 'Choose another folder...' | 419 // Last index means 'Choose another folder...' |
420 if (parent_combobox_->GetSelectedItem() < | 420 if (parent_combobox_->selected_item() < |
421 parent_model_.GetItemCount(parent_combobox_) - 1) { | 421 parent_model_.GetItemCount(parent_combobox_) - 1) { |
422 BookmarkNode* new_parent = | 422 BookmarkNode* new_parent = |
423 parent_model_.GetNodeAt(parent_combobox_->GetSelectedItem()); | 423 parent_model_.GetNodeAt(parent_combobox_->selected_item()); |
424 if (new_parent != node->GetParent()) { | 424 if (new_parent != node->GetParent()) { |
425 UserMetrics::RecordAction(L"BookmarkBubble_ChangeParent", profile_); | 425 UserMetrics::RecordAction(L"BookmarkBubble_ChangeParent", profile_); |
426 model->Move(node, new_parent, new_parent->GetChildCount()); | 426 model->Move(node, new_parent, new_parent->GetChildCount()); |
427 } | 427 } |
428 } | 428 } |
429 } | 429 } |
430 } | 430 } |
OLD | NEW |