- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / automation / automation_provider_list.cc
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/automation/automation_provider_list.h"
6
7 #include <algorithm>
8
9 #include "base/logging.h"
10 #include "chrome/browser/automation/automation_provider.h"
11
12 AutomationProviderList::AutomationProviderList() {
13 }
14
15 AutomationProviderList::~AutomationProviderList() {
16   iterator iter = automation_providers_.begin();
17   while (iter != automation_providers_.end()) {
18     (*iter)->Release();
19     iter = automation_providers_.erase(iter);
20   }
21 }
22
23 bool AutomationProviderList::AddProvider(AutomationProvider* provider) {
24   provider->AddRef();
25   automation_providers_.push_back(provider);
26   return true;
27 }
28
29 bool AutomationProviderList::RemoveProvider(AutomationProvider* provider) {
30   const iterator remove_provider =
31     std::find(automation_providers_.begin(), automation_providers_.end(),
32               provider);
33   if (remove_provider != automation_providers_.end()) {
34     (*remove_provider)->Release();
35     automation_providers_.erase(remove_provider);
36     if (automation_providers_.empty())
37       OnLastProviderRemoved();
38     return true;
39   }
40   return false;
41 }