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

Side by Side Diff: chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.h

Issue 6339002: [Mac] Consolidate all files relating to preferences in a subdir of c/b/ui/coc... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import <Cocoa/Cocoa.h>
6
7 #import "base/mac/cocoa_protocols.h"
8 #include "base/scoped_ptr.h"
9 #include "base/string16.h"
10 #include "chrome/browser/search_engines/edit_search_engine_controller.h"
11 #include "chrome/browser/search_engines/keyword_editor_controller.h"
12 #include "chrome/browser/search_engines/template_url_model_observer.h"
13 #include "chrome/browser/ui/cocoa/table_row_nsimage_cache.h"
14 #include "ui/base/models/table_model_observer.h"
15
16 class EditSearchEngineControllerDelegate;
17 @class KeywordEditorCocoaController;
18 class Profile;
19 @class WindowSizeAutosaver;
20
21 // Very thin bridge that simply pushes notifications from C++ to ObjC.
22 class KeywordEditorModelObserver : public TemplateURLModelObserver,
23 public EditSearchEngineControllerDelegate,
24 public ui::TableModelObserver,
25 public TableRowNSImageCache::Table {
26 public:
27 explicit KeywordEditorModelObserver(KeywordEditorCocoaController* controller);
28 virtual ~KeywordEditorModelObserver();
29
30 // Notification that the template url model has changed in some way.
31 virtual void OnTemplateURLModelChanged();
32
33 // Invoked from the EditSearchEngineController when the user accepts the
34 // edits. NOTE: |template_url| is the value supplied to
35 // EditSearchEngineController's constructor, and may be NULL. A NULL value
36 // indicates a new TemplateURL should be created rather than modifying an
37 // existing TemplateURL.
38 virtual void OnEditedKeyword(const TemplateURL* template_url,
39 const string16& title,
40 const string16& keyword,
41 const std::string& url);
42
43 // ui::TableModelObserver overrides. Invalidate icon cache.
44 virtual void OnModelChanged();
45 virtual void OnItemsChanged(int start, int length);
46 virtual void OnItemsAdded(int start, int length);
47 virtual void OnItemsRemoved(int start, int length);
48
49 // TableRowNSImageCache::Table
50 virtual int RowCount() const;
51 virtual SkBitmap GetIcon(int row) const;
52
53 // Lazily converts the image at the given row and caches it in |icon_cache_|.
54 NSImage* GetImageForRow(int row);
55
56 private:
57 KeywordEditorCocoaController* controller_;
58
59 TableRowNSImageCache icon_cache_;
60
61 DISALLOW_COPY_AND_ASSIGN(KeywordEditorModelObserver);
62 };
63
64 // This controller manages a window with a table view of search engines. It
65 // acts as |tableView_|'s data source and delegate, feeding it data from the
66 // KeywordEditorController's |table_model()|.
67
68 @interface KeywordEditorCocoaController : NSWindowController
69 <NSWindowDelegate,
70 NSTableViewDataSource,
71 NSTableViewDelegate> {
72 IBOutlet NSTableView* tableView_;
73 IBOutlet NSButton* addButton_;
74 IBOutlet NSButton* removeButton_;
75 IBOutlet NSButton* makeDefaultButton_;
76
77 scoped_nsobject<NSTextFieldCell> groupCell_;
78
79 Profile* profile_; // weak
80 scoped_ptr<KeywordEditorController> controller_;
81 scoped_ptr<KeywordEditorModelObserver> observer_;
82
83 scoped_nsobject<WindowSizeAutosaver> sizeSaver_;
84 }
85 @property (nonatomic, readonly) KeywordEditorController* controller;
86
87 // Show the keyword editor associated with the given profile (or the
88 // original profile if this is an incognito profile). If no keyword
89 // editor exists for this profile, create one and show it. Any
90 // resulting editor releases itself when closed.
91 + (void)showKeywordEditor:(Profile*)profile;
92
93 - (KeywordEditorController*)controller;
94
95 // Message forwarded by KeywordEditorModelObserver.
96 - (void)modelChanged;
97
98 - (IBAction)addKeyword:(id)sender;
99 - (IBAction)deleteKeyword:(id)sender;
100 - (IBAction)makeDefault:(id)sender;
101
102 @end
103
104 @interface KeywordEditorCocoaController (TestingAPI)
105
106 // Instances of this class are managed, use +showKeywordEditor:.
107 - (id)initWithProfile:(Profile*)profile;
108
109 // Returns a reference to the shared instance for the given profile,
110 // or nil if there is none.
111 + (KeywordEditorCocoaController*)sharedInstanceForProfile:(Profile*)profile;
112
113 // Converts a row index in our table view (which has group header rows) into
114 // one in the |controller_|'s model, which does not have them.
115 - (int)indexInModelForRow:(NSUInteger)row;
116
117 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698