Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/public/browser/context_factory.h" | 13 #include "content/public/browser/context_factory.h" |
| 14 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "content/shell/browser/shell_platform_data_aura.h" | 16 #include "content/shell/browser/shell_platform_data_aura.h" |
| 17 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/base/clipboard/clipboard.h" | 20 #include "ui/base/clipboard/clipboard.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 23 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
| 24 #include "ui/views/background.h" | 24 #include "ui/views/background.h" |
| 25 #include "ui/views/controls/button/label_button.h" | 25 #include "ui/views/controls/button/md_text_button.h" |
| 26 #include "ui/views/controls/textfield/textfield.h" | 26 #include "ui/views/controls/textfield/textfield.h" |
| 27 #include "ui/views/controls/textfield/textfield_controller.h" | 27 #include "ui/views/controls/textfield/textfield_controller.h" |
| 28 #include "ui/views/controls/webview/webview.h" | 28 #include "ui/views/controls/webview/webview.h" |
| 29 #include "ui/views/layout/fill_layout.h" | 29 #include "ui/views/layout/fill_layout.h" |
| 30 #include "ui/views/layout/grid_layout.h" | 30 #include "ui/views/layout/grid_layout.h" |
| 31 #include "ui/views/test/desktop_test_views_delegate.h" | 31 #include "ui/views/test/desktop_test_views_delegate.h" |
| 32 #include "ui/views/view.h" | 32 #include "ui/views/view.h" |
| 33 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 34 #include "ui/views/widget/widget_delegate.h" | 34 #include "ui/views/widget/widget_delegate.h" |
| 35 | 35 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 | 124 |
| 125 // Add toolbar buttons and URL text field | 125 // Add toolbar buttons and URL text field |
| 126 { | 126 { |
| 127 layout->StartRow(0, 0); | 127 layout->StartRow(0, 0); |
| 128 views::GridLayout* toolbar_layout = new views::GridLayout(toolbar_view_); | 128 views::GridLayout* toolbar_layout = new views::GridLayout(toolbar_view_); |
| 129 toolbar_view_->SetLayoutManager(toolbar_layout); | 129 toolbar_view_->SetLayoutManager(toolbar_layout); |
| 130 | 130 |
| 131 views::ColumnSet* toolbar_column_set = | 131 views::ColumnSet* toolbar_column_set = |
| 132 toolbar_layout->AddColumnSet(0); | 132 toolbar_layout->AddColumnSet(0); |
| 133 // Back button | 133 // Back button |
| 134 back_button_ = new views::LabelButton(this, base::ASCIIToUTF16("Back")); | 134 back_button_ = |
| 135 back_button_->SetStyle(views::Button::STYLE_BUTTON); | 135 views::MdTextButton::CreateMdButton(this, base::ASCIIToUTF16("Back")); |
|
Evan Stade
2016/09/01 00:55:35
I'm not sure how many times you need to use a view
James Cook
2016/09/01 02:35:58
This seems fine. The wrapping here isn't too bad.
| |
| 136 gfx::Size back_button_size = back_button_->GetPreferredSize(); | 136 gfx::Size back_button_size = back_button_->GetPreferredSize(); |
| 137 toolbar_column_set->AddColumn(views::GridLayout::CENTER, | 137 toolbar_column_set->AddColumn(views::GridLayout::CENTER, |
| 138 views::GridLayout::CENTER, 0, | 138 views::GridLayout::CENTER, 0, |
| 139 views::GridLayout::FIXED, | 139 views::GridLayout::FIXED, |
| 140 back_button_size.width(), | 140 back_button_size.width(), |
| 141 back_button_size.width() / 2); | 141 back_button_size.width() / 2); |
| 142 // Forward button | 142 // Forward button |
| 143 forward_button_ = | 143 forward_button_ = views::MdTextButton::CreateMdButton( |
| 144 new views::LabelButton(this, base::ASCIIToUTF16("Forward")); | 144 this, base::ASCIIToUTF16("Forward")); |
| 145 forward_button_->SetStyle(views::Button::STYLE_BUTTON); | |
| 146 gfx::Size forward_button_size = forward_button_->GetPreferredSize(); | 145 gfx::Size forward_button_size = forward_button_->GetPreferredSize(); |
| 147 toolbar_column_set->AddColumn(views::GridLayout::CENTER, | 146 toolbar_column_set->AddColumn(views::GridLayout::CENTER, |
| 148 views::GridLayout::CENTER, 0, | 147 views::GridLayout::CENTER, 0, |
| 149 views::GridLayout::FIXED, | 148 views::GridLayout::FIXED, |
| 150 forward_button_size.width(), | 149 forward_button_size.width(), |
| 151 forward_button_size.width() / 2); | 150 forward_button_size.width() / 2); |
| 152 // Refresh button | 151 // Refresh button |
| 153 refresh_button_ = | 152 refresh_button_ = views::MdTextButton::CreateMdButton( |
| 154 new views::LabelButton(this, base::ASCIIToUTF16("Refresh")); | 153 this, base::ASCIIToUTF16("Refresh")); |
| 155 refresh_button_->SetStyle(views::Button::STYLE_BUTTON); | |
| 156 gfx::Size refresh_button_size = refresh_button_->GetPreferredSize(); | 154 gfx::Size refresh_button_size = refresh_button_->GetPreferredSize(); |
| 157 toolbar_column_set->AddColumn(views::GridLayout::CENTER, | 155 toolbar_column_set->AddColumn(views::GridLayout::CENTER, |
| 158 views::GridLayout::CENTER, 0, | 156 views::GridLayout::CENTER, 0, |
| 159 views::GridLayout::FIXED, | 157 views::GridLayout::FIXED, |
| 160 refresh_button_size.width(), | 158 refresh_button_size.width(), |
| 161 refresh_button_size.width() / 2); | 159 refresh_button_size.width() / 2); |
| 162 // Stop button | 160 // Stop button |
| 163 stop_button_ = new views::LabelButton(this, base::ASCIIToUTF16("Stop")); | 161 stop_button_ = |
| 164 stop_button_->SetStyle(views::Button::STYLE_BUTTON); | 162 views::MdTextButton::CreateMdButton(this, base::ASCIIToUTF16("Stop")); |
| 165 gfx::Size stop_button_size = stop_button_->GetPreferredSize(); | 163 gfx::Size stop_button_size = stop_button_->GetPreferredSize(); |
| 166 toolbar_column_set->AddColumn(views::GridLayout::CENTER, | 164 toolbar_column_set->AddColumn(views::GridLayout::CENTER, |
| 167 views::GridLayout::CENTER, 0, | 165 views::GridLayout::CENTER, 0, |
| 168 views::GridLayout::FIXED, | 166 views::GridLayout::FIXED, |
| 169 stop_button_size.width(), | 167 stop_button_size.width(), |
| 170 stop_button_size.width() / 2); | 168 stop_button_size.width() / 2); |
| 171 toolbar_column_set->AddPaddingColumn(0, 2); | 169 toolbar_column_set->AddPaddingColumn(0, 2); |
| 172 // URL entry | 170 // URL entry |
| 173 url_entry_ = new views::Textfield(); | 171 url_entry_ = new views::Textfield(); |
| 174 url_entry_->set_controller(this); | 172 url_entry_->set_controller(this); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 285 |
| 288 private: | 286 private: |
| 289 // Hold a reference of Shell for deleting it when the window is closing | 287 // Hold a reference of Shell for deleting it when the window is closing |
| 290 Shell* shell_; | 288 Shell* shell_; |
| 291 | 289 |
| 292 // Window title | 290 // Window title |
| 293 base::string16 title_; | 291 base::string16 title_; |
| 294 | 292 |
| 295 // Toolbar view contains forward/backward/reload button and URL entry | 293 // Toolbar view contains forward/backward/reload button and URL entry |
| 296 View* toolbar_view_; | 294 View* toolbar_view_; |
| 297 views::LabelButton* back_button_; | 295 views::CustomButton* back_button_; |
| 298 views::LabelButton* forward_button_; | 296 views::CustomButton* forward_button_; |
| 299 views::LabelButton* refresh_button_; | 297 views::CustomButton* refresh_button_; |
| 300 views::LabelButton* stop_button_; | 298 views::CustomButton* stop_button_; |
| 301 views::Textfield* url_entry_; | 299 views::Textfield* url_entry_; |
| 302 | 300 |
| 303 // Contents view contains the web contents view | 301 // Contents view contains the web contents view |
| 304 View* contents_view_; | 302 View* contents_view_; |
| 305 views::WebView* web_view_; | 303 views::WebView* web_view_; |
| 306 | 304 |
| 307 DISALLOW_COPY_AND_ASSIGN(ShellWindowDelegateView); | 305 DISALLOW_COPY_AND_ASSIGN(ShellWindowDelegateView); |
| 308 }; | 306 }; |
| 309 | 307 |
| 310 } // namespace | 308 } // namespace |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 void Shell::PlatformSetTitle(const base::string16& title) { | 442 void Shell::PlatformSetTitle(const base::string16& title) { |
| 445 if (headless_) | 443 if (headless_) |
| 446 return; | 444 return; |
| 447 ShellWindowDelegateView* delegate_view = | 445 ShellWindowDelegateView* delegate_view = |
| 448 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 446 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
| 449 delegate_view->SetWindowTitle(title); | 447 delegate_view->SetWindowTitle(title); |
| 450 window_widget_->UpdateWindowTitle(); | 448 window_widget_->UpdateWindowTitle(); |
| 451 } | 449 } |
| 452 | 450 |
| 453 } // namespace content | 451 } // namespace content |
| OLD | NEW |