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 "chrome/app/chrome_dll_resource.h" | 7 #include "chrome/app/chrome_dll_resource.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_editor.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
9 #include "chrome/browser/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/bookmarks/bookmark_utils.h" |
10 #include "chrome/browser/metrics/user_metrics.h" | 11 #include "chrome/browser/metrics/user_metrics.h" |
11 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
12 #include "chrome/browser/views/bookmark_editor_view.h" | |
13 #include "chrome/browser/views/info_bubble.h" | 13 #include "chrome/browser/views/info_bubble.h" |
14 #include "chrome/browser/views/standard_layout.h" | 14 #include "chrome/browser/views/standard_layout.h" |
15 #include "chrome/common/gfx/chrome_canvas.h" | 15 #include "chrome/common/gfx/chrome_canvas.h" |
16 #include "chrome/common/l10n_util.h" | 16 #include "chrome/common/l10n_util.h" |
17 #include "chrome/common/notification_service.h" | 17 #include "chrome/common/notification_service.h" |
18 #include "chrome/common/resource_bundle.h" | 18 #include "chrome/common/resource_bundle.h" |
19 #include "chrome/views/controls/button/native_button.h" | 19 #include "chrome/views/controls/button/native_button.h" |
20 #include "chrome/views/controls/text_field.h" | 20 #include "chrome/views/controls/text_field.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" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // Windows gets confused as to who it should give active status to. We | 366 // Windows gets confused as to who it should give active status to. We |
367 // explicitly hide the bookmark bubble window in such a way that activation | 367 // explicitly hide the bookmark bubble window in such a way that activation |
368 // status changes. That way, when the editor closes, activation is properly | 368 // status changes. That way, when the editor closes, activation is properly |
369 // restored to the browser. | 369 // restored to the browser. |
370 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE); | 370 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE); |
371 | 371 |
372 // Even though we just hid the window, we need to invoke Close to schedule | 372 // Even though we just hid the window, we need to invoke Close to schedule |
373 // the delete and all that. | 373 // the delete and all that. |
374 Close(); | 374 Close(); |
375 | 375 |
376 if (node) | 376 if (node) { |
377 BookmarkEditorView::Show(parent, profile_, NULL, node, | 377 BookmarkEditor::Show(parent, profile_, NULL, node, |
378 BookmarkEditorView::SHOW_TREE, NULL); | 378 BookmarkEditor::SHOW_TREE, NULL); |
| 379 } |
379 } | 380 } |
380 | 381 |
381 void BookmarkBubbleView::ApplyEdits() { | 382 void BookmarkBubbleView::ApplyEdits() { |
382 // Set this to make sure we don't attempt to apply edits again. | 383 // Set this to make sure we don't attempt to apply edits again. |
383 apply_edits_ = false; | 384 apply_edits_ = false; |
384 | 385 |
385 BookmarkModel* model = profile_->GetBookmarkModel(); | 386 BookmarkModel* model = profile_->GetBookmarkModel(); |
386 BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); | 387 BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); |
387 if (node) { | 388 if (node) { |
388 const std::wstring new_title = title_tf_->GetText(); | 389 const std::wstring new_title = title_tf_->GetText(); |
389 if (new_title != node->GetTitle()) { | 390 if (new_title != node->GetTitle()) { |
390 model->SetTitle(node, new_title); | 391 model->SetTitle(node, new_title); |
391 UserMetrics::RecordAction(L"BookmarkBubble_ChangeTitleInBubble", | 392 UserMetrics::RecordAction(L"BookmarkBubble_ChangeTitleInBubble", |
392 profile_); | 393 profile_); |
393 } | 394 } |
394 // Last index means 'Choose another folder...' | 395 // Last index means 'Choose another folder...' |
395 if (parent_combobox_->GetSelectedItem() < | 396 if (parent_combobox_->GetSelectedItem() < |
396 parent_model_.GetItemCount(parent_combobox_) - 1) { | 397 parent_model_.GetItemCount(parent_combobox_) - 1) { |
397 BookmarkNode* new_parent = | 398 BookmarkNode* new_parent = |
398 parent_model_.GetNodeAt(parent_combobox_->GetSelectedItem()); | 399 parent_model_.GetNodeAt(parent_combobox_->GetSelectedItem()); |
399 if (new_parent != node->GetParent()) { | 400 if (new_parent != node->GetParent()) { |
400 UserMetrics::RecordAction(L"BookmarkBubble_ChangeParent", profile_); | 401 UserMetrics::RecordAction(L"BookmarkBubble_ChangeParent", profile_); |
401 model->Move(node, new_parent, new_parent->GetChildCount()); | 402 model->Move(node, new_parent, new_parent->GetChildCount()); |
402 } | 403 } |
403 } | 404 } |
404 } | 405 } |
405 } | 406 } |
OLD | NEW |