OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/shell/browser/shell.h" | 5 #include "content/shell/browser/shell.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "content/public/browser/web_contents_view.h" | 10 #include "content/public/browser/web_contents_view.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 ShellWindowDelegateView(Shell* shell) | 76 ShellWindowDelegateView(Shell* shell) |
77 : shell_(shell), | 77 : shell_(shell), |
78 toolbar_view_(new View), | 78 toolbar_view_(new View), |
79 contents_view_(new View) { | 79 contents_view_(new View) { |
80 } | 80 } |
81 virtual ~ShellWindowDelegateView() {} | 81 virtual ~ShellWindowDelegateView() {} |
82 | 82 |
83 // Update the state of UI controls | 83 // Update the state of UI controls |
84 void SetAddressBarURL(const GURL& url) { | 84 void SetAddressBarURL(const GURL& url) { |
85 url_entry_->SetText(ASCIIToUTF16(url.spec())); | 85 url_entry_->SetText(base::ASCIIToUTF16(url.spec())); |
86 } | 86 } |
87 void SetWebContents(WebContents* web_contents, const gfx::Size& size) { | 87 void SetWebContents(WebContents* web_contents, const gfx::Size& size) { |
88 contents_view_->SetLayoutManager(new views::FillLayout()); | 88 contents_view_->SetLayoutManager(new views::FillLayout()); |
89 web_view_ = new views::WebView(web_contents->GetBrowserContext()); | 89 web_view_ = new views::WebView(web_contents->GetBrowserContext()); |
90 web_view_->SetWebContents(web_contents); | 90 web_view_->SetWebContents(web_contents); |
91 web_view_->SetPreferredSize(size); | 91 web_view_->SetPreferredSize(size); |
92 web_contents->GetView()->Focus(); | 92 web_contents->GetView()->Focus(); |
93 contents_view_->AddChildView(web_view_); | 93 contents_view_->AddChildView(web_view_); |
94 Layout(); | 94 Layout(); |
95 | 95 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 // Add toolbar buttons and URL text field | 139 // Add toolbar buttons and URL text field |
140 { | 140 { |
141 layout->StartRow(0, 0); | 141 layout->StartRow(0, 0); |
142 views::GridLayout* toolbar_layout = new views::GridLayout(toolbar_view_); | 142 views::GridLayout* toolbar_layout = new views::GridLayout(toolbar_view_); |
143 toolbar_view_->SetLayoutManager(toolbar_layout); | 143 toolbar_view_->SetLayoutManager(toolbar_layout); |
144 | 144 |
145 views::ColumnSet* toolbar_column_set = | 145 views::ColumnSet* toolbar_column_set = |
146 toolbar_layout->AddColumnSet(0); | 146 toolbar_layout->AddColumnSet(0); |
147 // Back button | 147 // Back button |
148 back_button_ = new views::LabelButton(this, ASCIIToUTF16("Back")); | 148 back_button_ = new views::LabelButton(this, base::ASCIIToUTF16("Back")); |
149 back_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 149 back_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
150 gfx::Size back_button_size = back_button_->GetPreferredSize(); | 150 gfx::Size back_button_size = back_button_->GetPreferredSize(); |
151 toolbar_column_set->AddColumn(views::GridLayout::CENTER, | 151 toolbar_column_set->AddColumn(views::GridLayout::CENTER, |
152 views::GridLayout::CENTER, 0, | 152 views::GridLayout::CENTER, 0, |
153 views::GridLayout::FIXED, | 153 views::GridLayout::FIXED, |
154 back_button_size.width(), | 154 back_button_size.width(), |
155 back_button_size.width() / 2); | 155 back_button_size.width() / 2); |
156 // Forward button | 156 // Forward button |
157 forward_button_ = new views::LabelButton(this, ASCIIToUTF16("Forward")); | 157 forward_button_ = |
| 158 new views::LabelButton(this, base::ASCIIToUTF16("Forward")); |
158 forward_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 159 forward_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
159 gfx::Size forward_button_size = forward_button_->GetPreferredSize(); | 160 gfx::Size forward_button_size = forward_button_->GetPreferredSize(); |
160 toolbar_column_set->AddColumn(views::GridLayout::CENTER, | 161 toolbar_column_set->AddColumn(views::GridLayout::CENTER, |
161 views::GridLayout::CENTER, 0, | 162 views::GridLayout::CENTER, 0, |
162 views::GridLayout::FIXED, | 163 views::GridLayout::FIXED, |
163 forward_button_size.width(), | 164 forward_button_size.width(), |
164 forward_button_size.width() / 2); | 165 forward_button_size.width() / 2); |
165 // Refresh button | 166 // Refresh button |
166 refresh_button_ = new views::LabelButton(this, ASCIIToUTF16("Refresh")); | 167 refresh_button_ = |
| 168 new views::LabelButton(this, base::ASCIIToUTF16("Refresh")); |
167 refresh_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 169 refresh_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
168 gfx::Size refresh_button_size = refresh_button_->GetPreferredSize(); | 170 gfx::Size refresh_button_size = refresh_button_->GetPreferredSize(); |
169 toolbar_column_set->AddColumn(views::GridLayout::CENTER, | 171 toolbar_column_set->AddColumn(views::GridLayout::CENTER, |
170 views::GridLayout::CENTER, 0, | 172 views::GridLayout::CENTER, 0, |
171 views::GridLayout::FIXED, | 173 views::GridLayout::FIXED, |
172 refresh_button_size.width(), | 174 refresh_button_size.width(), |
173 refresh_button_size.width() / 2); | 175 refresh_button_size.width() / 2); |
174 // Stop button | 176 // Stop button |
175 stop_button_ = new views::LabelButton(this, ASCIIToUTF16("Stop")); | 177 stop_button_ = new views::LabelButton(this, base::ASCIIToUTF16("Stop")); |
176 stop_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 178 stop_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
177 gfx::Size stop_button_size = stop_button_->GetPreferredSize(); | 179 gfx::Size stop_button_size = stop_button_->GetPreferredSize(); |
178 toolbar_column_set->AddColumn(views::GridLayout::CENTER, | 180 toolbar_column_set->AddColumn(views::GridLayout::CENTER, |
179 views::GridLayout::CENTER, 0, | 181 views::GridLayout::CENTER, 0, |
180 views::GridLayout::FIXED, | 182 views::GridLayout::FIXED, |
181 stop_button_size.width(), | 183 stop_button_size.width(), |
182 stop_button_size.width() / 2); | 184 stop_button_size.width() / 2); |
183 toolbar_column_set->AddPaddingColumn(0, 2); | 185 toolbar_column_set->AddPaddingColumn(0, 2); |
184 // URL entry | 186 // URL entry |
185 url_entry_ = new views::Textfield(); | 187 url_entry_ = new views::Textfield(); |
(...skipping 23 matching lines...) Expand all Loading... |
209 | 211 |
210 layout->AddPaddingRow(0, 5); | 212 layout->AddPaddingRow(0, 5); |
211 } | 213 } |
212 // Overridden from TextfieldController | 214 // Overridden from TextfieldController |
213 virtual void ContentsChanged(views::Textfield* sender, | 215 virtual void ContentsChanged(views::Textfield* sender, |
214 const base::string16& new_contents) OVERRIDE { | 216 const base::string16& new_contents) OVERRIDE { |
215 } | 217 } |
216 virtual bool HandleKeyEvent(views::Textfield* sender, | 218 virtual bool HandleKeyEvent(views::Textfield* sender, |
217 const ui::KeyEvent& key_event) OVERRIDE { | 219 const ui::KeyEvent& key_event) OVERRIDE { |
218 if (sender == url_entry_ && key_event.key_code() == ui::VKEY_RETURN) { | 220 if (sender == url_entry_ && key_event.key_code() == ui::VKEY_RETURN) { |
219 std::string text = UTF16ToUTF8(url_entry_->text()); | 221 std::string text = base::UTF16ToUTF8(url_entry_->text()); |
220 GURL url(text); | 222 GURL url(text); |
221 if (!url.has_scheme()) { | 223 if (!url.has_scheme()) { |
222 url = GURL(std::string("http://") + std::string(text)); | 224 url = GURL(std::string("http://") + std::string(text)); |
223 url_entry_->SetText(ASCIIToUTF16(url.spec())); | 225 url_entry_->SetText(base::ASCIIToUTF16(url.spec())); |
224 } | 226 } |
225 shell_->LoadURL(url); | 227 shell_->LoadURL(url); |
226 return true; | 228 return true; |
227 } | 229 } |
228 return false; | 230 return false; |
229 } | 231 } |
230 | 232 |
231 // Overridden from ButtonListener | 233 // Overridden from ButtonListener |
232 virtual void ButtonPressed(views::Button* sender, | 234 virtual void ButtonPressed(views::Button* sender, |
233 const ui::Event& event) OVERRIDE { | 235 const ui::Event& event) OVERRIDE { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 } | 386 } |
385 | 387 |
386 void Shell::PlatformSetTitle(const base::string16& title) { | 388 void Shell::PlatformSetTitle(const base::string16& title) { |
387 ShellWindowDelegateView* delegate_view = | 389 ShellWindowDelegateView* delegate_view = |
388 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 390 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
389 delegate_view->SetWindowTitle(title); | 391 delegate_view->SetWindowTitle(title); |
390 window_widget_->UpdateWindowTitle(); | 392 window_widget_->UpdateWindowTitle(); |
391 } | 393 } |
392 | 394 |
393 } // namespace content | 395 } // namespace content |
OLD | NEW |