Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: mash/browser/browser.cc

Issue 2046723002: Add navigation client lib for convenience (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@target
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | services/navigation/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | services/navigation/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698