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

Side by Side Diff: chrome/browser/ui/views/apps/app_info_dialog/app_info_footer_panel.cc

Issue 2791463002: mash: Remove ShelfDelegate; move functions to ShelfModel. (Closed)
Patch Set: Address comment. Created 3 years, 8 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
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/views/apps/app_info_dialog/app_info_footer_panel.h" 5 #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_footer_panel.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser_dialogs.h" 8 #include "chrome/browser/ui/browser_dialogs.h"
9 #include "chrome/common/extensions/extension_constants.h" 9 #include "chrome/common/extensions/extension_constants.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
11 #include "extensions/browser/extension_system.h" 11 #include "extensions/browser/extension_system.h"
12 #include "extensions/browser/management_policy.h" 12 #include "extensions/browser/management_policy.h"
13 #include "extensions/browser/uninstall_reason.h" 13 #include "extensions/browser/uninstall_reason.h"
14 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/events/event.h" 16 #include "ui/events/event.h"
17 #include "ui/views/controls/button/md_text_button.h" 17 #include "ui/views/controls/button/md_text_button.h"
18 #include "ui/views/layout/box_layout.h" 18 #include "ui/views/layout/box_layout.h"
19 #include "ui/views/layout/layout_constants.h" 19 #include "ui/views/layout/layout_constants.h"
20 #include "ui/views/view.h" 20 #include "ui/views/view.h"
21 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
22 22
23 #if defined(USE_ASH) 23 #if defined(USE_ASH)
24 #include "ash/shelf/shelf_delegate.h" // nogncheck 24 #include "ash/shelf/shelf_model.h" // nogncheck
25 #include "ash/shell.h" // nogncheck 25 #include "ash/shell.h" // nogncheck
26 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" // nogncheck 26 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" // nogncheck
27 #endif 27 #endif
28 28
29 AppInfoFooterPanel::AppInfoFooterPanel(gfx::NativeWindow parent_window, 29 AppInfoFooterPanel::AppInfoFooterPanel(gfx::NativeWindow parent_window,
30 Profile* profile, 30 Profile* profile,
31 const extensions::Extension* app) 31 const extensions::Extension* app)
32 : AppInfoPanel(profile, app), 32 : AppInfoPanel(profile, app),
33 parent_window_(parent_window), 33 parent_window_(parent_window),
34 create_shortcuts_button_(NULL), 34 create_shortcuts_button_(NULL),
35 pin_to_shelf_button_(NULL), 35 pin_to_shelf_button_(NULL),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 AddChildView(unpin_from_shelf_button_); 82 AddChildView(unpin_from_shelf_button_);
83 UpdatePinButtons(false); 83 UpdatePinButtons(false);
84 84
85 if (remove_button_) 85 if (remove_button_)
86 AddChildView(remove_button_); 86 AddChildView(remove_button_);
87 } 87 }
88 88
89 void AppInfoFooterPanel::UpdatePinButtons(bool focus_visible_button) { 89 void AppInfoFooterPanel::UpdatePinButtons(bool focus_visible_button) {
90 #if defined(USE_ASH) 90 #if defined(USE_ASH)
91 if (pin_to_shelf_button_ && unpin_from_shelf_button_) { 91 if (pin_to_shelf_button_ && unpin_from_shelf_button_) {
92 bool is_pinned = 92 bool is_pinned = !ash::Shell::Get()->shelf_model()->IsAppPinned(app_->id());
93 !ash::Shell::Get()->shelf_delegate()->IsAppPinned(app_->id());
94 pin_to_shelf_button_->SetVisible(is_pinned); 93 pin_to_shelf_button_->SetVisible(is_pinned);
95 unpin_from_shelf_button_->SetVisible(!is_pinned); 94 unpin_from_shelf_button_->SetVisible(!is_pinned);
96 95
97 if (focus_visible_button) { 96 if (focus_visible_button) {
98 views::View* button_to_focus = 97 views::View* button_to_focus =
99 is_pinned ? pin_to_shelf_button_ : unpin_from_shelf_button_; 98 is_pinned ? pin_to_shelf_button_ : unpin_from_shelf_button_;
100 button_to_focus->RequestFocus(); 99 button_to_focus->RequestFocus();
101 } 100 }
102 } 101 }
103 #endif 102 #endif
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return false; 144 return false;
146 #else 145 #else
147 // Extensions and the Chrome component app can't have shortcuts. 146 // Extensions and the Chrome component app can't have shortcuts.
148 return app_->id() != extension_misc::kChromeAppId && !app_->is_extension(); 147 return app_->id() != extension_misc::kChromeAppId && !app_->is_extension();
149 #endif // USE_ASH 148 #endif // USE_ASH
150 } 149 }
151 150
152 #if defined(USE_ASH) 151 #if defined(USE_ASH)
153 void AppInfoFooterPanel::SetPinnedToShelf(bool value) { 152 void AppInfoFooterPanel::SetPinnedToShelf(bool value) {
154 DCHECK(CanSetPinnedToShelf()); 153 DCHECK(CanSetPinnedToShelf());
155 ash::ShelfDelegate* shelf_delegate = ash::Shell::Get()->shelf_delegate(); 154 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model();
156 DCHECK(shelf_delegate); 155 DCHECK(shelf_model);
157 if (value) 156 if (value)
158 shelf_delegate->PinAppWithID(app_->id()); 157 shelf_model->PinAppWithID(app_->id());
159 else 158 else
160 shelf_delegate->UnpinAppWithID(app_->id()); 159 shelf_model->UnpinAppWithID(app_->id());
161 160
162 UpdatePinButtons(true); 161 UpdatePinButtons(true);
163 Layout(); 162 Layout();
164 } 163 }
165 164
166 bool AppInfoFooterPanel::CanSetPinnedToShelf() const { 165 bool AppInfoFooterPanel::CanSetPinnedToShelf() const {
167 // Non-Ash platforms don't have a shelf. 166 // Non-Ash platforms don't have a shelf.
168 if (!ash::Shell::HasInstance()) 167 if (!ash::Shell::HasInstance())
169 return false; 168 return false;
170 169
(...skipping 13 matching lines...) Expand all
184 app_, extensions::UNINSTALL_REASON_USER_INITIATED, 183 app_, extensions::UNINSTALL_REASON_USER_INITIATED,
185 extensions::UNINSTALL_SOURCE_APP_INFO_DIALOG); 184 extensions::UNINSTALL_SOURCE_APP_INFO_DIALOG);
186 } 185 }
187 186
188 bool AppInfoFooterPanel::CanUninstallApp() const { 187 bool AppInfoFooterPanel::CanUninstallApp() const {
189 extensions::ManagementPolicy* policy = 188 extensions::ManagementPolicy* policy =
190 extensions::ExtensionSystem::Get(profile_)->management_policy(); 189 extensions::ExtensionSystem::Get(profile_)->management_policy();
191 return policy->UserMayModifySettings(app_, nullptr) && 190 return policy->UserMayModifySettings(app_, nullptr) &&
192 !policy->MustRemainInstalled(app_, nullptr); 191 !policy->MustRemainInstalled(app_, nullptr);
193 } 192 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc ('k') | chrome/test/base/browser_with_test_window_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698