| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 bubble_->set_fade_away_on_close(true); | 358 bubble_->set_fade_away_on_close(true); |
| 359 Close(); | 359 Close(); |
| 360 } | 360 } |
| 361 // WARNING: we've most likely been deleted when CloseWindow returns. | 361 // WARNING: we've most likely been deleted when CloseWindow returns. |
| 362 } | 362 } |
| 363 | 363 |
| 364 void BookmarkBubbleView::ShowEditor() { | 364 void BookmarkBubbleView::ShowEditor() { |
| 365 const BookmarkNode* node = | 365 const BookmarkNode* node = |
| 366 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_); | 366 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_); |
| 367 | 367 |
| 368 #if !defined(WEBUI_DIALOGS) | |
| 369 #if defined(OS_WIN) | 368 #if defined(OS_WIN) |
| 370 // Parent the editor to our root ancestor (not the root we're in, as that | 369 // Parent the editor to our root ancestor (not the root we're in, as that |
| 371 // is the info bubble and will close shortly). | 370 // is the info bubble and will close shortly). |
| 372 HWND parent = GetAncestor(GetWidget()->GetNativeView(), GA_ROOTOWNER); | 371 HWND parent = GetAncestor(GetWidget()->GetNativeView(), GA_ROOTOWNER); |
| 373 | 372 |
| 374 // We're about to show the bookmark editor. When the bookmark editor closes | 373 // We're about to show the bookmark editor. When the bookmark editor closes |
| 375 // we want the browser to become active. NativeWidgetWin::Hide() does a hide | 374 // we want the browser to become active. NativeWidgetWin::Hide() does a hide |
| 376 // in a such way that activation isn't changed, which means when we close | 375 // in a such way that activation isn't changed, which means when we close |
| 377 // Windows gets confused as to who it should give active status to. We | 376 // Windows gets confused as to who it should give active status to. We |
| 378 // explicitly hide the bookmark bubble window in such a way that activation | 377 // explicitly hide the bookmark bubble window in such a way that activation |
| 379 // status changes. That way, when the editor closes, activation is properly | 378 // status changes. That way, when the editor closes, activation is properly |
| 380 // restored to the browser. | 379 // restored to the browser. |
| 381 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE); | 380 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE); |
| 382 #elif defined(TOOLKIT_USES_GTK) | 381 #elif defined(TOOLKIT_USES_GTK) |
| 383 gfx::NativeWindow parent = GTK_WINDOW( | 382 gfx::NativeWindow parent = GTK_WINDOW( |
| 384 static_cast<views::NativeWidgetGtk*>(GetWidget()->native_widget())-> | 383 static_cast<views::NativeWidgetGtk*>(GetWidget()->native_widget())-> |
| 385 GetTransientParent()); | 384 GetTransientParent()); |
| 386 #endif | 385 #endif |
| 387 #endif | |
| 388 | 386 |
| 389 // Even though we just hid the window, we need to invoke Close to schedule | 387 // Even though we just hid the window, we need to invoke Close to schedule |
| 390 // the delete and all that. | 388 // the delete and all that. |
| 391 Close(); | 389 Close(); |
| 392 | 390 |
| 393 if (node) { | 391 if (node) { |
| 394 #if defined(WEBUI_DIALOGS) | 392 BookmarkEditor::Show(parent, profile_, |
| 395 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 393 BookmarkEditor::EditDetails::EditNode(node), |
| 396 DCHECK(browser); | |
| 397 browser->OpenBookmarkManagerEditNode(node->id()); | |
| 398 #else | |
| 399 BookmarkEditor::Show(parent, profile_, NULL, | |
| 400 BookmarkEditor::EditDetails(node), | |
| 401 BookmarkEditor::SHOW_TREE); | 394 BookmarkEditor::SHOW_TREE); |
| 402 #endif | |
| 403 } | 395 } |
| 404 } | 396 } |
| 405 | 397 |
| 406 void BookmarkBubbleView::ApplyEdits() { | 398 void BookmarkBubbleView::ApplyEdits() { |
| 407 // Set this to make sure we don't attempt to apply edits again. | 399 // Set this to make sure we don't attempt to apply edits again. |
| 408 apply_edits_ = false; | 400 apply_edits_ = false; |
| 409 | 401 |
| 410 BookmarkModel* model = profile_->GetBookmarkModel(); | 402 BookmarkModel* model = profile_->GetBookmarkModel(); |
| 411 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); | 403 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); |
| 412 if (node) { | 404 if (node) { |
| 413 const string16 new_title = title_tf_->text(); | 405 const string16 new_title = title_tf_->text(); |
| 414 if (new_title != node->GetTitle()) { | 406 if (new_title != node->GetTitle()) { |
| 415 model->SetTitle(node, new_title); | 407 model->SetTitle(node, new_title); |
| 416 UserMetrics::RecordAction( | 408 UserMetrics::RecordAction( |
| 417 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 409 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
| 418 } | 410 } |
| 419 // Last index means 'Choose another folder...' | 411 // Last index means 'Choose another folder...' |
| 420 if (parent_combobox_->selected_item() < | 412 if (parent_combobox_->selected_item() < |
| 421 parent_model_.GetItemCount() - 1) { | 413 parent_model_.GetItemCount() - 1) { |
| 422 const BookmarkNode* new_parent = | 414 const BookmarkNode* new_parent = |
| 423 parent_model_.GetNodeAt(parent_combobox_->selected_item()); | 415 parent_model_.GetNodeAt(parent_combobox_->selected_item()); |
| 424 if (new_parent != node->parent()) { | 416 if (new_parent != node->parent()) { |
| 425 UserMetrics::RecordAction( | 417 UserMetrics::RecordAction( |
| 426 UserMetricsAction("BookmarkBubble_ChangeParent")); | 418 UserMetricsAction("BookmarkBubble_ChangeParent")); |
| 427 model->Move(node, new_parent, new_parent->child_count()); | 419 model->Move(node, new_parent, new_parent->child_count()); |
| 428 } | 420 } |
| 429 } | 421 } |
| 430 } | 422 } |
| 431 } | 423 } |
| OLD | NEW |