| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/string_tokenizer.h" | 8 #include "base/strings/string_tokenizer.h" |
| 8 #include "mojo/examples/media_viewer/media_viewer.mojom.h" | 9 #include "mojo/examples/media_viewer/media_viewer.mojom.h" |
| 9 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
| 10 #include "mojo/public/cpp/application/application_delegate.h" | 11 #include "mojo/public/cpp/application/application_delegate.h" |
| 11 #include "mojo/services/public/cpp/view_manager/node.h" | 12 #include "mojo/services/public/cpp/view_manager/node.h" |
| 12 #include "mojo/services/public/cpp/view_manager/types.h" | 13 #include "mojo/services/public/cpp/view_manager/types.h" |
| 13 #include "mojo/services/public/cpp/view_manager/view.h" | 14 #include "mojo/services/public/cpp/view_manager/view.h" |
| 14 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 15 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 15 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 16 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| 16 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 17 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 160 |
| 160 // Overridden from view_manager::ViewManagerDelegate: | 161 // Overridden from view_manager::ViewManagerDelegate: |
| 161 virtual void OnRootAdded(view_manager::ViewManager* view_manager, | 162 virtual void OnRootAdded(view_manager::ViewManager* view_manager, |
| 162 view_manager::Node* root) OVERRIDE { | 163 view_manager::Node* root) OVERRIDE { |
| 163 content_view_ = view_manager::View::Create(view_manager); | 164 content_view_ = view_manager::View::Create(view_manager); |
| 164 root->SetActiveView(content_view_); | 165 root->SetActiveView(content_view_); |
| 165 content_view_->SetColor(SK_ColorGRAY); | 166 content_view_->SetColor(SK_ColorGRAY); |
| 166 if (!bitmap_.isNull()) | 167 if (!bitmap_.isNull()) |
| 167 DrawBitmap(); | 168 DrawBitmap(); |
| 168 } | 169 } |
| 170 virtual void OnViewManagerDisconnected( |
| 171 view_manager::ViewManager* view_manager) OVERRIDE { |
| 172 base::MessageLoop::current()->Quit(); |
| 173 } |
| 169 | 174 |
| 170 void DrawBitmap() { | 175 void DrawBitmap() { |
| 171 if (!content_view_) | 176 if (!content_view_) |
| 172 return; | 177 return; |
| 173 | 178 |
| 174 skia::RefPtr<SkCanvas> canvas(skia::AdoptRef(skia::CreatePlatformCanvas( | 179 skia::RefPtr<SkCanvas> canvas(skia::AdoptRef(skia::CreatePlatformCanvas( |
| 175 content_view_->node()->bounds().width(), | 180 content_view_->node()->bounds().width(), |
| 176 content_view_->node()->bounds().height(), | 181 content_view_->node()->bounds().height(), |
| 177 true))); | 182 true))); |
| 178 canvas->drawColor(SK_ColorGRAY); | 183 canvas->drawColor(SK_ColorGRAY); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 209 } | 214 } |
| 210 | 215 |
| 211 } // namespace examples | 216 } // namespace examples |
| 212 | 217 |
| 213 // static | 218 // static |
| 214 ApplicationDelegate* ApplicationDelegate::Create() { | 219 ApplicationDelegate* ApplicationDelegate::Create() { |
| 215 return new examples::PNGViewer; | 220 return new examples::PNGViewer; |
| 216 } | 221 } |
| 217 | 222 |
| 218 } // namespace mojo | 223 } // namespace mojo |
| OLD | NEW |