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

Side by Side Diff: chrome/browser/ui/app_list/app_list_shower_views.cc

Issue 219383006: Never create an app list for an incognito profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 1 month 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 | Annotate | Revision Log
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 "chrome/browser/ui/app_list/app_list_shower_views.h" 5 #include "chrome/browser/ui/app_list/app_list_shower_views.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/apps/scoped_keep_alive.h" 9 #include "chrome/browser/apps/scoped_keep_alive.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/app_list/app_list_shower_delegate.h" 11 #include "chrome/browser/ui/app_list/app_list_shower_delegate.h"
12 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 12 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
13 #include "ui/app_list/views/app_list_view.h" 13 #include "ui/app_list/views/app_list_view.h"
14 #include "ui/gfx/geometry/point.h" 14 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/screen.h" 15 #include "ui/gfx/screen.h"
16 16
17 AppListShower::AppListShower(AppListShowerDelegate* delegate) 17 AppListShower::AppListShower(AppListShowerDelegate* delegate)
18 : delegate_(delegate), 18 : delegate_(delegate),
19 profile_(NULL), 19 profile_(NULL),
20 app_list_(NULL), 20 app_list_(NULL),
21 window_icon_updated_(false) { 21 window_icon_updated_(false) {
22 } 22 }
23 23
24 AppListShower::~AppListShower() { 24 AppListShower::~AppListShower() {
25 } 25 }
26 26
27 void AppListShower::ShowForProfile(Profile* requested_profile) { 27 void AppListShower::ShowForCurrentProfile() {
28 DCHECK(HasView());
29 keep_alive_.reset(new ScopedKeepAlive);
30
28 // If the app list is already displaying |profile| just activate it (in case 31 // If the app list is already displaying |profile| just activate it (in case
29 // we have lost focus). 32 // we have lost focus).
30 if (IsAppListVisible() && (requested_profile == profile_)) {
31 Show();
32 return;
33 }
34
35 if (!HasView()) {
36 CreateViewForProfile(requested_profile);
37 } else if (requested_profile != profile_) {
38 profile_ = requested_profile;
39 UpdateViewForNewProfile();
40 }
41
42 keep_alive_.reset(new ScopedKeepAlive);
43 if (!IsAppListVisible()) 33 if (!IsAppListVisible())
44 delegate_->MoveNearCursor(app_list_); 34 delegate_->MoveNearCursor(app_list_);
35
45 Show(); 36 Show();
46 } 37 }
47 38
48 gfx::NativeWindow AppListShower::GetWindow() { 39 gfx::NativeWindow AppListShower::GetWindow() {
49 if (!IsAppListVisible()) 40 if (!IsAppListVisible())
50 return NULL; 41 return NULL;
51 return app_list_->GetWidget()->GetNativeWindow(); 42 return app_list_->GetWidget()->GetNativeWindow();
52 } 43 }
53 44
54 void AppListShower::CreateViewForProfile(Profile* requested_profile) { 45 void AppListShower::CreateViewForProfile(Profile* requested_profile) {
55 profile_ = requested_profile; 46 DCHECK(requested_profile);
47 if (HasView() && requested_profile->IsSameProfile(profile_))
48 return;
49
50 profile_ = requested_profile->GetOriginalProfile();
51 if (HasView()) {
52 UpdateViewForNewProfile();
53 return;
54 }
56 app_list_ = MakeViewForCurrentProfile(); 55 app_list_ = MakeViewForCurrentProfile();
57 delegate_->OnViewCreated(); 56 delegate_->OnViewCreated();
58 } 57 }
59 58
60 void AppListShower::DismissAppList() { 59 void AppListShower::DismissAppList() {
61 if (HasView()) { 60 if (HasView()) {
62 Hide(); 61 Hide();
63 delegate_->OnViewDismissed(); 62 delegate_->OnViewDismissed();
64 // This can be reached by pressing the dismiss accelerator. To prevent 63 // This can be reached by pressing the dismiss accelerator. To prevent
65 // events from being processed with a destroyed dispatcher, delay the reset 64 // events from being processed with a destroyed dispatcher, delay the reset
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 FROM_HERE, 133 FROM_HERE,
135 base::Bind(&AppListShower::ResetKeepAlive, base::Unretained(this))); 134 base::Bind(&AppListShower::ResetKeepAlive, base::Unretained(this)));
136 return; 135 return;
137 } 136 }
138 ResetKeepAlive(); 137 ResetKeepAlive();
139 } 138 }
140 139
141 void AppListShower::ResetKeepAlive() { 140 void AppListShower::ResetKeepAlive() {
142 keep_alive_.reset(); 141 keep_alive_.reset();
143 } 142 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_shower_views.h ('k') | chrome/browser/ui/app_list/app_list_shower_views_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698