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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 } else { | 356 } else { |
357 DCHECK(sender == close_button_); | 357 DCHECK(sender == close_button_); |
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 #if defined(TOUCH_UI) | 365 #if defined(TOUCH_UI) |
366 // TODO(saintlou): this brings up a modal window that can't be dismissed | |
367 // on touch and is tracked in chromium-os by crosbug.com/13899 | |
368 bubble_->set_fade_away_on_close(true); | 366 bubble_->set_fade_away_on_close(true); |
369 Close(); | 367 #endif |
Rick Byers
2011/08/04 18:26:07
I think you should probably remove this whole #if
flackr
2011/08/12 18:11:24
Done.
| |
370 #else | |
371 const BookmarkNode* node = | 368 const BookmarkNode* node = |
372 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_); | 369 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_); |
373 | 370 |
371 #if not defined(WEBUI_BOOKMARK_EDITOR) | |
374 #if defined(OS_WIN) | 372 #if defined(OS_WIN) |
375 // 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 |
376 // is the info bubble and will close shortly). | 374 // is the info bubble and will close shortly). |
377 HWND parent = GetAncestor(GetWidget()->GetNativeView(), GA_ROOTOWNER); | 375 HWND parent = GetAncestor(GetWidget()->GetNativeView(), GA_ROOTOWNER); |
378 | 376 |
379 // 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 |
380 // 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 |
381 // 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 |
382 // 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 |
383 // 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 |
384 // status changes. That way, when the editor closes, activation is properly | 382 // status changes. That way, when the editor closes, activation is properly |
385 // restored to the browser. | 383 // restored to the browser. |
386 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE); | 384 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE); |
387 #elif defined(TOOLKIT_USES_GTK) | 385 #elif defined(TOOLKIT_USES_GTK) |
388 gfx::NativeWindow parent = GTK_WINDOW( | 386 gfx::NativeWindow parent = GTK_WINDOW( |
389 static_cast<views::NativeWidgetGtk*>(GetWidget()->native_widget())-> | 387 static_cast<views::NativeWidgetGtk*>(GetWidget()->native_widget())-> |
390 GetTransientParent()); | 388 GetTransientParent()); |
391 #endif | 389 #endif |
390 #endif | |
392 | 391 |
393 // Even though we just hid the window, we need to invoke Close to schedule | 392 // Even though we just hid the window, we need to invoke Close to schedule |
394 // the delete and all that. | 393 // the delete and all that. |
395 Close(); | 394 Close(); |
396 | 395 |
397 if (node) { | 396 if (node) { |
397 #if defined(WEBUI_BOOKMARK_EDITOR) | |
398 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | |
399 DCHECK(browser); | |
400 browser->OpenBookmarkManagerEditNode(node->id()); | |
401 #else | |
398 BookmarkEditor::Show(parent, profile_, NULL, | 402 BookmarkEditor::Show(parent, profile_, NULL, |
399 BookmarkEditor::EditDetails(node), | 403 BookmarkEditor::EditDetails(node), |
400 BookmarkEditor::SHOW_TREE); | 404 BookmarkEditor::SHOW_TREE); |
405 #endif | |
401 } | 406 } |
402 #endif | |
403 } | 407 } |
404 | 408 |
405 void BookmarkBubbleView::ApplyEdits() { | 409 void BookmarkBubbleView::ApplyEdits() { |
406 // Set this to make sure we don't attempt to apply edits again. | 410 // Set this to make sure we don't attempt to apply edits again. |
407 apply_edits_ = false; | 411 apply_edits_ = false; |
408 | 412 |
409 BookmarkModel* model = profile_->GetBookmarkModel(); | 413 BookmarkModel* model = profile_->GetBookmarkModel(); |
410 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); | 414 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); |
411 if (node) { | 415 if (node) { |
412 const string16 new_title = title_tf_->text(); | 416 const string16 new_title = title_tf_->text(); |
413 if (new_title != node->GetTitle()) { | 417 if (new_title != node->GetTitle()) { |
414 model->SetTitle(node, new_title); | 418 model->SetTitle(node, new_title); |
415 UserMetrics::RecordAction( | 419 UserMetrics::RecordAction( |
416 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 420 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
417 } | 421 } |
418 // Last index means 'Choose another folder...' | 422 // Last index means 'Choose another folder...' |
419 if (parent_combobox_->selected_item() < | 423 if (parent_combobox_->selected_item() < |
420 parent_model_.GetItemCount() - 1) { | 424 parent_model_.GetItemCount() - 1) { |
421 const BookmarkNode* new_parent = | 425 const BookmarkNode* new_parent = |
422 parent_model_.GetNodeAt(parent_combobox_->selected_item()); | 426 parent_model_.GetNodeAt(parent_combobox_->selected_item()); |
423 if (new_parent != node->parent()) { | 427 if (new_parent != node->parent()) { |
424 UserMetrics::RecordAction( | 428 UserMetrics::RecordAction( |
425 UserMetricsAction("BookmarkBubble_ChangeParent")); | 429 UserMetricsAction("BookmarkBubble_ChangeParent")); |
426 model->Move(node, new_parent, new_parent->child_count()); | 430 model->Move(node, new_parent, new_parent->child_count()); |
427 } | 431 } |
428 } | 432 } |
429 } | 433 } |
430 } | 434 } |
OLD | NEW |