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

Side by Side Diff: chrome/browser/gtk/bookmark_editor_gtk.cc

Issue 1795007: Get rid of BookmarkEditor::Show()'s BookmarkEditor::Handler argument. (Closed)
Patch Set: baz Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/bookmark_editor_gtk.h" 5 #include "chrome/browser/gtk/bookmark_editor_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 23 matching lines...) Expand all
34 static const int kTreeWidth = 300; 34 static const int kTreeWidth = 300;
35 static const int kTreeHeight = 150; 35 static const int kTreeHeight = 150;
36 36
37 } // namespace 37 } // namespace
38 38
39 // static 39 // static
40 void BookmarkEditor::Show(gfx::NativeWindow parent_hwnd, 40 void BookmarkEditor::Show(gfx::NativeWindow parent_hwnd,
41 Profile* profile, 41 Profile* profile,
42 const BookmarkNode* parent, 42 const BookmarkNode* parent,
43 const EditDetails& details, 43 const EditDetails& details,
44 Configuration configuration, 44 Configuration configuration) {
45 Handler* handler) {
46 DCHECK(profile); 45 DCHECK(profile);
47 BookmarkEditorGtk* editor = 46 BookmarkEditorGtk* editor =
48 new BookmarkEditorGtk(parent_hwnd, profile, parent, details, 47 new BookmarkEditorGtk(parent_hwnd, profile, parent, details,
49 configuration, handler); 48 configuration);
50 editor->Show(); 49 editor->Show();
51 } 50 }
52 51
53 BookmarkEditorGtk::BookmarkEditorGtk( 52 BookmarkEditorGtk::BookmarkEditorGtk(
54 GtkWindow* window, 53 GtkWindow* window,
55 Profile* profile, 54 Profile* profile,
56 const BookmarkNode* parent, 55 const BookmarkNode* parent,
57 const EditDetails& details, 56 const EditDetails& details,
58 BookmarkEditor::Configuration configuration, 57 BookmarkEditor::Configuration configuration)
59 BookmarkEditor::Handler* handler)
60 : profile_(profile), 58 : profile_(profile),
61 dialog_(NULL), 59 dialog_(NULL),
62 parent_(parent), 60 parent_(parent),
63 details_(details), 61 details_(details),
64 running_menu_for_root_(false), 62 running_menu_for_root_(false),
65 show_tree_(configuration == SHOW_TREE), 63 show_tree_(configuration == SHOW_TREE) {
66 handler_(handler) {
67 DCHECK(profile); 64 DCHECK(profile);
68 Init(window); 65 Init(window);
69 } 66 }
70 67
71 BookmarkEditorGtk::~BookmarkEditorGtk() { 68 BookmarkEditorGtk::~BookmarkEditorGtk() {
72 // The tree model is deleted before the view. Reset the model otherwise the 69 // The tree model is deleted before the view. Reset the model otherwise the
73 // tree will reference a deleted model. 70 // tree will reference a deleted model.
74 71
75 bb_model_->RemoveObserver(this); 72 bb_model_->RemoveObserver(this);
76 } 73 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // We're going to apply edits to the bookmark bar model, which will call us 306 // We're going to apply edits to the bookmark bar model, which will call us
310 // back. Normally when a structural edit occurs we reset the tree model. 307 // back. Normally when a structural edit occurs we reset the tree model.
311 // We don't want to do that here, so we remove ourselves as an observer. 308 // We don't want to do that here, so we remove ourselves as an observer.
312 bb_model_->RemoveObserver(this); 309 bb_model_->RemoveObserver(this);
313 310
314 GURL new_url(GetInputURL()); 311 GURL new_url(GetInputURL());
315 std::wstring new_title(GetInputTitle()); 312 std::wstring new_title(GetInputTitle());
316 313
317 if (!show_tree_ || !selected_parent) { 314 if (!show_tree_ || !selected_parent) {
318 bookmark_utils::ApplyEditsWithNoGroupChange( 315 bookmark_utils::ApplyEditsWithNoGroupChange(
319 bb_model_, parent_, details_, new_title, new_url, handler_.get()); 316 bb_model_, parent_, details_, new_title, new_url, NULL);
320 return; 317 return;
321 } 318 }
322 319
323 // Create the new groups and update the titles. 320 // Create the new groups and update the titles.
324 const BookmarkNode* new_parent = 321 const BookmarkNode* new_parent =
325 bookmark_utils::CommitTreeStoreDifferencesBetween( 322 bookmark_utils::CommitTreeStoreDifferencesBetween(
326 bb_model_, tree_store_, selected_parent); 323 bb_model_, tree_store_, selected_parent);
327 324
328 if (!new_parent) { 325 if (!new_parent) {
329 // Bookmarks must be parented. 326 // Bookmarks must be parented.
330 NOTREACHED(); 327 NOTREACHED();
331 return; 328 return;
332 } 329 }
333 330
334 bookmark_utils::ApplyEditsWithPossibleGroupChange( 331 bookmark_utils::ApplyEditsWithPossibleGroupChange(
335 bb_model_, new_parent, details_, new_title, new_url, handler_.get()); 332 bb_model_, new_parent, details_, new_title, new_url, NULL);
sky 2010/04/28 16:09:45 Can you cleanup up bookmark_utils too?
viettrungluu 2010/04/28 16:20:09 One step at a time. ;-) I have to make sure that n
336 } 333 }
337 334
338 void BookmarkEditorGtk::AddNewGroup(GtkTreeIter* parent, GtkTreeIter* child) { 335 void BookmarkEditorGtk::AddNewGroup(GtkTreeIter* parent, GtkTreeIter* child) {
339 gtk_tree_store_append(tree_store_, child, parent); 336 gtk_tree_store_append(tree_store_, child, parent);
340 gtk_tree_store_set( 337 gtk_tree_store_set(
341 tree_store_, child, 338 tree_store_, child,
342 bookmark_utils::FOLDER_ICON, GtkThemeProvider::GetFolderIcon(true), 339 bookmark_utils::FOLDER_ICON, GtkThemeProvider::GetFolderIcon(true),
343 bookmark_utils::FOLDER_NAME, 340 bookmark_utils::FOLDER_NAME,
344 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME).c_str(), 341 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME).c_str(),
345 bookmark_utils::ITEM_ID, static_cast<int64>(0), 342 bookmark_utils::ITEM_ID, static_cast<int64>(0),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 GTK_TREE_MODEL(tree_store_), &new_item_iter); 413 GTK_TREE_MODEL(tree_store_), &new_item_iter);
417 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); 414 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path);
418 415
419 // Make the folder name editable. 416 // Make the folder name editable.
420 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, 417 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path,
421 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), 418 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0),
422 TRUE); 419 TRUE);
423 420
424 gtk_tree_path_free(path); 421 gtk_tree_path_free(path);
425 } 422 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/bookmark_editor_gtk.h ('k') | chrome/browser/gtk/bookmark_editor_gtk_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698