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

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

Issue 7670041: Add --use-more-webui runtime flag to toggle WebUI replacements for native dialogs. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merge with trunk. Created 9 years, 3 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 17 matching lines...) Expand all
28 #include "views/controls/button/text_button.h" 28 #include "views/controls/button/text_button.h"
29 #include "views/controls/label.h" 29 #include "views/controls/label.h"
30 #include "views/controls/link.h" 30 #include "views/controls/link.h"
31 #include "views/controls/textfield/textfield.h" 31 #include "views/controls/textfield/textfield.h"
32 #include "views/events/event.h" 32 #include "views/events/event.h"
33 #include "views/focus/focus_manager.h" 33 #include "views/focus/focus_manager.h"
34 #include "views/layout/grid_layout.h" 34 #include "views/layout/grid_layout.h"
35 #include "views/layout/layout_constants.h" 35 #include "views/layout/layout_constants.h"
36 #include "views/window/client_view.h" 36 #include "views/window/client_view.h"
37 37
38 #if defined(TOOLKIT_USES_GTK)
39 #include "views/widget/native_widget_gtk.h"
40 #endif
41
38 using views::ColumnSet; 42 using views::ColumnSet;
39 using views::GridLayout; 43 using views::GridLayout;
40 44
41 // Padding between "Title:" and the actual title. 45 // Padding between "Title:" and the actual title.
42 static const int kTitlePadding = 4; 46 static const int kTitlePadding = 4;
43 47
44 // Minimum width for the fields - they will push out the size of the bubble if 48 // Minimum width for the fields - they will push out the size of the bubble if
45 // necessary. This should be big enough so that the field pushes the right side 49 // necessary. This should be big enough so that the field pushes the right side
46 // of the bubble far enough so that the edit button's left edge is to the right 50 // of the bubble far enough so that the edit button's left edge is to the right
47 // of the field's left edge. 51 // of the field's left edge.
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 bubble_->set_fade_away_on_close(true); 363 bubble_->set_fade_away_on_close(true);
360 Close(); 364 Close();
361 } 365 }
362 // WARNING: we've most likely been deleted when CloseWindow returns. 366 // WARNING: we've most likely been deleted when CloseWindow returns.
363 } 367 }
364 368
365 void BookmarkBubbleView::ShowEditor() { 369 void BookmarkBubbleView::ShowEditor() {
366 const BookmarkNode* node = 370 const BookmarkNode* node =
367 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_); 371 profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_);
368 372
369 #if !defined(WEBUI_DIALOGS)
370 #if defined(USE_AURA) 373 #if defined(USE_AURA)
371 NOTIMPLEMENTED(); 374 NOTIMPLEMENTED();
372 gfx::NativeView parent = NULL; 375 gfx::NativeView parent = NULL;
373 #elif defined(OS_WIN) 376 #elif defined(OS_WIN)
374 // Parent the editor to our root ancestor (not the root we're in, as that 377 // Parent the editor to our root ancestor (not the root we're in, as that
375 // is the info bubble and will close shortly). 378 // is the info bubble and will close shortly).
376 HWND parent = GetAncestor(GetWidget()->GetNativeView(), GA_ROOTOWNER); 379 HWND parent = GetAncestor(GetWidget()->GetNativeView(), GA_ROOTOWNER);
377 380
378 // We're about to show the bookmark editor. When the bookmark editor closes 381 // 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 382 // 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 383 // 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 384 // 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 385 // explicitly hide the bookmark bubble window in such a way that activation
383 // status changes. That way, when the editor closes, activation is properly 386 // status changes. That way, when the editor closes, activation is properly
384 // restored to the browser. 387 // restored to the browser.
385 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE); 388 ShowWindow(GetWidget()->GetNativeView(), SW_HIDE);
386 #elif defined(TOOLKIT_USES_GTK) 389 #elif defined(TOOLKIT_USES_GTK)
387 gfx::NativeWindow parent = GTK_WINDOW( 390 gfx::NativeWindow parent = GTK_WINDOW(
388 static_cast<views::NativeWidgetGtk*>(GetWidget()->native_widget())-> 391 static_cast<views::NativeWidgetGtk*>(GetWidget()->native_widget())->
389 GetTransientParent()); 392 GetTransientParent());
390 #endif 393 #endif
391 #endif
392 394
393 // Even though we just hid the window, we need to invoke Close to schedule 395 // Even though we just hid the window, we need to invoke Close to schedule
394 // the delete and all that. 396 // the delete and all that.
395 Close(); 397 Close();
396 398
397 if (node) { 399 if (node) {
398 #if defined(WEBUI_DIALOGS) 400 BookmarkEditor::Show(parent, profile_,
399 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); 401 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); 402 BookmarkEditor::SHOW_TREE);
406 #endif
407 } 403 }
408 } 404 }
409 405
410 void BookmarkBubbleView::ApplyEdits() { 406 void BookmarkBubbleView::ApplyEdits() {
411 // 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.
412 apply_edits_ = false; 408 apply_edits_ = false;
413 409
414 BookmarkModel* model = profile_->GetBookmarkModel(); 410 BookmarkModel* model = profile_->GetBookmarkModel();
415 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_); 411 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url_);
416 if (node) { 412 if (node) {
417 const string16 new_title = title_tf_->text(); 413 const string16 new_title = title_tf_->text();
418 if (new_title != node->GetTitle()) { 414 if (new_title != node->GetTitle()) {
419 model->SetTitle(node, new_title); 415 model->SetTitle(node, new_title);
420 UserMetrics::RecordAction( 416 UserMetrics::RecordAction(
421 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); 417 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"));
422 } 418 }
423 // Last index means 'Choose another folder...' 419 // Last index means 'Choose another folder...'
424 if (parent_combobox_->selected_item() < 420 if (parent_combobox_->selected_item() <
425 parent_model_.GetItemCount() - 1) { 421 parent_model_.GetItemCount() - 1) {
426 const BookmarkNode* new_parent = 422 const BookmarkNode* new_parent =
427 parent_model_.GetNodeAt(parent_combobox_->selected_item()); 423 parent_model_.GetNodeAt(parent_combobox_->selected_item());
428 if (new_parent != node->parent()) { 424 if (new_parent != node->parent()) {
429 UserMetrics::RecordAction( 425 UserMetrics::RecordAction(
430 UserMetricsAction("BookmarkBubble_ChangeParent")); 426 UserMetricsAction("BookmarkBubble_ChangeParent"));
431 model->Move(node, new_parent, new_parent->child_count()); 427 model->Move(node, new_parent, new_parent->child_count());
432 } 428 }
433 } 429 }
434 } 430 }
435 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698