OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/application/application_runner_chromium.h" | 5 #include "mojo/application/application_runner_chromium.h" |
6 #include "mojo/public/c/system/main.h" | 6 #include "mojo/public/c/system/main.h" |
7 #include "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_delegate.h" |
8 #include "mojo/public/cpp/application/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
9 #include "mojo/public/cpp/application/connect.h" | 9 #include "mojo/public/cpp/application/connect.h" |
10 #include "mojo/public/cpp/application/service_provider_impl.h" | 10 #include "mojo/public/cpp/application/service_provider_impl.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 root_ = root; | 64 root_ = root; |
65 root_->AddObserver(this); | 65 root_->AddObserver(this); |
66 | 66 |
67 content_ = mojo::View::Create(view_manager_); | 67 content_ = mojo::View::Create(view_manager_); |
68 content_->SetBounds(root_->bounds()); | 68 content_->SetBounds(root_->bounds()); |
69 root_->AddChild(content_); | 69 root_->AddChild(content_); |
70 | 70 |
71 window_manager_app_->InitFocus( | 71 window_manager_app_->InitFocus( |
72 new FocusRules(window_manager_app_.get(), content_)); | 72 new FocusRules(window_manager_app_.get(), content_)); |
| 73 |
| 74 if (!pending_url_.empty()) |
| 75 NavigateToURL(pending_url_); |
73 } | 76 } |
74 | 77 |
75 virtual void OnViewManagerDisconnected( | 78 virtual void OnViewManagerDisconnected( |
76 mojo::ViewManager* view_manager) override { | 79 mojo::ViewManager* view_manager) override { |
77 CHECK(false); // FIXME: This is dead code, why? | 80 CHECK(false); // FIXME: This is dead code, why? |
78 view_manager_ = nullptr; | 81 view_manager_ = nullptr; |
79 root_ = nullptr; | 82 root_ = nullptr; |
80 } | 83 } |
81 | 84 |
82 virtual void OnViewDestroyed(mojo::View* view) override { | 85 virtual void OnViewDestroyed(mojo::View* view) override { |
83 CHECK(false); // FIXME: This is dead code, why? | 86 CHECK(false); // FIXME: This is dead code, why? |
84 view->RemoveObserver(this); | 87 view->RemoveObserver(this); |
85 } | 88 } |
86 | 89 |
87 virtual void OnViewBoundsChanged(mojo::View* view, | 90 virtual void OnViewBoundsChanged(mojo::View* view, |
88 const mojo::Rect& old_bounds, | 91 const mojo::Rect& old_bounds, |
89 const mojo::Rect& new_bounds) override { | 92 const mojo::Rect& new_bounds) override { |
90 content_->SetBounds(new_bounds); | 93 content_->SetBounds(new_bounds); |
91 } | 94 } |
92 | 95 |
93 // Overridden from InterfaceFactory<Debugger> | 96 // Overridden from InterfaceFactory<Debugger> |
94 virtual void Create(mojo::ApplicationConnection* connection, | 97 virtual void Create(mojo::ApplicationConnection* connection, |
95 mojo::InterfaceRequest<Debugger> request) override { | 98 mojo::InterfaceRequest<Debugger> request) override { |
96 mojo::WeakBindToRequest(this, &request); | 99 mojo::WeakBindToRequest(this, &request); |
97 } | 100 } |
98 | 101 |
99 // Overridden from Debugger | 102 // Overridden from Debugger |
100 virtual void NavigateToURL(const mojo::String& url) override { | 103 virtual void NavigateToURL(const mojo::String& url) override { |
101 content_->Embed(url); | 104 // We can get Navigate commands before we've actually been |
| 105 // embedded into the view and content_ created. |
| 106 // Just save the last one. |
| 107 if (content_) |
| 108 content_->Embed(url); |
| 109 else |
| 110 pending_url_ = url; |
102 } | 111 } |
103 | 112 |
104 scoped_ptr<mojo::WindowManagerApp> window_manager_app_; | 113 scoped_ptr<mojo::WindowManagerApp> window_manager_app_; |
105 | 114 |
106 mojo::ViewManager* view_manager_; | 115 mojo::ViewManager* view_manager_; |
107 mojo::View* root_; | 116 mojo::View* root_; |
108 mojo::View* content_; | 117 mojo::View* content_; |
| 118 std::string pending_url_; |
109 | 119 |
110 DISALLOW_COPY_AND_ASSIGN(SkyDebugger); | 120 DISALLOW_COPY_AND_ASSIGN(SkyDebugger); |
111 }; | 121 }; |
112 | 122 |
113 } // namespace sky | 123 } // namespace sky |
114 | 124 |
115 MojoResult MojoMain(MojoHandle shell_handle) { | 125 MojoResult MojoMain(MojoHandle shell_handle) { |
116 mojo::ApplicationRunnerChromium runner(new sky::SkyDebugger); | 126 mojo::ApplicationRunnerChromium runner(new sky::SkyDebugger); |
117 return runner.Run(shell_handle); | 127 return runner.Run(shell_handle); |
118 } | 128 } |
OLD | NEW |