OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mandoline/ui/desktop_ui/browser_window.h" | 5 #include "mandoline/ui/desktop_ui/browser_window.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
120 // BrowserWindow, mojo::ViewTreeDelegate implementation: | 120 // BrowserWindow, mojo::ViewTreeDelegate implementation: |
121 | 121 |
122 void BrowserWindow::OnEmbed(mojo::View* root) { | 122 void BrowserWindow::OnEmbed(mojo::View* root) { |
123 // BrowserWindow does not support being embedded more than once. | 123 // BrowserWindow does not support being embedded more than once. |
124 CHECK(!root_); | 124 CHECK(!root_); |
125 | 125 |
126 // Record when the browser window was displayed, used for performance testing. | 126 // Record when the browser window was displayed, used for performance testing. |
127 const base::Time display_time = base::Time::Now(); | 127 const base::Time display_time = base::Time::Now(); |
128 | 128 |
129 // Make it so we get OnWillEmbed() for any Embed()s done by other apps we | |
130 // Embed(). | |
131 root->connection()->SetEmbedRoot(); | |
132 | |
133 root_ = root; | 129 root_ = root; |
134 | 130 |
135 host_->SetTitle("Mandoline"); | 131 host_->SetTitle("Mandoline"); |
136 | 132 |
137 content_ = root_->connection()->CreateView(); | 133 content_ = root_->connection()->CreateView(); |
138 Init(root_); | 134 Init(root_); |
139 | 135 |
140 host_->SetSize(mojo::Size::From(gfx::Size(1280, 800))); | 136 host_->SetSize(mojo::Size::From(gfx::Size(1280, 800))); |
141 | 137 |
142 root_->AddChild(content_); | 138 root_->AddChild(content_); |
143 content_->SetVisible(true); | 139 content_->SetVisible(true); |
144 | 140 |
| 141 content_->SetAccessPolicy(mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT); |
| 142 |
145 web_view_.Init(app_, content_); | 143 web_view_.Init(app_, content_); |
146 | 144 |
147 host_->AddAccelerator(BrowserCommand_Close, mojo::KEYBOARD_CODE_W, | 145 host_->AddAccelerator(BrowserCommand_Close, mojo::KEYBOARD_CODE_W, |
148 mojo::EVENT_FLAGS_CONTROL_DOWN); | 146 mojo::EVENT_FLAGS_CONTROL_DOWN); |
149 host_->AddAccelerator(BrowserCommand_FocusOmnibox, mojo::KEYBOARD_CODE_L, | 147 host_->AddAccelerator(BrowserCommand_FocusOmnibox, mojo::KEYBOARD_CODE_L, |
150 mojo::EVENT_FLAGS_CONTROL_DOWN); | 148 mojo::EVENT_FLAGS_CONTROL_DOWN); |
151 host_->AddAccelerator(BrowserCommand_NewWindow, mojo::KEYBOARD_CODE_N, | 149 host_->AddAccelerator(BrowserCommand_NewWindow, mojo::KEYBOARD_CODE_N, |
152 mojo::EVENT_FLAGS_CONTROL_DOWN); | 150 mojo::EVENT_FLAGS_CONTROL_DOWN); |
153 | 151 |
154 // Now that we're ready, load the default url. | 152 // Now that we're ready, load the default url. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 omnibox_view_->Embed(view_tree_client.Pass()); | 356 omnibox_view_->Embed(view_tree_client.Pass()); |
359 | 357 |
360 // TODO(beng): This should be handled sufficiently by | 358 // TODO(beng): This should be handled sufficiently by |
361 // OmniboxImpl::ShowWindow() but unfortunately view manager policy | 359 // OmniboxImpl::ShowWindow() but unfortunately view manager policy |
362 // currently prevents the embedded app from changing window z for | 360 // currently prevents the embedded app from changing window z for |
363 // its own window. | 361 // its own window. |
364 omnibox_view_->MoveToFront(); | 362 omnibox_view_->MoveToFront(); |
365 } | 363 } |
366 | 364 |
367 } // namespace mandoline | 365 } // namespace mandoline |
OLD | NEW |