1// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_FOLDER_EDITOR_CONTROLLER_H_ 6#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_FOLDER_EDITOR_CONTROLLER_H_ 7#pragma once 8 9#include "base/basictypes.h" 10#include "chrome/browser/bookmarks/base_bookmark_model_observer.h" 11#include "chrome/browser/ui/input_window_dialog.h" 12#include "ui/gfx/native_widget_types.h" 13 14class Profile; 15 16// BookmarkFolderEditorController manages the editing and/or creation of a 17// folder. If the user presses ok, the name change is committed to the model. 18// 19// BookmarkFolderEditorController deletes itself when the window is closed. 20class BookmarkFolderEditorController : public InputWindowDialog::Delegate, 21 public BaseBookmarkModelObserver { 22 public: 23 enum Type { 24 NEW_BOOKMARK, // Indicates that we are creating a new bookmark. 25 EXISTING_BOOKMARK, // Indicates that we are renaming an existing bookmark. 26 }; 27 28 virtual ~BookmarkFolderEditorController(); 29 30 static void Show(Profile* profile, 31 gfx::NativeWindow wnd, 32 const BookmarkNode* node, 33 int index, 34 Type type); 35 36 private: 37 BookmarkFolderEditorController(Profile* profile, 38 gfx::NativeWindow wnd, 39 const BookmarkNode* node, 40 int index, 41 Type type); 42 43 // Overridden from InputWindowDialog::Delegate: 44 virtual bool IsValid(const std::wstring& text); 45 virtual void InputAccepted(const std::wstring& text); 46 virtual void InputCanceled(); 47 48 // Overridden from BaseBookmarkModelObserver: 49 virtual void BookmarkModelChanged(); 50 virtual void BookmarkModelBeingDeleted(BookmarkModel* model); 51 52 Profile* profile_; 53 54 BookmarkModel* model_; 55 56 // If |is_new_| is true, this is the parent to create the new node under. 57 // Otherwise this is the node to change the title of. 58 const BookmarkNode* node_; 59 60 // Index to insert the new folder at. 61 int index_; 62 63 const bool is_new_; 64 65 InputWindowDialog* dialog_; 66 67 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderEditorController); 68}; 69 70#endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_FOLDER_EDITOR_CONTROLLER_H_ 71