Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / apps / app_info_dialog / app_info_dialog_views.cc
index e7f812e..0979bb4 100644 (file)
@@ -5,6 +5,7 @@
 #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.h"
 
 #include "base/memory/scoped_ptr.h"
+#include "base/metrics/histogram.h"
 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
 #include "chrome/browser/ui/views/app_list/app_list_dialog_contents_view.h"
 #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_footer_panel.h"
 #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.h"
 #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.h"
 #include "chrome/browser/ui/views/constrained_window_views.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/manifest.h"
 #include "ui/app_list/app_list_constants.h"
 #include "ui/gfx/geometry/rect.h"
 #include "ui/gfx/geometry/size.h"
 #include "ui/views/border.h"
 #include "ui/views/controls/scroll_view.h"
 #include "ui/views/layout/box_layout.h"
-#include "ui/views/layout/grid_layout.h"
 #include "ui/views/layout/layout_constants.h"
 #include "ui/views/widget/widget.h"
 
 void ShowAppInfoDialog(AppListControllerDelegate* app_list_controller_delegate,
                        Profile* profile,
                        const extensions::Extension* app) {
+  UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialogOpenedForType",
+                            app->GetType(),
+                            extensions::Manifest::NUM_LOAD_TYPES);
+  UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialogOpenedForLocation",
+                            app->location(),
+                            extensions::Manifest::NUM_LOCATIONS);
+
   gfx::NativeWindow app_list_window =
       app_list_controller_delegate->GetAppListWindow();
   DCHECK(app_list_window);
@@ -43,19 +52,10 @@ AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window,
                              Profile* profile,
                              const extensions::Extension* app)
     : dialog_header_(NULL), dialog_body_(NULL), dialog_footer_(NULL) {
-  views::GridLayout* layout = new views::GridLayout(this);
+  views::BoxLayout* layout =
+      new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
   SetLayoutManager(layout);
 
-  // Create one column that fills the whole dialog.
-  int kColumnSetId = 1;
-  views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId);
-  column_set->AddColumn(views::GridLayout::FILL,
-                        views::GridLayout::FILL,
-                        1,  // Stretch the column to the width of the dialog.
-                        views::GridLayout::USE_PREF,
-                        0,
-                        0);
-
   const int kHorizontalSeparatorHeight = 1;
   dialog_header_ = new AppInfoHeaderPanel(profile, app);
   dialog_header_->SetBorder(views::Border::CreateSolidSidedBorder(
@@ -64,6 +64,11 @@ AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window,
   dialog_footer_ = new AppInfoFooterPanel(parent_window, profile, app);
   dialog_footer_->SetBorder(views::Border::CreateSolidSidedBorder(
       kHorizontalSeparatorHeight, 0, 0, 0, app_list::kDialogSeparatorColor));
+  if (!dialog_footer_->has_children()) {
+    // If there are no controls in the footer, don't add it to the dialog.
+    delete dialog_footer_;
+    dialog_footer_ = NULL;
+  }
 
   // Make a vertically stacked view of all the panels we want to display in the
   // dialog.
@@ -86,14 +91,13 @@ AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window,
   dialog_body_->ClipHeightTo(kMaxDialogHeight, kMaxDialogHeight);
   dialog_body_->SetContents(dialog_body_contents);
 
-  layout->StartRow(0, kColumnSetId);
-  layout->AddView(dialog_header_);
+  AddChildView(dialog_header_);
 
-  layout->StartRow(1, kColumnSetId);
-  layout->AddView(dialog_body_);
+  AddChildView(dialog_body_);
+  layout->SetFlexForView(dialog_body_, 1);
 
-  layout->StartRow(0, kColumnSetId);
-  layout->AddView(dialog_footer_);
+  if (dialog_footer_)
+    AddChildView(dialog_footer_);
 }
 
 AppInfoDialog::~AppInfoDialog() {