blob: a1642e4cf56f86080dee19e2286fb136218f61a1 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// 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_SEARCH_ENGINES_KEYWORD_EDITOR_CONTROLLER_H_
#define CHROME_BROWSER_SEARCH_ENGINES_KEYWORD_EDITOR_CONTROLLER_H_
#pragma once
#include <string>
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
class PrefService;
class Profile;
class TemplateURL;
class TemplateURLModel;
class TemplateURLTableModel;
class KeywordEditorController {
public:
explicit KeywordEditorController(Profile* profile);
~KeywordEditorController();
static void RegisterPrefs(PrefService* prefs);
// Invoked when the user succesfully fills out the add keyword dialog.
// Propagates the change to the TemplateURLModel and updates the table model.
// Returns the index of the added URL.
int AddTemplateURL(const string16& title,
const string16& keyword,
const std::string& url);
// Invoked when the user modifies a TemplateURL. Updates the TemplateURLModel
// and table model appropriately.
void ModifyTemplateURL(const TemplateURL* template_url,
const string16& title,
const string16& keyword,
const std::string& url);
// Return true if the given |url| can be edited.
bool CanEdit(const TemplateURL* url) const;
// Return true if the given |url| can be made the default.
bool CanMakeDefault(const TemplateURL* url) const;
// Return true if the given |url| can be removed.
bool CanRemove(const TemplateURL* url) const;
// Remove the TemplateURL at the specified index in the TableModel.
void RemoveTemplateURL(int index);
// Make the TemplateURL at the specified index (into the TableModel) the
// default search provider. Return the new index, or -1 if nothing was done.
int MakeDefaultTemplateURL(int index);
// Return true if the |url_model_| data is loaded.
bool loaded() const;
// Return the TemplateURL corresponding to the |index| in the model.
const TemplateURL* GetTemplateURL(int index) const;
TemplateURLTableModel* table_model() {
return table_model_.get();
}
TemplateURLModel* url_model() const;
private:
// The profile.
Profile* profile_;
// Model for the TableView.
scoped_ptr<TemplateURLTableModel> table_model_;
DISALLOW_COPY_AND_ASSIGN(KeywordEditorController);
};
#endif // CHROME_BROWSER_SEARCH_ENGINES_KEYWORD_EDITOR_CONTROLLER_H_
|