• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_
7 #pragma once
8 
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/string16.h"
12 #include "content/browser/tab_contents/constrained_window.h"
13 #include "views/window/dialog_delegate.h"
14 
15 #if defined(TOOLKIT_USES_GTK)
16 #include "chrome/browser/ui/gtk/constrained_window_gtk.h"
17 #endif
18 
19 class PrefService;
20 class TabContents;
21 class TemplateURL;
22 class TemplateURLModel;
23 
24 namespace gfx {
25 class Canvas;
26 }
27 
28 namespace views {
29 class Button;
30 class ImageView;
31 class Label;
32 class View;
33 }
34 
35 // Responsible for displaying the contents of the default search
36 // prompt for when InstallSearchProvider(url, true) is called.
37 class DefaultSearchView
38     : public views::View,
39       public views::ButtonListener,
40       public ConstrainedDialogDelegate {
41  public:
42   // Takes ownership of |proposed_default_turl|.
43   static void Show(TabContents* tab_contents,
44                    TemplateURL* ,
45                    TemplateURLModel* template_url_model);
46 
47   virtual ~DefaultSearchView();
48 
49  protected:
50   // Overridden from views::View:
51   // Draws the gray background at the top of the dialog.
52   virtual void OnPaint(gfx::Canvas* canvas);
53 
54   // Overridden from views::ButtonListener:
55   virtual void ButtonPressed(views::Button* sender, const views::Event& event);
56 
57   // ConstrainedDialogDelegate:
58   virtual std::wstring GetWindowTitle() const;
59   virtual views::View* GetInitiallyFocusedView();
60   virtual views::View* GetContentsView();
61   virtual int GetDialogButtons() const;
62   virtual bool Accept();
63 
64  private:
65   // Takes ownership of |proposed_default_turl|.
66   DefaultSearchView(TabContents* tab_contents,
67                     TemplateURL* proposed_default_turl,
68                     TemplateURLModel* template_url_model);
69 
70   // Initializes the labels and controls in the view.
71   void SetupControls(PrefService* prefs);
72 
73   // Image of browser search box with grey background and bubble arrow.
74   views::ImageView* background_image_;
75 
76   // Button for the current default search engine.
77   views::View* default_provider_button_;
78 
79   // Button for the newly proposed search engine.
80   views::View* proposed_provider_button_;
81 
82   // The proposed new default search engine.
83   scoped_ptr<TemplateURL> proposed_turl_;
84 
85   TemplateURLModel* template_url_model_;
86 
87   DISALLOW_COPY_AND_ASSIGN(DefaultSearchView);
88 };
89 
90 #endif  // CHROME_BROWSER_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_
91