| 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 "extensions/browser/app_window/app_window_registry.h" | 5 #include "extensions/browser/app_window/app_window_registry.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_); | 55 content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 AppWindowRegistry* AppWindowRegistry::Get(content::BrowserContext* context) { | 59 AppWindowRegistry* AppWindowRegistry::Get(content::BrowserContext* context) { |
| 60 return Factory::GetForBrowserContext(context, true /* create */); | 60 return Factory::GetForBrowserContext(context, true /* create */); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void AppWindowRegistry::AddAppWindow(AppWindow* app_window) { | 63 void AppWindowRegistry::AddAppWindow(AppWindow* app_window) { |
| 64 BringToFront(app_window); | 64 BringToFront(app_window); |
| 65 FOR_EACH_OBSERVER(Observer, observers_, OnAppWindowAdded(app_window)); | 65 for (auto& observer : observers_) |
| 66 observer.OnAppWindowAdded(app_window); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void AppWindowRegistry::AppWindowIconChanged(AppWindow* app_window) { | 69 void AppWindowRegistry::AppWindowIconChanged(AppWindow* app_window) { |
| 69 AddAppWindowToList(app_window); | 70 AddAppWindowToList(app_window); |
| 70 FOR_EACH_OBSERVER(Observer, observers_, OnAppWindowIconChanged(app_window)); | 71 for (auto& observer : observers_) |
| 72 observer.OnAppWindowIconChanged(app_window); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void AppWindowRegistry::AppWindowActivated(AppWindow* app_window) { | 75 void AppWindowRegistry::AppWindowActivated(AppWindow* app_window) { |
| 74 BringToFront(app_window); | 76 BringToFront(app_window); |
| 75 FOR_EACH_OBSERVER(Observer, observers_, OnAppWindowActivated(app_window)); | 77 for (auto& observer : observers_) |
| 78 observer.OnAppWindowActivated(app_window); |
| 76 } | 79 } |
| 77 | 80 |
| 78 void AppWindowRegistry::AppWindowHidden(AppWindow* app_window) { | 81 void AppWindowRegistry::AppWindowHidden(AppWindow* app_window) { |
| 79 FOR_EACH_OBSERVER(Observer, observers_, OnAppWindowHidden(app_window)); | 82 for (auto& observer : observers_) |
| 83 observer.OnAppWindowHidden(app_window); |
| 80 } | 84 } |
| 81 | 85 |
| 82 void AppWindowRegistry::AppWindowShown(AppWindow* app_window, bool was_hidden) { | 86 void AppWindowRegistry::AppWindowShown(AppWindow* app_window, bool was_hidden) { |
| 83 FOR_EACH_OBSERVER(Observer, observers_, | 87 for (auto& observer : observers_) |
| 84 OnAppWindowShown(app_window, was_hidden)); | 88 observer.OnAppWindowShown(app_window, was_hidden); |
| 85 } | 89 } |
| 86 | 90 |
| 87 void AppWindowRegistry::RemoveAppWindow(AppWindow* app_window) { | 91 void AppWindowRegistry::RemoveAppWindow(AppWindow* app_window) { |
| 88 const AppWindowList::iterator it = | 92 const AppWindowList::iterator it = |
| 89 std::find(app_windows_.begin(), app_windows_.end(), app_window); | 93 std::find(app_windows_.begin(), app_windows_.end(), app_window); |
| 90 if (it != app_windows_.end()) | 94 if (it != app_windows_.end()) |
| 91 app_windows_.erase(it); | 95 app_windows_.erase(it); |
| 92 FOR_EACH_OBSERVER(Observer, observers_, OnAppWindowRemoved(app_window)); | 96 for (auto& observer : observers_) |
| 97 observer.OnAppWindowRemoved(app_window); |
| 93 } | 98 } |
| 94 | 99 |
| 95 void AppWindowRegistry::AddObserver(Observer* observer) { | 100 void AppWindowRegistry::AddObserver(Observer* observer) { |
| 96 observers_.AddObserver(observer); | 101 observers_.AddObserver(observer); |
| 97 } | 102 } |
| 98 | 103 |
| 99 void AppWindowRegistry::RemoveObserver(Observer* observer) { | 104 void AppWindowRegistry::RemoveObserver(Observer* observer) { |
| 100 observers_.RemoveObserver(observer); | 105 observers_.RemoveObserver(observer); |
| 101 } | 106 } |
| 102 | 107 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 bool AppWindowRegistry::Factory::ServiceIsNULLWhileTesting() const { | 266 bool AppWindowRegistry::Factory::ServiceIsNULLWhileTesting() const { |
| 262 return false; | 267 return false; |
| 263 } | 268 } |
| 264 | 269 |
| 265 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( | 270 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( |
| 266 content::BrowserContext* context) const { | 271 content::BrowserContext* context) const { |
| 267 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); | 272 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
| 268 } | 273 } |
| 269 | 274 |
| 270 } // namespace extensions | 275 } // namespace extensions |
| OLD | NEW |