| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "mash/browser/browser.h" | 5 #include "mash/browser/browser.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "components/mus/public/cpp/window.h" | 14 #include "components/mus/public/cpp/window.h" |
| 15 #include "components/mus/public/cpp/window_tree_client.h" | 15 #include "components/mus/public/cpp/window_tree_client.h" |
| 16 #include "mash/browser/debug_view.h" | 16 #include "mash/browser/debug_view.h" |
| 17 #include "mash/public/interfaces/launchable.mojom.h" | 17 #include "mash/public/interfaces/launchable.mojom.h" |
| 18 #include "mojo/public/c/system/main.h" | 18 #include "mojo/public/c/system/main.h" |
| 19 #include "services/navigation/public/cpp/view.h" |
| 19 #include "services/navigation/public/interfaces/view.mojom.h" | 20 #include "services/navigation/public/interfaces/view.mojom.h" |
| 20 #include "services/shell/public/cpp/application_runner.h" | 21 #include "services/shell/public/cpp/application_runner.h" |
| 21 #include "services/shell/public/cpp/connector.h" | 22 #include "services/shell/public/cpp/connector.h" |
| 22 #include "services/shell/public/cpp/shell_client.h" | 23 #include "services/shell/public/cpp/shell_client.h" |
| 23 #include "services/tracing/public/cpp/tracing_impl.h" | 24 #include "services/tracing/public/cpp/tracing_impl.h" |
| 24 #include "ui/aura/mus/mus_util.h" | 25 #include "ui/aura/mus/mus_util.h" |
| 25 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 26 #include "ui/gfx/paint_throbber.h" | 27 #include "ui/gfx/paint_throbber.h" |
| 27 #include "ui/gfx/text_constants.h" | 28 #include "ui/gfx/text_constants.h" |
| 28 #include "ui/native_theme/native_theme.h" | 29 #include "ui/native_theme/native_theme.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 base::TimeTicks start_time_; | 109 base::TimeTicks start_time_; |
| 109 base::Timer timer_; | 110 base::Timer timer_; |
| 110 base::WeakPtrFactory<Throbber> weak_factory_; | 111 base::WeakPtrFactory<Throbber> weak_factory_; |
| 111 | 112 |
| 112 DISALLOW_COPY_AND_ASSIGN(Throbber); | 113 DISALLOW_COPY_AND_ASSIGN(Throbber); |
| 113 }; | 114 }; |
| 114 | 115 |
| 115 class UI : public views::WidgetDelegateView, | 116 class UI : public views::WidgetDelegateView, |
| 116 public views::ButtonListener, | 117 public views::ButtonListener, |
| 117 public views::TextfieldController, | 118 public views::TextfieldController, |
| 118 public navigation::mojom::ViewClient { | 119 public navigation::ViewDelegate { |
| 119 public: | 120 public: |
| 120 enum class Type { WINDOW, POPUP }; | 121 enum class Type { WINDOW, POPUP }; |
| 121 | 122 |
| 122 UI(Browser* browser, | 123 UI(Browser* browser, |
| 123 Type type, | 124 Type type, |
| 124 navigation::mojom::ViewPtr view, | 125 navigation::mojom::ViewPtr view, |
| 125 navigation::mojom::ViewClientRequest request) | 126 navigation::mojom::ViewClientRequest request) |
| 126 : browser_(browser), | 127 : browser_(browser), |
| 127 type_(type), | 128 type_(type), |
| 128 back_button_(new views::LabelButton(this, base::ASCIIToUTF16("Back"))), | 129 back_button_(new views::LabelButton(this, base::ASCIIToUTF16("Back"))), |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 switch (key_event.key_code()) { | 270 switch (key_event.key_code()) { |
| 270 case ui::VKEY_RETURN: { | 271 case ui::VKEY_RETURN: { |
| 271 view_->NavigateTo(GURL(prompt_->text())); | 272 view_->NavigateTo(GURL(prompt_->text())); |
| 272 } break; | 273 } break; |
| 273 default: | 274 default: |
| 274 break; | 275 break; |
| 275 } | 276 } |
| 276 return false; | 277 return false; |
| 277 } | 278 } |
| 278 | 279 |
| 279 // navigation::mojom::ViewClient: | 280 // navigation::ViewDelegate: |
| 280 void LoadingStateChanged(bool is_loading) override { | 281 void LoadingStateChanged(bool is_loading) override { |
| 281 is_loading_ = is_loading; | 282 if (view_.is_loading()) { |
| 282 if (is_loading_) { | |
| 283 reload_button_->SetText(base::ASCIIToUTF16("Stop")); | 283 reload_button_->SetText(base::ASCIIToUTF16("Stop")); |
| 284 throbber_->Start(); | 284 throbber_->Start(); |
| 285 } else { | 285 } else { |
| 286 reload_button_->SetText(base::ASCIIToUTF16("Reload")); | 286 reload_button_->SetText(base::ASCIIToUTF16("Reload")); |
| 287 throbber_->Stop(); | 287 throbber_->Stop(); |
| 288 progress_bar_->SetProgress(0.f); | 288 progress_bar_->SetProgress(0.f); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 void NavigationStateChanged(const GURL& url, | 291 void NavigationStateChanged(const GURL& url, |
| 292 const mojo::String& title, | 292 const mojo::String& title, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 AddWindow(window); | 409 AddWindow(window); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void Browser::Create(shell::Connection* connection, | 412 void Browser::Create(shell::Connection* connection, |
| 413 mojom::LaunchableRequest request) { | 413 mojom::LaunchableRequest request) { |
| 414 bindings_.AddBinding(this, std::move(request)); | 414 bindings_.AddBinding(this, std::move(request)); |
| 415 } | 415 } |
| 416 | 416 |
| 417 } // namespace browser | 417 } // namespace browser |
| 418 } // namespace mash | 418 } // namespace mash |
| OLD | NEW |