Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: athena/activity/activity_manager_impl.cc

Issue 603033002: Get FileSelect dialog work on athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reformat Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « athena/activity/activity_manager_impl.h ('k') | athena/activity/activity_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/activity/activity_manager_impl.h" 5 #include "athena/activity/activity_manager_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "athena/activity/activity_widget_delegate.h" 9 #include "athena/activity/activity_widget_delegate.h"
10 #include "athena/activity/public/activity.h" 10 #include "athena/activity/public/activity.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 widget->Close(); 78 widget->Close();
79 } 79 }
80 } 80 }
81 81
82 void ActivityManagerImpl::UpdateActivity(Activity* activity) { 82 void ActivityManagerImpl::UpdateActivity(Activity* activity) {
83 views::Widget* widget = GetWidget(activity); 83 views::Widget* widget = GetWidget(activity);
84 widget->UpdateWindowIcon(); 84 widget->UpdateWindowIcon();
85 widget->UpdateWindowTitle(); 85 widget->UpdateWindowTitle();
86 } 86 }
87 87
88 Activity* ActivityManagerImpl::GetActivityForWindow(aura::Window* window) {
89 struct Matcher {
90 Matcher(aura::Window* w) : window(w) {}
91 bool operator()(Activity* activity) {
92 return activity->GetWindow() == window;
93 }
94 aura::Window* window;
95 };
96 std::vector<Activity*>::iterator iter =
97 std::find_if(activities_.begin(), activities_.end(), Matcher(window));
98 return iter != activities_.end() ? *iter : NULL;
99 }
100
88 void ActivityManagerImpl::AddObserver(ActivityManagerObserver* observer) { 101 void ActivityManagerImpl::AddObserver(ActivityManagerObserver* observer) {
89 observers_.AddObserver(observer); 102 observers_.AddObserver(observer);
90 } 103 }
91 104
92 void ActivityManagerImpl::RemoveObserver(ActivityManagerObserver* observer) { 105 void ActivityManagerImpl::RemoveObserver(ActivityManagerObserver* observer) {
93 observers_.RemoveObserver(observer); 106 observers_.RemoveObserver(observer);
94 } 107 }
95 108
96 void ActivityManagerImpl::OnWidgetDestroying(views::Widget* widget) { 109 void ActivityManagerImpl::OnWidgetDestroying(views::Widget* widget) {
97 struct Matcher { 110 Activity* activity = GetActivityForWindow(widget->GetNativeWindow());
98 Matcher(aura::Window* w) : window(w) {} 111 if (activity) {
99
100 bool operator()(Activity* activity) {
101 return activity->GetWindow() == window;
102 }
103 aura::Window* window;
104 };
105 std::vector<Activity*>::iterator iter =
106 std::find_if(activities_.begin(),
107 activities_.end(),
108 Matcher(widget->GetNativeWindow()));
109 DCHECK(iter != activities_.end());
110 if (iter != activities_.end()) {
111 widget->RemoveObserver(this); 112 widget->RemoveObserver(this);
112 Activity::Delete(*iter); 113 Activity::Delete(activity);
113 } 114 }
114 } 115 }
115 116
116 // static 117 // static
117 ActivityManager* ActivityManager::Create() { 118 ActivityManager* ActivityManager::Create() {
118 new ActivityManagerImpl(); 119 new ActivityManagerImpl();
119 CHECK(instance); 120 CHECK(instance);
120 return instance; 121 return instance;
121 } 122 }
122 123
123 ActivityManager* ActivityManager::Get() { 124 ActivityManager* ActivityManager::Get() {
124 return instance; 125 return instance;
125 } 126 }
126 127
127 void ActivityManager::Shutdown() { 128 void ActivityManager::Shutdown() {
128 CHECK(instance); 129 CHECK(instance);
129 delete instance; 130 delete instance;
130 } 131 }
131 132
132 133
133 } // namespace athena 134 } // namespace athena
OLDNEW
« no previous file with comments | « athena/activity/activity_manager_impl.h ('k') | athena/activity/activity_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698