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

Issue 214163002: Added separate required, optional and file permissions to app info dialog (Closed)

Created:
6 years, 9 months ago by sashab
Modified:
6 years, 7 months ago
Reviewers:
benwells, Matt Giuca
CC:
chromium-reviews, tfarina, chrome-apps-syd-reviews_chromium.org
Visibility:
Public.

Description

Added collapsible permissions to the app info dialog Separated the optional and required permissions in the dialog, and added retained files as well. Also made the various types of permissions collapsible, and added a message when the app has no permissions whatsoever. BUG=356985, 350746 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=266518 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=267161

Patch Set 1 #

Patch Set 2 : Added collapsible permissions #

Patch Set 3 : Made permissions collapsible, required permissions expanded by default #

Total comments: 16

Patch Set 4 : Reverted the RTL special cases, which it turns out Chrome takes care of normally :) #

Patch Set 5 : Minor description fixes, dash fix and font size fix #

Total comments: 4

Patch Set 6 : Removed unicode from code #

Total comments: 4

Patch Set 7 : Unittests and minor fixes #

Patch Set 8 : Actual unittests this time #

Total comments: 19

Patch Set 9 : Nit fixes + unittest improvements #

Patch Set 10 : Attempted tsan fix and some leak fixes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+621 lines, -74 lines) Patch
M chrome/app/generated_resources.grd View 1 chunk +12 lines, -0 lines 0 comments Download
M chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.h View 1 2 3 4 5 6 7 8 2 chunks +28 lines, -0 lines 0 comments Download
M chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc View 1 2 3 4 5 6 7 8 9 3 chunks +371 lines, -74 lines 0 comments Download
A chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +209 lines, -0 lines 0 comments Download
M chrome/chrome_tests_unit.gypi View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 36 (0 generated)
sashab
This review is for adding the 3 separate scroll areas to the permissions tab. Screenshots ...
6 years, 9 months ago (2014-03-27 02:54:38 UTC) #1
benwells
On 2014/03/27 02:54:38, sasha_b wrote: > This review is for adding the 3 separate scroll ...
6 years, 9 months ago (2014-03-27 03:40:57 UTC) #2
sashab
I'm working on it now, but I thought I could do this review in parallel ...
6 years, 9 months ago (2014-03-27 03:46:39 UTC) #3
sashab
I know this review is pretty big, but a lot of it is just short ...
6 years, 8 months ago (2014-04-16 01:51:36 UTC) #4
Matt Giuca
https://codereview.chromium.org/214163002/diff/40001/chrome/app/generated_resources.grd File chrome/app/generated_resources.grd (right): https://codereview.chromium.org/214163002/diff/40001/chrome/app/generated_resources.grd#newcode2244 chrome/app/generated_resources.grd:2244: + <message name="IDS_APPLICATION_INFO_REQUIRED_PERMISSIONS_TEXT" desc="Text displayed above the required permissions ...
6 years, 8 months ago (2014-04-16 05:39:15 UTC) #5
Matt Giuca
Also, the CL description is too long. Should be wrapped to 72 chars, and the ...
6 years, 8 months ago (2014-04-16 05:41:14 UTC) #6
sashab
See comments. Also changed the size of the headings to be the 'base' font size ...
6 years, 8 months ago (2014-04-16 06:33:17 UTC) #7
Matt Giuca
lgtm lgtm with maybe going back to a hyphen. https://codereview.chromium.org/214163002/diff/80001/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc File chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc (right): https://codereview.chromium.org/214163002/diff/80001/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc#newcode211 chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc:211: ...
6 years, 8 months ago (2014-04-16 07:02:54 UTC) #8
sashab
https://codereview.chromium.org/214163002/diff/80001/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc File chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc (right): https://codereview.chromium.org/214163002/diff/80001/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc#newcode211 chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc:211: title_view->AddChildView(new views::Label(base::UTF8ToUTF16("–"))); On 2014/04/16 07:02:55, Matt Giuca wrote: > ...
6 years, 8 months ago (2014-04-16 23:26:06 UTC) #9
Matt Giuca
On 2014/04/16 23:26:06, sasha_b wrote: > https://codereview.chromium.org/214163002/diff/80001/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc > File chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc > (right): > > https://codereview.chromium.org/214163002/diff/80001/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc#newcode211 ...
6 years, 8 months ago (2014-04-16 23:47:09 UTC) #10
sashab
benwells please review :)
6 years, 8 months ago (2014-04-16 23:47:47 UTC) #11
benwells
I just skimmed and only have a couple of nits. Awesome CL. Any chance of ...
6 years, 8 months ago (2014-04-17 01:45:49 UTC) #12
sashab
I had some problems with 'git cl upload' so hopefully this uploaded correctly. But there ...
6 years, 8 months ago (2014-04-17 07:41:09 UTC) #13
benwells
https://codereview.chromium.org/214163002/diff/140001/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc File chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc (right): https://codereview.chromium.org/214163002/diff/140001/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc#newcode69 chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc:69: // Animates this to be a height proportional to ...
6 years, 8 months ago (2014-04-23 00:36:21 UTC) #14
sashab
I've done all requested fixes. As discussed, I _could_ add a giant test that has ...
6 years, 8 months ago (2014-04-28 01:59:06 UTC) #15
benwells
lgtm
6 years, 8 months ago (2014-04-28 04:24:20 UTC) #16
sashab
The CQ bit was checked by sashab@chromium.org
6 years, 8 months ago (2014-04-28 04:36:45 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sashab@chromium.org/214163002/160001
6 years, 8 months ago (2014-04-28 04:37:06 UTC) #18
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 8 months ago (2014-04-28 05:14:27 UTC) #19
commit-bot: I haz the power
Try jobs failed on following builders: tryserver.chromium on chromium_presubmit
6 years, 8 months ago (2014-04-28 05:14:27 UTC) #20
sashab
The CQ bit was checked by sashab@chromium.org
6 years, 8 months ago (2014-04-28 05:28:58 UTC) #21
sashab
The CQ bit was unchecked by sashab@chromium.org
6 years, 8 months ago (2014-04-28 05:29:19 UTC) #22
sashab
The CQ bit was checked by sashab@chromium.org
6 years, 8 months ago (2014-04-28 06:15:41 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sashab@chromium.org/214163002/160001
6 years, 8 months ago (2014-04-28 06:16:52 UTC) #24
commit-bot: I haz the power
Change committed as 266518
6 years, 7 months ago (2014-04-28 12:20:00 UTC) #25
sashab
The CQ bit was checked by sashab@chromium.org
6 years, 7 months ago (2014-04-30 00:50:56 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sashab@chromium.org/214163002/200001
6 years, 7 months ago (2014-04-30 00:52:44 UTC) #27
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 7 months ago (2014-04-30 02:39:33 UTC) #28
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_rel on tryserver.chromium
6 years, 7 months ago (2014-04-30 02:39:34 UTC) #29
sashab
The CQ bit was checked by sashab@chromium.org
6 years, 7 months ago (2014-04-30 03:34:52 UTC) #30
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sashab@chromium.org/214163002/200001
6 years, 7 months ago (2014-04-30 03:35:59 UTC) #31
commit-bot: I haz the power
Change committed as 267161
6 years, 7 months ago (2014-04-30 10:39:17 UTC) #32
sashab
The CQ bit was checked by sashab@chromium.org
6 years, 7 months ago (2014-05-01 00:01:12 UTC) #33
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sashab@chromium.org/214163002/220001
6 years, 7 months ago (2014-05-01 00:02:21 UTC) #34
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 7 months ago (2014-05-01 00:02:41 UTC) #35
commit-bot: I haz the power
6 years, 7 months ago (2014-05-01 00:02:42 UTC) #36
Failed to apply patch for
chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc:
While running patch -p1 --forward --force --no-backup-if-mismatch;
  patching file
chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc
  Hunk #1 FAILED at 4.
  Hunk #2 FAILED at 83.
  Hunk #3 FAILED at 95.
  3 out of 3 hunks FAILED -- saving rejects to file
chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc.rej

Patch:      
chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc
Index: chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc
diff --git
a/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc
b/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc
index
e8d6d31b98057b7348963930df79204762210a71..bf5a7791f1bdb7d594734deae136f44e44b13a00
100644
--- a/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc
+++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.cc
@@ -4,78 +4,131 @@
 
 #include
"chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.h"
 
+#include "apps/saved_files_service.h"
+#include "base/files/file_path.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
 #include "extensions/common/extension.h"
+#include "extensions/common/permissions/api_permission.h"
 #include "extensions/common/permissions/permission_message_provider.h"
-#include "extensions/common/permissions/permission_set.h"
+#include "extensions/common/permissions/permissions_data.h"
 #include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
 #include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/animation/animation.h"
+#include "ui/gfx/animation/animation_delegate.h"
+#include "ui/gfx/animation/slide_animation.h"
+#include "ui/gfx/text_constants.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/controls/button/image_button.h"
 #include "ui/views/controls/label.h"
 #include "ui/views/controls/scroll_view.h"
-#include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/layout/fill_layout.h"
 #include "ui/views/layout/grid_layout.h"
 #include "ui/views/layout/layout_constants.h"
 
-// A scrollable list of permissions for the given app.
-class PermissionsScrollView : public views::ScrollView {
+namespace {
+
+// A view to display a title with an expandable permissions list section.
+class ExpandableContainerView : public views::View,
+                                public views::ButtonListener,
+                                public gfx::AnimationDelegate {
  public:
-  PermissionsScrollView(int min_height,
-                        int max_height,
-                        const extensions::Extension* app);
+  ExpandableContainerView(
+      views::View* owner,
+      const base::string16& title,
+      const std::vector<base::string16>& permission_messages);
+  virtual ~ExpandableContainerView();
+
+  // views::View:
+  virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
+
+  // views::ButtonListener:
+  virtual void ButtonPressed(views::Button* sender,
+                             const ui::Event& event) OVERRIDE;
+
+  // gfx::AnimationDelegate:
+  virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
+  virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
+
+  // Expand/Collapse the detail section for this ExpandableContainerView.
+  void ToggleDetailLevel();
 
  private:
-  virtual ~PermissionsScrollView();
-};
+  // A view which displays the permission messages as a bulleted list.
+  class DetailsView : public views::View {
+   public:
+    explicit DetailsView(std::vector<base::string16> messages);
+    virtual ~DetailsView() {}
 
-PermissionsScrollView::PermissionsScrollView(int min_height,
-                                             int max_height,
-                                             const extensions::Extension* app)
{
-  ClipHeightTo(min_height, max_height);
-  SetVerticalScrollBar(new views::OverlayScrollBar(false));
+    // views::View:
+    virtual gfx::Size GetPreferredSize() OVERRIDE;
 
-  views::View* inner_scrollable_view = new views::View();
-  this->SetContents(inner_scrollable_view);
+    // Animates this to be a height proportional to |ratio|.
+    void AnimateToRatio(double ratio);
 
-  // Get the permission messages for the app.
-  std::vector<base::string16> permission_messages =
-      extensions::PermissionMessageProvider::Get()->GetWarningMessages(
-          app->GetActivePermissions(), app->GetType());
+   private:
+    // The current state of the animation, as a decimal from 0 to 1 (0 is fully
+    // collapsed, 1 is fully expanded).
+    double visible_ratio_;
 
-  // Create the layout.
-  views::GridLayout* layout =
-      views::GridLayout::CreatePanel(inner_scrollable_view);
-  inner_scrollable_view->SetLayoutManager(layout);
+    DISALLOW_COPY_AND_ASSIGN(DetailsView);
+  };
+
+  // The dialog that owns |this|. It's also an ancestor in the View hierarchy.
+  views::View* owner_;
+
+  // A view for showing |permission_messages|.
+  DetailsView* details_view_;
+
+  gfx::SlideAnimation slide_animation_;
+
+  // The up/down arrow next to the heading (points up/down depending on whether
+  // the details section is expanded).
+  views::ImageButton* arrow_toggle_;
+
+  // Whether the details section is expanded.
+  bool expanded_;
+
+  DISALLOW_COPY_AND_ASSIGN(ExpandableContainerView);
+};
+
+ExpandableContainerView::DetailsView::DetailsView(
+    std::vector<base::string16> messages)
+    : visible_ratio_(0) {
+  views::GridLayout* layout = views::GridLayout::CreatePanel(this);
+  SetLayoutManager(layout);
 
   // Create 2 columns: one for the bullet, one for the bullet text.
-  static const int kPermissionBulletsColumnSetId = 1;
-  views::ColumnSet* permission_bullets_column_set =
-      layout->AddColumnSet(kPermissionBulletsColumnSetId);
-  permission_bullets_column_set->AddPaddingColumn(0, 10);
-  permission_bullets_column_set->AddColumn(views::GridLayout::LEADING,
-                                           views::GridLayout::LEADING,
-                                           0,
-                                           views::GridLayout::USE_PREF,
-                                           0,  // no fixed width
-                                           0);
-  permission_bullets_column_set->AddPaddingColumn(0, 5);
-  permission_bullets_column_set->AddColumn(views::GridLayout::LEADING,
-                                           views::GridLayout::LEADING,
-                                           0,
-                                           views::GridLayout::USE_PREF,
-                                           0,  // no fixed width
-                                           0);
+  static const int kColumnSet = 1;
+  views::ColumnSet* column_set = layout->AddColumnSet(kColumnSet);
+  column_set->AddPaddingColumn(0, 10);
+  column_set->AddColumn(views::GridLayout::LEADING,
+                        views::GridLayout::LEADING,
+                        1,
+                        views::GridLayout::USE_PREF,
+                        0,
+                        0);
+  column_set->AddPaddingColumn(0, 5);
+  column_set->AddColumn(views::GridLayout::LEADING,
+                        views::GridLayout::LEADING,
+                        1,
+                        views::GridLayout::USE_PREF,
+                        0,
+                        0);
 
   // Add permissions to scrollable view.
-  for (std::vector<base::string16>::const_iterator it =
-           permission_messages.begin();
-       it != permission_messages.end();
+  for (std::vector<base::string16>::const_iterator it = messages.begin();
+       it != messages.end();
        ++it) {
     views::Label* permission_label = new views::Label(*it);
 
     permission_label->SetMultiLine(true);
     permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
-    permission_label->SizeToFit(250);
 
-    layout->StartRow(0, kPermissionBulletsColumnSetId);
+    layout->StartRow(0, kColumnSet);
     // Extract only the bullet from the IDS_EXTENSION_PERMISSION_LINE text.
     layout->AddView(new views::Label(l10n_util::GetStringFUTF16(
         IDS_EXTENSION_PERMISSION_LINE, base::string16())));
@@ -83,11 +136,139 @@ PermissionsScrollView::PermissionsScrollView(int
min_height,
     // bullet.
     layout->AddView(permission_label);
 
-    layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
+    layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing);
+  }
+}
+
+gfx::Size ExpandableContainerView::DetailsView::GetPreferredSize() {
+  gfx::Size size = views::View::GetPreferredSize();
+  return gfx::Size(size.width(), size.height() * visible_ratio_);
+}
+
+void ExpandableContainerView::DetailsView::AnimateToRatio(double ratio) {
+  visible_ratio_ = ratio;
+  PreferredSizeChanged();
+  SchedulePaint();
+}
+
+ExpandableContainerView::ExpandableContainerView(
+    views::View* owner,
+    const base::string16& title,
+    const std::vector<base::string16>& permission_messages)
+    : owner_(owner),
+      details_view_(NULL),
+      slide_animation_(this),
+      arrow_toggle_(NULL),
+      expanded_(false) {
+  views::GridLayout* layout = new views::GridLayout(this);
+  SetLayoutManager(layout);
+  const int kMainColumnSetId = 0;
+  views::ColumnSet* column_set = layout->AddColumnSet(kMainColumnSetId);
+  column_set->AddColumn(views::GridLayout::LEADING,
+                        views::GridLayout::LEADING,
+                        1,
+                        views::GridLayout::USE_PREF,
+                        0,
+                        0);
+
+  // A column set that is split in half, to allow for the expand/collapse
button
+  // image to be aligned to the right of the vi…
(message too large)

Powered by Google App Engine
This is Rietveld 408576698