Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
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/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/views/window.h" 17 #include "chrome/browser/ui/views/window.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "content/browser/user_metrics.h"
20 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/user_metrics.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
23 #include "ui/base/keycodes/keyboard_codes.h" 23 #include "ui/base/keycodes/keyboard_codes.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/views/controls/button/text_button.h" 26 #include "ui/views/controls/button/text_button.h"
27 #include "ui/views/controls/combobox/combobox.h" 27 #include "ui/views/controls/combobox/combobox.h"
28 #include "ui/views/controls/label.h" 28 #include "ui/views/controls/label.h"
29 #include "ui/views/controls/link.h" 29 #include "ui/views/controls/link.h"
30 #include "ui/views/controls/textfield/textfield.h" 30 #include "ui/views/controls/textfield/textfield.h"
31 #include "ui/views/events/event.h" 31 #include "ui/views/events/event.h"
32 #include "ui/views/layout/grid_layout.h" 32 #include "ui/views/layout/grid_layout.h"
33 #include "ui/views/layout/layout_constants.h" 33 #include "ui/views/layout/layout_constants.h"
34 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
35 35
36 using content::UserMetricsAction;
36 using views::ColumnSet; 37 using views::ColumnSet;
37 using views::GridLayout; 38 using views::GridLayout;
38 39
39 // Padding between "Title:" and the actual title. 40 // Padding between "Title:" and the actual title.
40 static const int kTitlePadding = 4; 41 static const int kTitlePadding = 4;
41 42
42 // Minimum width for the fields - they will push out the size of the bubble if 43 // Minimum width for the fields - they will push out the size of the bubble if
43 // necessary. This should be big enough so that the field pushes the right side 44 // necessary. This should be big enough so that the field pushes the right side
44 // of the bubble far enough so that the edit button's left edge is to the right 45 // of the bubble far enough so that the edit button's left edge is to the right
45 // of the field's left edge. 46 // of the field's left edge.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return string16(); 266 return string16();
266 } 267 }
267 268
268 void BookmarkBubbleView::ButtonPressed( 269 void BookmarkBubbleView::ButtonPressed(
269 views::Button* sender, const views::Event& event) { 270 views::Button* sender, const views::Event& event) {
270 HandleButtonPressed(sender); 271 HandleButtonPressed(sender);
271 } 272 }
272 273
273 void BookmarkBubbleView::LinkClicked(views::Link* source, int event_flags) { 274 void BookmarkBubbleView::LinkClicked(views::Link* source, int event_flags) {
274 DCHECK(source == remove_link_); 275 DCHECK(source == remove_link_);
275 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Unstar")); 276 content::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"));
276 277
277 // Set this so we remove the bookmark after the window closes. 278 // Set this so we remove the bookmark after the window closes.
278 remove_bookmark_ = true; 279 remove_bookmark_ = true;
279 apply_edits_ = false; 280 apply_edits_ = false;
280 StartFade(false); 281 StartFade(false);
281 } 282 }
282 283
283 void BookmarkBubbleView::ItemChanged(views::Combobox* combo_box, 284 void BookmarkBubbleView::ItemChanged(views::Combobox* combo_box,
284 int prev_index, 285 int prev_index,
285 int new_index) { 286 int new_index) {
286 if (new_index + 1 == parent_model_.GetItemCount()) { 287 if (new_index + 1 == parent_model_.GetItemCount()) {
287 UserMetrics::RecordAction( 288 content::RecordAction(
288 UserMetricsAction("BookmarkBubble_EditFromCombobox")); 289 UserMetricsAction("BookmarkBubble_EditFromCombobox"));
289 ShowEditor(); 290 ShowEditor();
290 } 291 }
291 } 292 }
292 293
293 void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { 294 void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) {
294 if (sender == edit_button_) { 295 if (sender == edit_button_) {
295 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Edit")); 296 content::RecordAction(UserMetricsAction("BookmarkBubble_Edit"));
296 ShowEditor(); 297 ShowEditor();
297 } else { 298 } else {
298 DCHECK_EQ(sender, close_button_); 299 DCHECK_EQ(sender, close_button_);
299 StartFade(false); 300 StartFade(false);
300 } 301 }
301 } 302 }
302 303
303 void BookmarkBubbleView::ShowEditor() { 304 void BookmarkBubbleView::ShowEditor() {
304 const BookmarkNode* node = 305 const BookmarkNode* node =
305 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_); 306 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_);
(...skipping 11 matching lines...) Expand all
317 void BookmarkBubbleView::ApplyEdits() { 318 void BookmarkBubbleView::ApplyEdits() {
318 // Set this to make sure we don't attempt to apply edits again. 319 // Set this to make sure we don't attempt to apply edits again.
319 apply_edits_ = false; 320 apply_edits_ = false;
320 321
321 BookmarkModel* model = profile_->GetBookmarkModel(); 322 BookmarkModel* model = profile_->GetBookmarkModel();
322 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); 323 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_);
323 if (node) { 324 if (node) {
324 const string16 new_title = title_tf_->text(); 325 const string16 new_title = title_tf_->text();
325 if (new_title != node->GetTitle()) { 326 if (new_title != node->GetTitle()) {
326 model->SetTitle(node, new_title); 327 model->SetTitle(node, new_title);
327 UserMetrics::RecordAction( 328 content::RecordAction(
328 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); 329 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"));
329 } 330 }
330 // Last index means 'Choose another folder...' 331 // Last index means 'Choose another folder...'
331 if (parent_combobox_->selected_item() < parent_model_.GetItemCount() - 1) { 332 if (parent_combobox_->selected_item() < parent_model_.GetItemCount() - 1) {
332 const BookmarkNode* new_parent = 333 const BookmarkNode* new_parent =
333 parent_model_.GetNodeAt(parent_combobox_->selected_item()); 334 parent_model_.GetNodeAt(parent_combobox_->selected_item());
334 if (new_parent != node->parent()) { 335 if (new_parent != node->parent()) {
335 UserMetrics::RecordAction( 336 content::RecordAction(
336 UserMetricsAction("BookmarkBubble_ChangeParent")); 337 UserMetricsAction("BookmarkBubble_ChangeParent"));
337 model->Move(node, new_parent, new_parent->child_count()); 338 model->Move(node, new_parent, new_parent->child_count());
338 } 339 }
339 } 340 }
340 } 341 }
341 } 342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698