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

Unified Diff: chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc

Issue 580363002: Update app info and install prompt UI to show retained devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed feedback from Avi and tapted. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc
diff --git a/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc b/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc
index 844ad48ce9271a00dbc9ed57350e46bb12aa47cd..19c6d26d22a7631928769c99598e88d1bb2b5511 100644
--- a/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc
+++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc
@@ -8,9 +8,13 @@
#include <vector>
#include "apps/app_load_service.h"
+#include "apps/saved_devices_service.h"
#include "apps/saved_files_service.h"
#include "base/files/file_path.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/grit/generated_resources.h"
+#include "device/usb/usb_ids.h"
#include "extensions/common/extension.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/permissions_data.h"
@@ -31,10 +35,14 @@ AppInfoPermissionsPanel::AppInfoPermissionsPanel(
active_permissions_list_(NULL),
retained_files_heading_(NULL),
retained_files_list_(NULL),
- revoke_file_permissions_button_(NULL) {
+ revoke_file_permissions_button_(NULL),
+ retained_devices_heading_(NULL),
+ retained_devices_list_(NULL),
+ revoke_device_permissions_button_(NULL) {
// Create UI elements.
CreateActivePermissionsControl();
CreateRetainedFilesControl();
+ CreateRetainedDevicesControl();
// Layout elements.
SetLayoutManager(
@@ -45,6 +53,7 @@ AppInfoPermissionsPanel::AppInfoPermissionsPanel(
LayoutActivePermissionsControl();
LayoutRetainedFilesControl();
+ LayoutRetainedDevicesControl();
}
AppInfoPermissionsPanel::~AppInfoPermissionsPanel() {
@@ -142,6 +151,24 @@ void AppInfoPermissionsPanel::CreateRetainedFilesControl() {
}
}
+void AppInfoPermissionsPanel::CreateRetainedDevicesControl() {
+ const std::vector<base::string16> retained_device_permission_messages =
+ GetRetainedDevices();
+
+ if (!retained_device_permission_messages.empty()) {
+ revoke_device_permissions_button_ = new views::LabelButton(
+ this,
+ l10n_util::GetStringUTF16(
+ IDS_APPLICATION_INFO_REVOKE_DEVICE_PERMISSIONS_BUTTON_TEXT));
+ revoke_device_permissions_button_->SetStyle(views::Button::STYLE_BUTTON);
+
+ retained_devices_heading_ = CreateHeading(l10n_util::GetStringUTF16(
+ IDS_APPLICATION_INFO_RETAINED_DEVICE_PERMISSIONS_TEXT));
+ retained_devices_list_ = CreateBulletedListView(
+ retained_device_permission_messages, false, gfx::ELIDE_TAIL);
+ }
+}
+
void AppInfoPermissionsPanel::LayoutActivePermissionsControl() {
if (active_permissions_list_) {
views::View* vertical_stack = CreateVerticalStack();
@@ -176,10 +203,35 @@ void AppInfoPermissionsPanel::LayoutRetainedFilesControl() {
}
}
+void AppInfoPermissionsPanel::LayoutRetainedDevicesControl() {
+ if (retained_devices_list_) {
+ DCHECK(retained_devices_heading_);
+ DCHECK(revoke_device_permissions_button_);
+
+ // Add a sub-view so the revoke button is right-aligned.
+ views::View* right_aligned_button = new views::View();
+ views::BoxLayout* right_aligned_horizontal_layout =
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
+ right_aligned_horizontal_layout->set_main_axis_alignment(
+ views::BoxLayout::MAIN_AXIS_ALIGNMENT_END);
+ right_aligned_button->SetLayoutManager(right_aligned_horizontal_layout);
+ right_aligned_button->AddChildView(revoke_device_permissions_button_);
+
+ views::View* vertical_stack = CreateVerticalStack();
+ vertical_stack->AddChildView(retained_devices_heading_);
+ vertical_stack->AddChildView(retained_devices_list_);
+ vertical_stack->AddChildView(right_aligned_button);
+
+ AddChildView(vertical_stack);
+ }
+}
+
void AppInfoPermissionsPanel::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == revoke_file_permissions_button_) {
RevokeFilePermissions();
+ } else if (sender == revoke_device_permissions_button_) {
+ RevokeDevicePermissions();
} else {
NOTREACHED();
}
@@ -213,3 +265,16 @@ void AppInfoPermissionsPanel::RevokeFilePermissions() {
GetWidget()->Close();
}
+
+const std::vector<base::string16> AppInfoPermissionsPanel::GetRetainedDevices()
+ const {
+ return apps::SavedDevicesService::Get(profile_)
+ ->GetPermissionMessageStrings(app_->id());
+}
+
+void AppInfoPermissionsPanel::RevokeDevicePermissions() {
+ apps::SavedDevicesService::Get(profile_)->Clear(app_->id());
+ apps::AppLoadService::Get(profile_)->RestartApplicationIfRunning(app_->id());
+
+ GetWidget()->Close();
+}

Powered by Google App Engine
This is Rietveld 408576698