| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/aura/env.h" | 5 #include "ui/aura/env.h" |
| 6 | 6 |
| 7 #include "ui/aura/env_observer.h" | 7 #include "ui/aura/env_observer.h" |
| 8 #include "ui/aura/input_state_lookup.h" | 8 #include "ui/aura/input_state_lookup.h" |
| 9 #include "ui/compositor/compositor.h" | 9 #include "ui/compositor/compositor.h" |
| 10 #include "ui/events/event_target_iterator.h" | 10 #include "ui/events/event_target_iterator.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 input_state_lookup_(InputStateLookup::Create().Pass()) { | 24 input_state_lookup_(InputStateLookup::Create().Pass()) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 Env::~Env() { | 27 Env::~Env() { |
| 28 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); | 28 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); |
| 29 | 29 |
| 30 ui::Compositor::Terminate(); | 30 ui::Compositor::Terminate(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 //static | 33 //static |
| 34 void Env::CreateInstance() { | 34 void Env::CreateInstance(bool create_event_source) { |
| 35 if (!instance_) { | 35 if (!instance_) { |
| 36 instance_ = new Env; | 36 instance_ = new Env; |
| 37 instance_->Init(); | 37 instance_->Init(create_event_source); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 // static | 41 // static |
| 42 Env* Env::GetInstance() { | 42 Env* Env::GetInstance() { |
| 43 DCHECK(instance_) << "Env::CreateInstance must be called before getting " | 43 DCHECK(instance_) << "Env::CreateInstance must be called before getting " |
| 44 "the instance of Env."; | 44 "the instance of Env."; |
| 45 return instance_; | 45 return instance_; |
| 46 } | 46 } |
| 47 | 47 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool Env::IsMouseButtonDown() const { | 62 bool Env::IsMouseButtonDown() const { |
| 63 return input_state_lookup_.get() ? input_state_lookup_->IsMouseButtonDown() : | 63 return input_state_lookup_.get() ? input_state_lookup_->IsMouseButtonDown() : |
| 64 mouse_button_flags_ != 0; | 64 mouse_button_flags_ != 0; |
| 65 } | 65 } |
| 66 | 66 |
| 67 //////////////////////////////////////////////////////////////////////////////// | 67 //////////////////////////////////////////////////////////////////////////////// |
| 68 // Env, private: | 68 // Env, private: |
| 69 | 69 |
| 70 void Env::Init() { | 70 void Env::Init(bool create_event_source) { |
| 71 ui::Compositor::Initialize(); | 71 ui::Compositor::Initialize(); |
| 72 | 72 |
| 73 if (!ui::PlatformEventSource::GetInstance()) | 73 if (create_event_source && !ui::PlatformEventSource::GetInstance()) |
| 74 event_source_ = ui::PlatformEventSource::CreateDefault(); | 74 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void Env::NotifyWindowInitialized(Window* window) { | 77 void Env::NotifyWindowInitialized(Window* window) { |
| 78 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); | 78 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void Env::NotifyHostInitialized(WindowTreeHost* host) { | 81 void Env::NotifyHostInitialized(WindowTreeHost* host) { |
| 82 FOR_EACH_OBSERVER(EnvObserver, observers_, OnHostInitialized(host)); | 82 FOR_EACH_OBSERVER(EnvObserver, observers_, OnHostInitialized(host)); |
| 83 } | 83 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 scoped_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { | 100 scoped_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { |
| 101 return scoped_ptr<ui::EventTargetIterator>(); | 101 return scoped_ptr<ui::EventTargetIterator>(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 ui::EventTargeter* Env::GetEventTargeter() { | 104 ui::EventTargeter* Env::GetEventTargeter() { |
| 105 NOTREACHED(); | 105 NOTREACHED(); |
| 106 return NULL; | 106 return NULL; |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace aura | 109 } // namespace aura |
| OLD | NEW |