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