summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/search_engine_list_model.h
blob: 3d1fd5892eb301bff0a564657a3785673c376e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_COCOA_SEARCH_ENGINE_LIST_MODEL_H_
#define CHROME_BROWSER_COCOA_SEARCH_ENGINE_LIST_MODEL_H_

#import <Cocoa/Cocoa.h>

#include "base/scoped_nsobject.h"
#include "base/scoped_ptr.h"

class TemplateURLModel;
class SearchEngineObserver;

// The model for the "default search engine" combobox in preferences. Bridges
// between the cross-platform TemplateURLModel and Cocoa while watching for
// changes to the cross-platform model.

@interface SearchEngineListModel : NSObject {
 @private
  TemplateURLModel* model_;  // weak, owned by Profile
  scoped_ptr<SearchEngineObserver> observer_;  // watches for model changes
  scoped_nsobject<NSArray> engines_;
}

// Initialize with the given template model.
- (id)initWithModel:(TemplateURLModel*)model;

// Returns an array of NSString's corresponding to the user-visible names of the
// search engines.
- (NSArray*)searchEngines;

// The index into |-searchEngines| of the current default search engine. The
// setter changes the back-end preference.
- (NSUInteger)defaultIndex;
- (void)setDefaultIndex:(NSUInteger)index;

@end

// Broadcast when the cross-platform model changes. This can be used to update
// any view state that may rely on the position of items in the list.
extern NSString* const kSearchEngineListModelChangedNotification;

#endif  // CHROME_BROWSER_COCOA_SEARCH_ENGINE_LIST_MODEL_H_