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_FIRST_RUN_SEARCH_ENGINE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FIRST_RUN_SEARCH_ENGINE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_FIRST_RUN_SEARCH_ENGINE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FIRST_RUN_SEARCH_ENGINE_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 public: | 80 public: |
81 // |profile| allows us to get the set of imported search engines. | 81 // |profile| allows us to get the set of imported search engines. |
82 // |randomize| is true if logos are to be displayed in random order. | 82 // |randomize| is true if logos are to be displayed in random order. |
83 FirstRunSearchEngineView(Profile* profile, bool randomize); | 83 FirstRunSearchEngineView(Profile* profile, bool randomize); |
84 | 84 |
85 virtual ~FirstRunSearchEngineView(); | 85 virtual ~FirstRunSearchEngineView(); |
86 | 86 |
87 // Overridden from views::WidgetDelegateView: | 87 // Overridden from views::WidgetDelegateView: |
88 virtual string16 GetWindowTitle() const OVERRIDE; | 88 virtual string16 GetWindowTitle() const OVERRIDE; |
89 virtual views::View* GetContentsView() OVERRIDE { return this; } | 89 virtual views::View* GetContentsView() OVERRIDE { return this; } |
| 90 virtual void WindowClosing() OVERRIDE; |
90 | 91 |
91 // Overridden from views::ButtonListener: | 92 // Overridden from views::ButtonListener: |
92 virtual void ButtonPressed(views::Button* sender, | 93 virtual void ButtonPressed(views::Button* sender, |
93 const views::Event& event) OVERRIDE; | 94 const views::Event& event) OVERRIDE; |
94 | 95 |
95 // Overridden from views::View: | 96 // Overridden from views::View: |
96 virtual gfx::Size GetPreferredSize() OVERRIDE; | 97 virtual gfx::Size GetPreferredSize() OVERRIDE; |
97 virtual void Layout() OVERRIDE; | 98 virtual void Layout() OVERRIDE; |
98 virtual void ViewHierarchyChanged(bool is_add, | 99 virtual void ViewHierarchyChanged(bool is_add, |
99 View* parent, | 100 View* parent, |
100 View* child) OVERRIDE; | 101 View* child) OVERRIDE; |
101 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 102 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
102 | 103 |
103 // Override from views::View so we can draw the gray background at dialog top. | 104 // Override from views::View so we can draw the gray background at dialog top. |
104 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 105 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
105 | 106 |
106 // Overridden from TemplateURLServiceObserver. When the search engines have | 107 // Overridden from TemplateURLServiceObserver. When the search engines have |
107 // loaded from the profile, we can populate the logos in the dialog box | 108 // loaded from the profile, we can populate the logos in the dialog box |
108 // to present to the user. | 109 // to present to the user. |
109 virtual void OnTemplateURLServiceChanged() OVERRIDE; | 110 virtual void OnTemplateURLServiceChanged() OVERRIDE; |
110 | 111 |
| 112 #if defined(UNIT_TEST) |
| 113 void set_quit_on_closing(bool quit_on_closing) { |
| 114 quit_on_closing_ = quit_on_closing; |
| 115 } |
| 116 #endif |
| 117 |
111 private: | 118 private: |
112 // Once the TemplateURLService has loaded and we're in a View hierarchy, it's | 119 // Once the TemplateURLService has loaded and we're in a View hierarchy, it's |
113 // OK to add the search engines from the TemplateURLService. | 120 // OK to add the search engines from the TemplateURLService. |
114 void AddSearchEnginesIfPossible(); | 121 void AddSearchEnginesIfPossible(); |
115 | 122 |
| 123 // Sets the default search engine to the one represented by |choice|. |
| 124 void ChooseSearchEngine(SearchEngineChoice* choice); |
| 125 |
116 // One for each search engine choice offered, either three or four. | 126 // One for each search engine choice offered, either three or four. |
117 std::vector<SearchEngineChoice*> search_engine_choices_; | 127 std::vector<SearchEngineChoice*> search_engine_choices_; |
118 | 128 |
119 // If logos are to be displayed in random order. Used for UX testing. | 129 // If logos are to be displayed in random order. Used for UX testing. |
120 bool randomize_; | 130 bool randomize_; |
121 | 131 |
122 // Services associated with the current profile. | 132 // Services associated with the current profile. |
123 TemplateURLService* template_url_service_; | 133 TemplateURLService* template_url_service_; |
124 ThemeService* theme_service_; | 134 ThemeService* theme_service_; |
125 | 135 |
126 bool text_direction_is_rtl_; | 136 bool text_direction_is_rtl_; |
127 | 137 |
128 bool template_url_service_loaded_; | |
129 bool added_to_view_hierarchy_; | 138 bool added_to_view_hierarchy_; |
130 | 139 |
131 // Image of browser search box with grey background and bubble arrow. | 140 // Image of browser search box with grey background and bubble arrow. |
132 views::ImageView* background_image_; | 141 views::ImageView* background_image_; |
133 | 142 |
134 // UI elements: | 143 // UI elements: |
135 views::Label* title_label_; | 144 views::Label* title_label_; |
136 views::Label* text_label_; | 145 views::Label* text_label_; |
137 | 146 |
| 147 // True when the user has chosen a particular search engine. Defaults to |
| 148 // false. When the user closes the window without choosing a search engine, |
| 149 // the engine specified by |fallback_choice_| is chosen. |
| 150 bool user_chosen_engine_; |
| 151 |
| 152 // The engine to choose when the user closes the window without explicitly |
| 153 // making a selection. Because of randomization functionality, we cannot |
| 154 // reliably deduce this from slot order, so this value is saved prior to |
| 155 // randomization. |
| 156 SearchEngineChoice* fallback_choice_; |
| 157 |
| 158 // Defaults to true. Indicates that the current message loop should be quit |
| 159 // when the window is closed. This is false in tests when this dialog does not |
| 160 // spin its own message loop. |
| 161 bool quit_on_closing_; |
| 162 |
138 DISALLOW_COPY_AND_ASSIGN(FirstRunSearchEngineView); | 163 DISALLOW_COPY_AND_ASSIGN(FirstRunSearchEngineView); |
139 }; | 164 }; |
140 | 165 |
141 #endif // CHROME_BROWSER_UI_VIEWS_FIRST_RUN_SEARCH_ENGINE_VIEW_H_ | 166 #endif // CHROME_BROWSER_UI_VIEWS_FIRST_RUN_SEARCH_ENGINE_VIEW_H_ |
OLD | NEW |