| 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 "athena/content/public/app_registry.h" | 5 #include "athena/content/public/app_registry.h" |
| 6 | 6 |
| 7 #include "athena/content/app_activity_registry.h" | 7 #include "athena/content/app_activity_registry.h" |
| 8 #include "athena/content/public/app_content_control_delegate.h" | |
| 9 #include "base/logging.h" | 8 #include "base/logging.h" |
| 10 | 9 |
| 11 namespace athena { | 10 namespace athena { |
| 12 | 11 |
| 13 class AppRegistryImpl : public AppRegistry { | 12 class AppRegistryImpl : public AppRegistry { |
| 14 public: | 13 public: |
| 15 AppRegistryImpl(); | 14 AppRegistryImpl(); |
| 16 virtual ~AppRegistryImpl(); | 15 virtual ~AppRegistryImpl(); |
| 17 | 16 |
| 18 // AppRegistry: | 17 // AppRegistry: |
| 19 virtual void SetDelegate(AppContentControlDelegate* delegate) OVERRIDE; | |
| 20 virtual AppContentControlDelegate* GetDelegate() OVERRIDE; | |
| 21 virtual AppActivityRegistry* GetAppActivityRegistry( | 18 virtual AppActivityRegistry* GetAppActivityRegistry( |
| 22 const std::string& app_id, | 19 const std::string& app_id, |
| 23 content::BrowserContext* browser_context) OVERRIDE; | 20 content::BrowserContext* browser_context) OVERRIDE; |
| 24 virtual int NumberOfApplications() const OVERRIDE { return app_list_.size(); } | 21 virtual int NumberOfApplications() const OVERRIDE { return app_list_.size(); } |
| 25 | 22 |
| 26 private: | 23 private: |
| 27 virtual void RemoveAppActivityRegistry( | 24 virtual void RemoveAppActivityRegistry( |
| 28 AppActivityRegistry* registry) OVERRIDE; | 25 AppActivityRegistry* registry) OVERRIDE; |
| 29 | 26 |
| 30 std::vector<AppActivityRegistry*> app_list_; | 27 std::vector<AppActivityRegistry*> app_list_; |
| 31 | |
| 32 scoped_ptr<AppContentControlDelegate> delegate_; | |
| 33 | 28 |
| 34 DISALLOW_COPY_AND_ASSIGN(AppRegistryImpl); | 29 DISALLOW_COPY_AND_ASSIGN(AppRegistryImpl); |
| 35 }; | 30 }; |
| 36 | 31 |
| 37 namespace { | 32 namespace { |
| 38 | 33 |
| 39 AppRegistryImpl* instance = NULL; | 34 AppRegistryImpl* instance = NULL; |
| 40 | 35 |
| 41 } // namespace | 36 } // namespace |
| 42 | 37 |
| 43 AppRegistryImpl::AppRegistryImpl() : | 38 AppRegistryImpl::AppRegistryImpl() { |
| 44 delegate_(AppContentControlDelegate::CreateAppContentControlDelegate()) {} | 39 } |
| 45 | |
| 46 AppRegistryImpl::~AppRegistryImpl() { | 40 AppRegistryImpl::~AppRegistryImpl() { |
| 47 DCHECK(app_list_.empty()); | 41 DCHECK(app_list_.empty()); |
| 48 } | 42 } |
| 49 | 43 |
| 50 void AppRegistryImpl::SetDelegate(AppContentControlDelegate* delegate) { | |
| 51 DCHECK(delegate); | |
| 52 delegate_.reset(delegate); | |
| 53 } | |
| 54 | |
| 55 AppContentControlDelegate* AppRegistryImpl::GetDelegate() { | |
| 56 return delegate_.get(); | |
| 57 } | |
| 58 | |
| 59 AppActivityRegistry* AppRegistryImpl::GetAppActivityRegistry( | 44 AppActivityRegistry* AppRegistryImpl::GetAppActivityRegistry( |
| 60 const std::string& app_id, | 45 const std::string& app_id, |
| 61 content::BrowserContext* browser_context) { | 46 content::BrowserContext* browser_context) { |
| 62 // Search for an existing proxy. | 47 // Search for an existing proxy. |
| 63 for (std::vector<AppActivityRegistry*>::iterator it = app_list_.begin(); | 48 for (std::vector<AppActivityRegistry*>::iterator it = app_list_.begin(); |
| 64 it != app_list_.end(); ++it) { | 49 it != app_list_.end(); ++it) { |
| 65 if ((*it)->app_id() == app_id && | 50 if ((*it)->app_id() == app_id && |
| 66 (*it)->browser_context() == browser_context) | 51 (*it)->browser_context() == browser_context) |
| 67 return *it; | 52 return *it; |
| 68 } | 53 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 delete instance; | 85 delete instance; |
| 101 } | 86 } |
| 102 | 87 |
| 103 AppRegistry::AppRegistry() {} | 88 AppRegistry::AppRegistry() {} |
| 104 | 89 |
| 105 AppRegistry::~AppRegistry() { | 90 AppRegistry::~AppRegistry() { |
| 106 instance = NULL; | 91 instance = NULL; |
| 107 } | 92 } |
| 108 | 93 |
| 109 } // namespace athena | 94 } // namespace athena |
| OLD | NEW |