Chromium Code Reviews| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "mojo/examples/window_manager/window_manager.mojom.h" | 8 #include "mojo/examples/window_manager/window_manager.mojom.h" |
| 9 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
| 10 #include "mojo/public/cpp/application/application_delegate.h" | 10 #include "mojo/public/cpp/application/application_delegate.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 MOJO_OVERRIDE { | 168 MOJO_OVERRIDE { |
| 169 view_manager::ViewManager::ConfigureIncomingConnection(connection, this); | 169 view_manager::ViewManager::ConfigureIncomingConnection(connection, this); |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 void CreateWidget(view_manager::Node* node) { | 173 void CreateWidget(view_manager::Node* node) { |
| 174 views::Textfield* textfield = new views::Textfield; | 174 views::Textfield* textfield = new views::Textfield; |
| 175 textfield->set_controller(this); | 175 textfield->set_controller(this); |
| 176 | 176 |
| 177 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; | 177 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; |
| 178 widget_delegate->GetContentsView()->set_background( | 178 contents_view_ = widget_delegate->GetContentsView(); |
| 179 contents_view_->set_background( | |
| 179 views::Background::CreateSolidBackground(SK_ColorBLUE)); | 180 views::Background::CreateSolidBackground(SK_ColorBLUE)); |
| 180 widget_delegate->GetContentsView()->AddChildView(textfield); | 181 contents_view_->AddChildView(textfield); |
| 181 widget_delegate->GetContentsView()->SetLayoutManager( | 182 contents_view_->SetLayoutManager(new BrowserLayoutManager); |
| 182 new BrowserLayoutManager); | |
| 183 | 183 |
| 184 widget_ = new views::Widget; | 184 widget_ = new views::Widget; |
| 185 views::Widget::InitParams params( | 185 views::Widget::InitParams params( |
| 186 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 186 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 187 params.native_widget = new NativeWidgetViewManager(widget_, node); | 187 params.native_widget = new NativeWidgetViewManager(widget_, node); |
| 188 params.delegate = widget_delegate; | 188 params.delegate = widget_delegate; |
| 189 params.bounds = gfx::Rect(node->bounds().width(), node->bounds().height()); | 189 params.bounds = gfx::Rect(node->bounds().width(), node->bounds().height()); |
| 190 widget_->Init(params); | 190 widget_->Init(params); |
| 191 // KeyboardManager handles deleting itself when the widget is destroyed. | 191 // KeyboardManager handles deleting itself when the widget is destroyed. |
| 192 new KeyboardManager(widget_, window_manager_.get(), node); | 192 new KeyboardManager(widget_, window_manager_.get(), node); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 virtual void OnNodeFocusChanged(view_manager::Node* gained_focus, | 226 virtual void OnNodeFocusChanged(view_manager::Node* gained_focus, |
| 227 view_manager::Node* lost_focus) OVERRIDE { | 227 view_manager::Node* lost_focus) OVERRIDE { |
| 228 aura::client::FocusClient* focus_client = | 228 aura::client::FocusClient* focus_client = |
| 229 aura::client::GetFocusClient(widget_->GetNativeView()); | 229 aura::client::GetFocusClient(widget_->GetNativeView()); |
| 230 if (lost_focus == root_) | 230 if (lost_focus == root_) |
| 231 focus_client->FocusWindow(NULL); | 231 focus_client->FocusWindow(NULL); |
| 232 else if (gained_focus == root_) | 232 else if (gained_focus == root_) |
| 233 focus_client->FocusWindow(widget_->GetNativeView()); | 233 focus_client->FocusWindow(widget_->GetNativeView()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 virtual void OnNodeBoundsChanged(view_manager::Node* node, | |
| 237 const gfx::Rect& /*old_bounds*/, | |
|
sky
2014/07/11 18:19:46
We generally don't use this style in chrome code.
| |
| 238 const gfx::Rect& /*new_bounds*/) OVERRIDE { | |
| 239 widget_->SetBounds(gfx::Rect(node->bounds().size())); | |
|
sky
2014/07/11 18:19:46
NativeWidgetViewManager is a NodeObserver. It shou
| |
| 240 contents_view_->Layout(); | |
|
sky
2014/07/11 18:19:46
This should happen automatically as a result of se
| |
| 241 } | |
| 242 | |
| 236 scoped_ptr<ViewsInit> views_init_; | 243 scoped_ptr<ViewsInit> views_init_; |
| 237 | 244 |
| 238 view_manager::ViewManager* view_manager_; | 245 view_manager::ViewManager* view_manager_; |
| 239 view_manager::Node* root_; | 246 view_manager::Node* root_; |
| 240 views::Widget* widget_; | 247 views::Widget* widget_; |
| 248 views::View* contents_view_; | |
|
sky
2014/07/11 18:19:46
initialize this to NULL in the member initializer
| |
| 241 navigation::NavigatorHostPtr navigator_host_; | 249 navigation::NavigatorHostPtr navigator_host_; |
| 242 IWindowManagerPtr window_manager_; | 250 IWindowManagerPtr window_manager_; |
| 243 | 251 |
| 244 DISALLOW_COPY_AND_ASSIGN(Browser); | 252 DISALLOW_COPY_AND_ASSIGN(Browser); |
| 245 }; | 253 }; |
| 246 | 254 |
| 247 } // namespace examples | 255 } // namespace examples |
| 248 | 256 |
| 249 // static | 257 // static |
| 250 ApplicationDelegate* ApplicationDelegate::Create() { | 258 ApplicationDelegate* ApplicationDelegate::Create() { |
| 251 return new examples::Browser; | 259 return new examples::Browser; |
| 252 } | 260 } |
| 253 | 261 |
| 254 } // namespace mojo | 262 } // namespace mojo |
| OLD | NEW |