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

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

Issue 2700523002: arc: Fix crash on accessing app info for secondary user. (Closed)
Patch Set: minor comment update Created 3 years, 10 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_dialog_views.h" 5 #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 17 matching lines...) Expand all
28 #include "ui/gfx/geometry/size.h" 28 #include "ui/gfx/geometry/size.h"
29 #include "ui/views/border.h" 29 #include "ui/views/border.h"
30 #include "ui/views/controls/scroll_view.h" 30 #include "ui/views/controls/scroll_view.h"
31 #include "ui/views/layout/box_layout.h" 31 #include "ui/views/layout/box_layout.h"
32 #include "ui/views/layout/layout_constants.h" 32 #include "ui/views/layout/layout_constants.h"
33 #include "ui/views/widget/widget.h" 33 #include "ui/views/widget/widget.h"
34 #include "ui/views/window/dialog_delegate.h" 34 #include "ui/views/window/dialog_delegate.h"
35 35
36 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
37 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 37 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
38 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
39 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
38 #include "chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel. h" 40 #include "chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel. h"
39 #endif 41 #endif
40 42
41 namespace { 43 namespace {
42 44
43 // The color of the separator used inside the dialog - should match the app 45 // The color of the separator used inside the dialog - should match the app
44 // list's app_list::kDialogSeparatorColor 46 // list's app_list::kDialogSeparatorColor
45 const SkColor kDialogSeparatorColor = SkColorSetRGB(0xD1, 0xD1, 0xD1); 47 const SkColor kDialogSeparatorColor = SkColorSetRGB(0xD1, 0xD1, 0xD1);
46 48
47 #if defined(OS_MACOSX) 49 #if defined(OS_MACOSX)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } else { 105 } else {
104 dialog_widget = 106 dialog_widget =
105 constrained_window::CreateBrowserModalDialogViews(dialog, window); 107 constrained_window::CreateBrowserModalDialogViews(dialog, window);
106 dialog_widget->Show(); 108 dialog_widget->Show();
107 } 109 }
108 } 110 }
109 111
110 AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window, 112 AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window,
111 Profile* profile, 113 Profile* profile,
112 const extensions::Extension* app) 114 const extensions::Extension* app)
113 : dialog_header_(NULL), 115 : profile_(profile), app_id_(app->id()) {
114 dialog_body_(NULL),
115 dialog_footer_(NULL),
116 profile_(profile),
117 app_id_(app->id()),
118 extension_registry_(NULL) {
119 views::BoxLayout* layout = 116 views::BoxLayout* layout =
120 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); 117 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
121 SetLayoutManager(layout); 118 SetLayoutManager(layout);
122 119
123 const int kHorizontalSeparatorHeight = 1; 120 const int kHorizontalSeparatorHeight = 1;
124 dialog_header_ = new AppInfoHeaderPanel(profile, app); 121 dialog_header_ = new AppInfoHeaderPanel(profile, app);
125 dialog_header_->SetBorder(views::CreateSolidSidedBorder( 122 dialog_header_->SetBorder(views::CreateSolidSidedBorder(
126 0, 0, kHorizontalSeparatorHeight, 0, kDialogSeparatorColor)); 123 0, 0, kHorizontalSeparatorHeight, 0, kDialogSeparatorColor));
127 124
128 dialog_footer_ = new AppInfoFooterPanel(parent_window, profile, app); 125 dialog_footer_ = new AppInfoFooterPanel(parent_window, profile, app);
(...skipping 10 matching lines...) Expand all
139 views::View* dialog_body_contents = new views::View(); 136 views::View* dialog_body_contents = new views::View();
140 dialog_body_contents->SetLayoutManager( 137 dialog_body_contents->SetLayoutManager(
141 new views::BoxLayout(views::BoxLayout::kVertical, 138 new views::BoxLayout(views::BoxLayout::kVertical,
142 views::kButtonHEdgeMarginNew, 139 views::kButtonHEdgeMarginNew,
143 views::kPanelVertMargin, 140 views::kPanelVertMargin,
144 views::kUnrelatedControlVerticalSpacing)); 141 views::kUnrelatedControlVerticalSpacing));
145 dialog_body_contents->AddChildView(new AppInfoSummaryPanel(profile, app)); 142 dialog_body_contents->AddChildView(new AppInfoSummaryPanel(profile, app));
146 dialog_body_contents->AddChildView(new AppInfoPermissionsPanel(profile, app)); 143 dialog_body_contents->AddChildView(new AppInfoPermissionsPanel(profile, app));
147 144
148 #if defined(OS_CHROMEOS) 145 #if defined(OS_CHROMEOS)
149 // When ARC is enabled, show the "Manage supported links" link for Chrome. 146 // When ARC is enabled and the Settings app is available, show the
150 if (arc::ArcSessionManager::Get()->IsArcPlayStoreEnabled() && 147 // "Manage supported links" link for Chrome.
151 app->id() == extension_misc::kChromeAppId) 148 if (app->id() == extension_misc::kChromeAppId &&
152 dialog_body_contents->AddChildView(new ArcAppInfoLinksPanel(profile, app)); 149 arc::ArcSessionManager::Get()->IsArcPlayStoreEnabled()) {
150 const ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile);
151 if (arc_app_list_prefs &&
152 arc_app_list_prefs->IsRegistered(arc::kSettingsAppId)) {
153 arc_app_info_links_ = new ArcAppInfoLinksPanel(profile, app);
154 dialog_body_contents->AddChildView(arc_app_info_links_);
155 }
156 }
153 #endif 157 #endif
154 158
155 // Clip the scrollable view so that the scrollbar appears. As long as this 159 // Clip the scrollable view so that the scrollbar appears. As long as this
156 // is larger than the height of the dialog, it will be resized to the dialog's 160 // is larger than the height of the dialog, it will be resized to the dialog's
157 // actual height. 161 // actual height.
158 // TODO(sashab): Add ClipHeight() as a parameter-less method to 162 // TODO(sashab): Add ClipHeight() as a parameter-less method to
159 // views::ScrollView() to mimic this behaviour. 163 // views::ScrollView() to mimic this behaviour.
160 const int kMaxDialogHeight = 1000; 164 const int kMaxDialogHeight = 1000;
161 dialog_body_ = new views::ScrollView(); 165 dialog_body_ = new views::ScrollView();
162 dialog_body_->ClipHeightTo(kMaxDialogHeight, kMaxDialogHeight); 166 dialog_body_->ClipHeightTo(kMaxDialogHeight, kMaxDialogHeight);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return; 207 return;
204 208
205 Close(); 209 Close();
206 } 210 }
207 211
208 void AppInfoDialog::OnShutdown(extensions::ExtensionRegistry* registry) { 212 void AppInfoDialog::OnShutdown(extensions::ExtensionRegistry* registry) {
209 DCHECK_EQ(extension_registry_, registry); 213 DCHECK_EQ(extension_registry_, registry);
210 StopObservingExtensionRegistry(); 214 StopObservingExtensionRegistry();
211 Close(); 215 Close();
212 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698