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

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

Issue 7572022: Use bookmark manager to add/edit bookmark pages with webui_dialogs=1. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Windows build compatibility. Created 9 years, 4 months 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"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 ShowEditor(); 355 ShowEditor();
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)
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);
369 Close();
370 #else
371 const BookmarkNode* node = 365 const BookmarkNode* node =
372 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_); 366 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_);
373 367
368 #if !defined(WEBUI_DIALOGS)
374 #if defined(OS_WIN) 369 #if defined(OS_WIN)
375 // Parent the editor to our root ancestor (not the root we're in, as that 370 // Parent the editor to our root ancestor (not the root we're in, as that
376 // is the info bubble and will close shortly). 371 // is the info bubble and will close shortly).
377 HWND parent = GetAncestor(GetWidget()->GetNativeView(), GA_ROOTOWNER); 372 HWND parent = GetAncestor(GetWidget()->GetNativeView(), GA_ROOTOWNER);
378 373
379 // We're about to show the bookmark editor. When the bookmark editor closes 374 // 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 375 // 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 376 // 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 377 // 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 378 // explicitly hide the bookmark bubble window in such a way that activation
384 // status changes. That way, when the editor closes, activation is properly 379 // status changes. That way, when the editor closes, activation is properly
385 // restored to the browser. 380 // restored to the browser.
386 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE); 381 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE);
387 #elif defined(TOOLKIT_USES_GTK) 382 #elif defined(TOOLKIT_USES_GTK)
388 gfx::NativeWindow parent = GTK_WINDOW( 383 gfx::NativeWindow parent = GTK_WINDOW(
389 static_cast<views::NativeWidgetGtk*>(GetWidget()->native_widget())-> 384 static_cast<views::NativeWidgetGtk*>(GetWidget()->native_widget())->
390 GetTransientParent()); 385 GetTransientParent());
391 #endif 386 #endif
387 #endif
392 388
393 // Even though we just hid the window, we need to invoke Close to schedule 389 // Even though we just hid the window, we need to invoke Close to schedule
394 // the delete and all that. 390 // the delete and all that.
395 Close(); 391 Close();
396 392
397 if (node) { 393 if (node) {
394 #if defined(WEBUI_DIALOGS)
395 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
396 DCHECK(browser);
397 browser->OpenBookmarkManagerEditNode(node->id());
398 #else
398 BookmarkEditor::Show(parent, profile_, NULL, 399 BookmarkEditor::Show(parent, profile_, NULL,
399 BookmarkEditor::EditDetails(node), 400 BookmarkEditor::EditDetails(node),
400 BookmarkEditor::SHOW_TREE); 401 BookmarkEditor::SHOW_TREE);
402 #endif
401 } 403 }
402 #endif
403 } 404 }
404 405
405 void BookmarkBubbleView::ApplyEdits() { 406 void BookmarkBubbleView::ApplyEdits() {
406 // Set this to make sure we don't attempt to apply edits again. 407 // Set this to make sure we don't attempt to apply edits again.
407 apply_edits_ = false; 408 apply_edits_ = false;
408 409
409 BookmarkModel* model = profile_->GetBookmarkModel(); 410 BookmarkModel* model = profile_->GetBookmarkModel();
410 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); 411 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_);
411 if (node) { 412 if (node) {
412 const string16 new_title = title_tf_->text(); 413 const string16 new_title = title_tf_->text();
413 if (new_title != node->GetTitle()) { 414 if (new_title != node->GetTitle()) {
414 model->SetTitle(node, new_title); 415 model->SetTitle(node, new_title);
415 UserMetrics::RecordAction( 416 UserMetrics::RecordAction(
416 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); 417 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"));
417 } 418 }
418 // Last index means 'Choose another folder...' 419 // Last index means 'Choose another folder...'
419 if (parent_combobox_->selected_item() < 420 if (parent_combobox_->selected_item() <
420 parent_model_.GetItemCount() - 1) { 421 parent_model_.GetItemCount() - 1) {
421 const BookmarkNode* new_parent = 422 const BookmarkNode* new_parent =
422 parent_model_.GetNodeAt(parent_combobox_->selected_item()); 423 parent_model_.GetNodeAt(parent_combobox_->selected_item());
423 if (new_parent != node->parent()) { 424 if (new_parent != node->parent()) {
424 UserMetrics::RecordAction( 425 UserMetrics::RecordAction(
425 UserMetricsAction("BookmarkBubble_ChangeParent")); 426 UserMetricsAction("BookmarkBubble_ChangeParent"));
426 model->Move(node, new_parent, new_parent->child_count()); 427 model->Move(node, new_parent, new_parent->child_count());
427 } 428 }
428 } 429 }
429 } 430 }
430 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698