| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "views/window/dialog_delegate.h" | 12 #include "views/window/dialog_delegate.h" |
| 13 | 13 |
| 14 class PrefService; | 14 class PrefService; |
| 15 class Profile; |
| 15 class TabContents; | 16 class TabContents; |
| 16 class TemplateURL; | 17 class TemplateURL; |
| 17 class TemplateURLService; | 18 class TemplateURLService; |
| 19 class ThemeService; |
| 18 | 20 |
| 19 namespace gfx { | 21 namespace gfx { |
| 20 class Canvas; | 22 class Canvas; |
| 21 } | 23 } |
| 22 | 24 |
| 23 namespace views { | 25 namespace views { |
| 24 class Button; | 26 class Button; |
| 25 class ImageView; | 27 class ImageView; |
| 26 class Label; | 28 class Label; |
| 27 class View; | 29 class View; |
| 28 } | 30 } |
| 29 | 31 |
| 30 // Responsible for displaying the contents of the default search | 32 // Responsible for displaying the contents of the default search |
| 31 // prompt for when InstallSearchProvider(url, true) is called. | 33 // prompt for when InstallSearchProvider(url, true) is called. |
| 32 class DefaultSearchView | 34 class DefaultSearchView : public views::View, |
| 33 : public views::View, | 35 public views::ButtonListener, |
| 34 public views::ButtonListener, | 36 public views::DialogDelegate { |
| 35 public views::DialogDelegate { | |
| 36 public: | 37 public: |
| 37 // Takes ownership of |proposed_default_turl|. | 38 // Takes ownership of |proposed_default_turl|. |
| 38 static void Show(TabContents* tab_contents, | 39 static void Show(TabContents* tab_contents, |
| 39 TemplateURL* , | 40 TemplateURL* proposed_default_turl, |
| 40 TemplateURLService* template_url_service); | 41 Profile* profile); |
| 41 | 42 |
| 42 virtual ~DefaultSearchView(); | 43 virtual ~DefaultSearchView(); |
| 43 | 44 |
| 44 protected: | 45 protected: |
| 45 // Overridden from views::View: | 46 // Overridden from views::View: |
| 46 // Draws the gray background at the top of the dialog. | 47 // Draws the gray background at the top of the dialog. |
| 47 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 48 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 48 | 49 |
| 49 // Overridden from views::ButtonListener: | 50 // Overridden from views::ButtonListener: |
| 50 virtual void ButtonPressed(views::Button* sender, | 51 virtual void ButtonPressed(views::Button* sender, |
| 51 const views::Event& event) OVERRIDE; | 52 const views::Event& event) OVERRIDE; |
| 52 | 53 |
| 53 // views::DialogDelegate: | 54 // views::DialogDelegate: |
| 54 // TODO(beng): Figure out why adding OVERRIDE to these methods annoys Clang. | 55 // TODO(beng): Figure out why adding OVERRIDE to these methods annoys Clang. |
| 55 virtual string16 GetWindowTitle() const OVERRIDE; | 56 virtual string16 GetWindowTitle() const OVERRIDE; |
| 56 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 57 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
| 57 virtual views::View* GetContentsView() OVERRIDE; | 58 virtual views::View* GetContentsView() OVERRIDE; |
| 58 virtual int GetDialogButtons() const OVERRIDE; | 59 virtual int GetDialogButtons() const OVERRIDE; |
| 59 virtual bool Accept() OVERRIDE; | 60 virtual bool Accept() OVERRIDE; |
| 60 virtual views::Widget* GetWidget() OVERRIDE; | 61 virtual views::Widget* GetWidget() OVERRIDE; |
| 61 virtual const views::Widget* GetWidget() const OVERRIDE; | 62 virtual const views::Widget* GetWidget() const OVERRIDE; |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 // Takes ownership of |proposed_default_turl|. | 65 // Takes ownership of |proposed_default_turl|. |
| 65 DefaultSearchView(TabContents* tab_contents, | 66 DefaultSearchView(TabContents* tab_contents, |
| 66 TemplateURL* proposed_default_turl, | 67 TemplateURL* proposed_default_turl, |
| 67 TemplateURLService* template_url_service); | 68 TemplateURLService* template_url_service, |
| 69 PrefService* prefs); |
| 68 | 70 |
| 69 // Initializes the labels and controls in the view. | 71 // Initializes the labels and controls in the view. |
| 70 void SetupControls(PrefService* prefs); | 72 void SetupControls(PrefService* prefs); |
| 71 | 73 |
| 72 // Image of browser search box with grey background and bubble arrow. | 74 // Image of browser search box with grey background and bubble arrow. |
| 73 views::ImageView* background_image_; | 75 views::ImageView* background_image_; |
| 74 | 76 |
| 75 // Button for the current default search engine. | 77 // Button for the current default search engine. |
| 76 views::View* default_provider_button_; | 78 views::View* default_provider_button_; |
| 77 | 79 |
| 78 // Button for the newly proposed search engine. | 80 // Button for the newly proposed search engine. |
| 79 views::View* proposed_provider_button_; | 81 views::View* proposed_provider_button_; |
| 80 | 82 |
| 81 // The proposed new default search engine. | 83 // The proposed new default search engine. |
| 82 scoped_ptr<TemplateURL> proposed_turl_; | 84 scoped_ptr<TemplateURL> proposed_turl_; |
| 83 | 85 |
| 84 TemplateURLService* template_url_service_; | 86 TemplateURLService* template_url_service_; |
| 85 | 87 |
| 86 DISALLOW_COPY_AND_ASSIGN(DefaultSearchView); | 88 DISALLOW_COPY_AND_ASSIGN(DefaultSearchView); |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 #endif // CHROME_BROWSER_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_ | 91 #endif // CHROME_BROWSER_UI_VIEWS_DEFAULT_SEARCH_VIEW_H_ |
| OLD | NEW |