| Index: chrome/browser/search_engines/template_url_table_model.h
|
| ===================================================================
|
| --- chrome/browser/search_engines/template_url_table_model.h (revision 19296)
|
| +++ chrome/browser/search_engines/template_url_table_model.h (working copy)
|
| @@ -1,32 +1,16 @@
|
| -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
| +// 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_VIEWS_KEYWORD_EDITOR_VIEW_H_
|
| -#define CHROME_BROWSER_VIEWS_KEYWORD_EDITOR_VIEW_H_
|
| +#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_
|
| +#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_
|
|
|
| -#include <Windows.h>
|
| -#include <map>
|
| -
|
| #include "app/table_model.h"
|
| -#include "chrome/browser/search_engines/edit_search_engine_controller.h"
|
| #include "chrome/browser/search_engines/template_url_model.h"
|
| -#include "views/controls/button/button.h"
|
| -#include "views/controls/table/table_view_observer.h"
|
| -#include "views/view.h"
|
| -#include "views/window/dialog_delegate.h"
|
|
|
| -namespace views {
|
| -class Label;
|
| -class NativeButton;
|
| -}
|
| -
|
| -namespace {
|
| -class BorderView;
|
| -}
|
| -
|
| class ModelEntry;
|
| class SkBitmap;
|
| +class TemplateURL;
|
| class TemplateURLModel;
|
| class TemplateURLTableModel;
|
|
|
| @@ -41,7 +25,8 @@
|
| // the favicon. The entries in the model are sorted such that non-generated
|
| // appear first (grouped together) and are followed by generated keywords.
|
|
|
| -class TemplateURLTableModel : public TableModel {
|
| +class TemplateURLTableModel : public TableModel,
|
| + TemplateURLModelObserver {
|
| public:
|
| explicit TemplateURLTableModel(TemplateURLModel* template_url_model);
|
|
|
| @@ -60,14 +45,16 @@
|
| virtual Groups GetGroups();
|
| virtual int GetGroupID(int row);
|
|
|
| - // Removes the entry at the specified index. This does NOT propagate the
|
| - // change to the backend.
|
| + // Removes the entry at the specified index.
|
| void Remove(int index);
|
|
|
| - // Adds a new entry at the specified index. This does not propagate the
|
| - // change to the backend.
|
| - void Add(int index, const TemplateURL* template_url);
|
| + // Adds a new entry at the specified index.
|
| + void Add(int index, TemplateURL* template_url);
|
|
|
| + // Update the entry at the specified index.
|
| + void ModifyTemplateURL(int index, const std::wstring& title,
|
| + const std::wstring& keyword, const std::wstring& url);
|
| +
|
| // Reloads the icon at the specified index.
|
| void ReloadIcon(int index);
|
|
|
| @@ -81,8 +68,12 @@
|
| // Moves the keyword at the specified index to be at the end of the main
|
| // group. Returns the new index. This does nothing if the entry is already
|
| // in the main group.
|
| - void MoveToMainGroup(int index);
|
| + int MoveToMainGroup(int index);
|
|
|
| + // Make the TemplateURL at |index| the default. Returns the new index, or -1
|
| + // if the index is invalid or it is already the default.
|
| + int MakeDefaultTemplateURL(int index);
|
| +
|
| // If there is an observer, it's notified the selected row has changed.
|
| void NotifyChanged(int index);
|
|
|
| @@ -97,6 +88,9 @@
|
| // Notification that a model entry has fetched its icon.
|
| void FavIconAvailable(ModelEntry* entry);
|
|
|
| + // TemplateURLModelObserver notification.
|
| + virtual void OnTemplateURLModelChanged();
|
| +
|
| TableModelObserver* observer_;
|
|
|
| // The entries.
|
| @@ -112,103 +106,5 @@
|
| DISALLOW_EVIL_CONSTRUCTORS(TemplateURLTableModel);
|
| };
|
|
|
| -// KeywordEditorView ----------------------------------------------------------
|
|
|
| -// KeywordEditorView allows the user to edit keywords.
|
| -
|
| -class KeywordEditorView : public views::View,
|
| - public views::TableViewObserver,
|
| - public views::ButtonListener,
|
| - public TemplateURLModelObserver,
|
| - public views::DialogDelegate,
|
| - public EditSearchEngineControllerDelegate {
|
| - friend class KeywordEditorViewTest;
|
| - FRIEND_TEST(KeywordEditorViewTest, MakeDefault);
|
| - public:
|
| - // Shows the KeywordEditorView for the specified profile. If there is a
|
| - // KeywordEditorView already open, it is closed and a new one is shown.
|
| - static void Show(Profile* profile);
|
| -
|
| - explicit KeywordEditorView(Profile* profile);
|
| - virtual ~KeywordEditorView();
|
| -
|
| - // Overridden from EditSearchEngineControllerDelegate.
|
| - // Calls AddTemplateURL or ModifyTemplateURL as appropriate.
|
| - virtual void OnEditedKeyword(const TemplateURL* template_url,
|
| - const std::wstring& title,
|
| - const std::wstring& keyword,
|
| - const std::wstring& url);
|
| -
|
| - // Invoked when the user succesfully fills out the add keyword dialog.
|
| - // Propagates the change to the TemplateURLModel and updates the table model.
|
| - void AddTemplateURL(const std::wstring& title,
|
| - const std::wstring& keyword,
|
| - const std::wstring& url);
|
| -
|
| - // Invoked when the user modifies a TemplateURL. Updates the TemplateURLModel
|
| - // and table model appropriately.
|
| - void ModifyTemplateURL(const TemplateURL* template_url,
|
| - const std::wstring& title,
|
| - const std::wstring& keyword,
|
| - const std::wstring& url);
|
| -
|
| - // Overriden to invoke Layout.
|
| - virtual gfx::Size GetPreferredSize();
|
| -
|
| - // DialogDelegate methods:
|
| - virtual bool CanResize() const;
|
| - virtual std::wstring GetWindowTitle() const;
|
| - virtual int GetDialogButtons() const;
|
| - virtual bool Accept();
|
| - virtual bool Cancel();
|
| - virtual views::View* GetContentsView();
|
| -
|
| - // Returns the TemplateURLModel we're using.
|
| - TemplateURLModel* template_url_model() const { return url_model_; }
|
| -
|
| - private:
|
| - void Init();
|
| -
|
| - // Creates the layout and adds the views to it.
|
| - void InitLayoutManager();
|
| -
|
| - // TableViewObserver method. Updates buttons contingent on the selection.
|
| - virtual void OnSelectionChanged();
|
| - // Edits the selected item.
|
| - virtual void OnDoubleClick();
|
| -
|
| - // Button::ButtonListener method.
|
| - virtual void ButtonPressed(views::Button* sender);
|
| -
|
| - // TemplateURLModelObserver notification.
|
| - virtual void OnTemplateURLModelChanged();
|
| -
|
| - // Toggles whether the selected keyword is the default search provider.
|
| - void MakeDefaultSearchProvider();
|
| -
|
| - // Make the TemplateURL at the specified index (into the TableModel) the
|
| - // default search provider.
|
| - void MakeDefaultSearchProvider(int index);
|
| -
|
| - // The profile.
|
| - Profile* profile_;
|
| -
|
| - // Model containing TemplateURLs. We listen for changes on this and propagate
|
| - // them to the table model.
|
| - TemplateURLModel* url_model_;
|
| -
|
| - // Model for the TableView.
|
| - scoped_ptr<TemplateURLTableModel> table_model_;
|
| -
|
| - // All the views are added as children, so that we don't need to delete
|
| - // them directly.
|
| - views::TableView* table_view_;
|
| - views::NativeButton* add_button_;
|
| - views::NativeButton* edit_button_;
|
| - views::NativeButton* remove_button_;
|
| - views::NativeButton* make_default_button_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(KeywordEditorView);
|
| -};
|
| -
|
| -#endif // CHROME_BROWSER_VIEWS_KEYWORD_EDITOR_VIEW_H_
|
| +#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_
|
|
|