Merge from Chromium at DEPS revision r198571

This commit was generated by merge_to_master.py.

Change-Id: I951118a03836157090561764dd2627f0add8118f
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc
index 51f68c1..f37b05c 100644
--- a/ash/launcher/launcher.cc
+++ b/ash/launcher/launcher.cc
@@ -13,6 +13,7 @@
 #include "ash/launcher/launcher_navigator.h"
 #include "ash/launcher/launcher_view.h"
 #include "ash/root_window_controller.h"
+#include "ash/screen_ash.h"
 #include "ash/shelf/shelf_layout_manager.h"
 #include "ash/shelf/shelf_widget.h"
 #include "ash/shell.h"
@@ -35,15 +36,10 @@
 #include "ui/views/widget/widget.h"
 #include "ui/views/widget/widget_delegate.h"
 
-namespace {
-// Size of black border at bottom (or side) of launcher.
-const int kNumBlackPixels = 3;
-// Alpha to paint dimming image with.
-const int kDimAlpha = 96;
-}
-
 namespace ash {
 
+const char Launcher::kNativeViewName[] = "LauncherView";
+
 Launcher::Launcher(LauncherModel* launcher_model,
                    LauncherDelegate* launcher_delegate,
                    ShelfWidget* shelf_widget)
@@ -55,12 +51,14 @@
       launcher_model, delegate_, shelf_widget_->shelf_layout_manager());
   launcher_view_->Init();
   shelf_widget_->GetContentsView()->AddChildView(launcher_view_);
-  shelf_widget_->GetNativeView()->SetName("LauncherView");
+  shelf_widget_->GetNativeView()->SetName(kNativeViewName);
   shelf_widget_->GetNativeView()->SetProperty(
       internal::kStayInSameRootWindowKey, true);
+  delegate_->OnLauncherCreated(this);
 }
 
 Launcher::~Launcher() {
+  delegate_->OnLauncherDestroyed(this);
 }
 
 // static
@@ -98,17 +96,36 @@
 void Launcher::UpdateIconPositionForWindow(aura::Window* window) {
   launcher_view_->UpdatePanelIconPosition(
       delegate_->GetIDByWindow(window),
-      window->bounds().CenterPoint());
+      ash::ScreenAsh::ConvertRectFromScreen(
+          shelf_widget()->GetNativeView(),
+          window->GetBoundsInScreen()).CenterPoint());
 }
 
 void Launcher::ActivateLauncherItem(int index) {
+  // We pass in a keyboard event which will then trigger a switch to the
+  // next item if the current one is already active.
+  ui::KeyEvent event(ui::ET_KEY_RELEASED,
+                     ui::VKEY_UNKNOWN,  // The actual key gets ignored.
+                     ui::EF_NONE,
+                     false);
+  // TODO(skuhne): Remove this temporary fix once M28 is out and CL 11596003
+  // has landed. Note that all unit tests which use this function need to remove
+  // the "kChromeItemOffset" as well.
+  // Note: The index gets only decremented for the per app instance of the
+  // launcher. The old per browser launcher does not get impacted here.
+  if (delegate_->IsPerAppLauncher() && --index <= 0) {
+    LauncherItem item;
+    // Create a fake launcher item with an invalid ID so that
+    // our ChromeLauncherControllerPerApp can handle it accordingly. This is
+    // only a temporary fix until CL 11596003 has landed.
+    item.id = ash::kAppIdForBrowserSwitching;
+    delegate_->ItemSelected(item, event);
+    return;
+  }
+
   const ash::LauncherItems& items =
       launcher_view_->model()->items();
-  ui::MouseEvent event(ui::ET_MOUSE_PRESSED,
-                       gfx::Point(),
-                       gfx::Point(),
-                       ui::EF_NONE);
-  delegate_->ItemClicked(items[index], event);
+  delegate_->ItemSelected(items[index], event);
 }
 
 void Launcher::CycleWindowLinear(CycleDirection direction) {
@@ -171,9 +188,10 @@
   // found (which is true when indexes_left is -1) or b.) the last item was
   // requested (which is true when index was passed in as a negative number).
   if (found_index >= 0 && (indexes_left == -1 || window_index < 0) &&
-      (items[found_index].status == ash::STATUS_RUNNING ||
-       items[found_index].status == ash::STATUS_CLOSED)) {
-    // Then set this one as active.
+      (delegate_->IsPerAppLauncher() ||
+       (items[found_index].status == ash::STATUS_RUNNING ||
+        items[found_index].status == ash::STATUS_CLOSED))) {
+    // Then set this one as active (or advance to the next item of its kind).
     ActivateLauncherItem(found_index);
   }
 }
diff --git a/ash/launcher/launcher.h b/ash/launcher/launcher.h
index 8c61ce3..7d7f3cd 100644
--- a/ash/launcher/launcher.h
+++ b/ash/launcher/launcher.h
@@ -40,6 +40,8 @@
 
 class ASH_EXPORT Launcher {
  public:
+  static const char kNativeViewName[];
+
   Launcher(LauncherModel* launcher_model,
            LauncherDelegate* launcher_delegate,
            ShelfWidget* shelf_widget);
diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc
index 546a145..78fc815 100644
--- a/ash/launcher/launcher_button.cc
+++ b/ash/launcher/launcher_button.cc
@@ -79,7 +79,7 @@
 
  private:
   LauncherButtonAnimation()
-    : ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)) {
+      : animation_(this) {
     animation_.SetThrobDuration(kAttentionThrobDurationMS);
     animation_.SetTweenType(ui::Tween::SMOOTH_IN_OUT);
   }
@@ -96,7 +96,7 @@
   }
 
   // ui::AnimationDelegate
-  void AnimationProgressed(const ui::Animation* animation) {
+  virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE {
     if (animation != &animation_)
       return;
     if (!animation_.is_animating())
@@ -126,7 +126,7 @@
         show_attention_(false) {
   }
 
-  ~BarView() {
+  virtual ~BarView() {
     if (show_attention_)
       LauncherButtonAnimation::GetInstance()->RemoveObserver(this);
   }
@@ -392,17 +392,17 @@
 
 void LauncherButton::Layout() {
   const gfx::Rect button_bounds(GetContentsBounds());
-
-  int x_offset = shelf_layout_manager_->SelectValueForShelfAlignment(
-      0, kIconPad, kIconPad, 0);
-  int y_offset = shelf_layout_manager_->SelectValueForShelfAlignment(
-      kIconPad, 0, 0, kIconPad);
-
-  int icon_width = std::min(kIconSize, button_bounds.width() - x_offset);
-  int icon_height = std::min(kIconSize, button_bounds.height() - y_offset);
-
-  x_offset = std::max(x_offset, (button_bounds.width() - icon_width) / 2);
-  y_offset = std::max(y_offset, (button_bounds.height() - icon_height) / 2);
+   int x_offset = 0, y_offset = 0;
+   gfx::Rect icon_bounds;
+   if (shelf_layout_manager_->IsHorizontalAlignment()) {
+    icon_bounds.SetRect(
+        button_bounds.x(), button_bounds.y() + kIconPad,
+        button_bounds.width(), kIconSize);
+  } else {
+    icon_bounds.SetRect(
+        button_bounds.x() + kIconPad, button_bounds.y(),
+        kIconSize, button_bounds.height());
+  }
 
   if (ShouldHop(state_)) {
     x_offset += shelf_layout_manager_->SelectValueForShelfAlignment(
@@ -411,11 +411,7 @@
         -kHopSpacing, 0, 0, kHopSpacing);
   }
 
-  gfx::Rect icon_bounds(
-        button_bounds.x() + x_offset,
-        button_bounds.y() + y_offset,
-        icon_width,
-        icon_height);
+  icon_bounds.Offset(x_offset, y_offset);
   icon_view_->SetBoundsRect(icon_bounds);
   bar_->SetBarBoundsRect(GetContentsBounds());
   UpdateState();
diff --git a/ash/launcher/launcher_button_host.h b/ash/launcher/launcher_button_host.h
index 37ed07a..ecb76a3 100644
--- a/ash/launcher/launcher_button_host.h
+++ b/ash/launcher/launcher_button_host.h
@@ -54,7 +54,7 @@
   virtual void MouseExitedButton(views::View* view) = 0;
 
   // Invoked to get the accessible name of the item.
-  virtual string16 GetAccessibleName(const views::View* view) = 0;
+  virtual base::string16 GetAccessibleName(const views::View* view) = 0;
 
  protected:
   virtual ~LauncherButtonHost() {}
diff --git a/ash/launcher/launcher_delegate.h b/ash/launcher/launcher_delegate.h
index 5ca045e..45109e8 100644
--- a/ash/launcher/launcher_delegate.h
+++ b/ash/launcher/launcher_delegate.h
@@ -19,6 +19,12 @@
 }
 
 namespace ash {
+class Launcher;
+
+// When passed to LauncherDelegate::ItemSelected, the browser item will be
+// addressed for switching.
+// TODO(skuhne): Remove this constant once CL 11596003 has landed.
+const LauncherID kAppIdForBrowserSwitching = -1;
 
 // A special menu model which keeps track of an "active" menu item.
 class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel {
@@ -48,16 +54,18 @@
   // Invoked when the user clicks on a window entry in the launcher.
   // |event| is the click event. The |event| is dispatched by a view
   // and has an instance of |views::View| as the event target
-  // but not |aura::Window|.
-  virtual void ItemClicked(const LauncherItem& item,
-                           const ui::Event& event) = 0;
+  // but not |aura::Window|. If the |event| is of type KeyEvent, it is assumed
+  // that this was triggered by keyboard action (Alt+<number>) and special
+  // handling might happen (PerApp launcher).
+  virtual void ItemSelected(const LauncherItem& item,
+                            const ui::Event& event) = 0;
 
   // Returns the resource id of the image to show on the browser shortcut
   // button.
   virtual int GetBrowserShortcutResourceId() = 0;
 
   // Returns the title to display for the specified launcher item.
-  virtual string16 GetTitle(const LauncherItem& item) = 0;
+  virtual base::string16 GetTitle(const LauncherItem& item) = 0;
 
   // Returns the context menumodel for the specified item on
   // |root_window|.  Return NULL if there should be no context
@@ -87,6 +95,17 @@
 
   // Returns true if a tooltip should be shown for the item.
   virtual bool ShouldShowTooltip(const LauncherItem& item) = 0;
+
+  // Callback used to allow delegate to perform initialization actions that
+  // depend on the Launcher being in a known state.
+  virtual void OnLauncherCreated(Launcher* launcher) = 0;
+
+  // Callback used to inform the delegate that a specific launcher no longer
+  // exists.
+  virtual void OnLauncherDestroyed(Launcher* launcher) = 0;
+
+  // True if the running launcher is the per application launcher.
+  virtual bool IsPerAppLauncher() = 0;
 };
 
 }  // namespace ash
diff --git a/ash/launcher/launcher_model.h b/ash/launcher/launcher_model.h
index 3e2ba59..0d54486 100644
--- a/ash/launcher/launcher_model.h
+++ b/ash/launcher/launcher_model.h
@@ -45,7 +45,7 @@
   void Set(int index, const LauncherItem& item);
 
   // Returns the index of the item by id.
-  int ItemIndexByID(int id) const;
+  int ItemIndexByID(LauncherID id) const;
 
   // Returns the index of the first panel or the index where the first panel
   // would go if there are no panels.
diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc
index 12bdf33..0363a0d 100644
--- a/ash/launcher/launcher_tooltip_manager.cc
+++ b/ash/launcher/launcher_tooltip_manager.cc
@@ -50,10 +50,10 @@
     : public views::BubbleDelegateView {
  public:
   LauncherTooltipBubble(views::View* anchor,
-                        views::BubbleBorder::ArrowLocation arrow_location,
+                        views::BubbleBorder::Arrow arrow,
                         LauncherTooltipManager* host);
 
-  void SetText(const string16& text);
+  void SetText(const base::string16& text);
   void Close();
 
  private:
@@ -71,9 +71,9 @@
 
 LauncherTooltipManager::LauncherTooltipBubble::LauncherTooltipBubble(
     views::View* anchor,
-    views::BubbleBorder::ArrowLocation arrow_location,
+    views::BubbleBorder::Arrow arrow,
     LauncherTooltipManager* host)
-    : views::BubbleDelegateView(anchor, arrow_location),
+    : views::BubbleDelegateView(anchor, arrow),
       host_(host) {
   gfx::Insets insets = gfx::Insets(kArrowOffsetTopBottom,
                                    kArrowOffsetLeftRight,
@@ -84,7 +84,7 @@
   if (anchor->border())
     insets += anchor->border()->GetInsets();
 
-  set_anchor_insets(insets);
+  set_anchor_view_insets(insets);
   set_close_on_esc(false);
   set_close_on_deactivate(false);
   set_use_focusless(true);
@@ -109,7 +109,7 @@
 }
 
 void LauncherTooltipManager::LauncherTooltipBubble::SetText(
-    const string16& text) {
+    const base::string16& text) {
   label_->SetText(text);
   SizeToContents();
 }
@@ -160,7 +160,7 @@
 }
 
 void LauncherTooltipManager::ShowDelayed(views::View* anchor,
-                                         const string16& text) {
+                                         const base::string16& text) {
   if (view_) {
     if (timer_.get() && timer_->IsRunning()) {
       return;
@@ -178,7 +178,7 @@
 }
 
 void LauncherTooltipManager::ShowImmediately(views::View* anchor,
-                                             const string16& text) {
+                                             const base::string16& text) {
   if (view_) {
     if (timer_.get() && timer_->IsRunning())
       StopTimer();
@@ -209,7 +209,7 @@
   }
 }
 
-void LauncherTooltipManager::UpdateArrowLocation() {
+void LauncherTooltipManager::UpdateArrow() {
   if (view_) {
     CancelHidingAnimation();
     Close();
@@ -332,7 +332,7 @@
 }
 
 void LauncherTooltipManager::CloseSoon() {
-  MessageLoopForUI::current()->PostTask(
+  base::MessageLoopForUI::current()->PostTask(
       FROM_HERE,
       base::Bind(&LauncherTooltipManager::Close, base::Unretained(this)));
 }
@@ -345,19 +345,19 @@
 }
 
 void LauncherTooltipManager::CreateBubble(views::View* anchor,
-                                          const string16& text) {
+                                          const base::string16& text) {
   DCHECK(!view_);
 
   anchor_ = anchor;
   text_ = text;
-  views::BubbleBorder::ArrowLocation arrow_location =
+  views::BubbleBorder::Arrow arrow =
       shelf_layout_manager_->SelectValueForShelfAlignment(
           views::BubbleBorder::BOTTOM_CENTER,
           views::BubbleBorder::LEFT_CENTER,
           views::BubbleBorder::RIGHT_CENTER,
           views::BubbleBorder::TOP_CENTER);
 
-  view_ = new LauncherTooltipBubble(anchor, arrow_location, this);
+  view_ = new LauncherTooltipBubble(anchor, arrow, this);
   widget_ = view_->GetWidget();
   view_->SetText(text_);
 
diff --git a/ash/launcher/launcher_tooltip_manager.h b/ash/launcher/launcher_tooltip_manager.h
index c2418f5..a880713 100644
--- a/ash/launcher/launcher_tooltip_manager.h
+++ b/ash/launcher/launcher_tooltip_manager.h
@@ -50,17 +50,17 @@
   void OnBubbleClosed(views::BubbleDelegateView* view);
 
   // Shows the tooltip after a delay.  It also has the appearing animation.
-  void ShowDelayed(views::View* anchor, const string16& text);
+  void ShowDelayed(views::View* anchor, const base::string16& text);
 
   // Shows the tooltip immediately.  It omits the appearing animation.
-  void ShowImmediately(views::View* anchor, const string16& text);
+  void ShowImmediately(views::View* anchor, const base::string16& text);
 
   // Closes the tooltip.
   void Close();
 
   // Changes the arrow location of the tooltip in case that the launcher
   // arrangement has changed.
-  void UpdateArrowLocation();
+  void UpdateArrow();
 
   // Resets the timer for the delayed showing |view_|.  If the timer isn't
   // running, it starts a new timer.
@@ -93,12 +93,12 @@
   void CancelHidingAnimation();
   void CloseSoon();
   void ShowInternal();
-  void CreateBubble(views::View* anchor, const string16& text);
+  void CreateBubble(views::View* anchor, const base::string16& text);
 
   LauncherTooltipBubble* view_;
   views::Widget* widget_;
   views::View* anchor_;
-  string16 text_;
+  base::string16 text_;
   scoped_ptr<base::Timer> timer_;
 
   ShelfLayoutManager* shelf_layout_manager_;
diff --git a/ash/launcher/launcher_tooltip_manager_unittest.cc b/ash/launcher/launcher_tooltip_manager_unittest.cc
index 0cdd373..4ceef35 100644
--- a/ash/launcher/launcher_tooltip_manager_unittest.cc
+++ b/ash/launcher/launcher_tooltip_manager_unittest.cc
@@ -54,12 +54,12 @@
 
   void ShowDelayed() {
     CreateWidget();
-    tooltip_manager_->ShowDelayed(dummy_anchor_.get(), string16());
+    tooltip_manager_->ShowDelayed(dummy_anchor_.get(), base::string16());
   }
 
   void ShowImmediately() {
     CreateWidget();
-    tooltip_manager_->ShowImmediately(dummy_anchor_.get(), string16());
+    tooltip_manager_->ShowImmediately(dummy_anchor_.get(), base::string16());
   }
 
   bool TooltipIsVisible() {
diff --git a/ash/launcher/launcher_util.cc b/ash/launcher/launcher_util.cc
index f41ac7d..f7ba77f 100644
--- a/ash/launcher/launcher_util.cc
+++ b/ash/launcher/launcher_util.cc
@@ -6,11 +6,6 @@
 
 #include "ash/launcher/launcher_model.h"
 #include "ash/launcher/launcher_types.h"
-#include "ash/shell.h"
-#include "ui/aura/client/window_types.h"
-#include "ui/aura/window.h"
-#include "ui/views/view.h"
-#include "ui/views/widget/widget.h"
 
 namespace ash {
 namespace launcher {
@@ -23,20 +18,5 @@
   return -1;
 }
 
-void MoveToEventRootIfPanel(aura::Window* maybe_panel,
-                            const ui::Event& event) {
-  if (maybe_panel->type() != aura::client::WINDOW_TYPE_PANEL)
-    return;
-  views::View* target = static_cast<views::View*>(event.target());
-  aura::RootWindow* target_root =
-      target ? target->GetWidget()->GetNativeView()->GetRootWindow() : NULL;
-  if (target_root && target_root != maybe_panel->GetRootWindow()) {
-    aura::Window* panel_container =
-        ash::Shell::GetContainer(target_root, maybe_panel->parent()->id());
-    // Move the panel to the target launcher.
-    panel_container->AddChild(maybe_panel);
-  }
-}
-
 }  // namespace launcher
 }  // namespace ash
diff --git a/ash/launcher/launcher_util.h b/ash/launcher/launcher_util.h
index 7cdd1f2..89551f0 100644
--- a/ash/launcher/launcher_util.h
+++ b/ash/launcher/launcher_util.h
@@ -7,14 +7,6 @@
 
 #include "ash/ash_export.h"
 
-namespace aura {
-class Window;
-}
-
-namespace ui {
-class Event;
-}
-
 namespace ash {
 class LauncherModel;
 
@@ -23,12 +15,6 @@
 // Return the index of the browser item from a given |launcher_model|.
 ASH_EXPORT int GetBrowserItemIndex(const LauncherModel& launcher_model);
 
-// Move the |maybe_panel| to the root window where the |event| occured if
-// |maybe_panel| is of aura::client::WINDOW_TYPE_PANEL and it's not
-// in the same root window.
-ASH_EXPORT void MoveToEventRootIfPanel(aura::Window* maybe_panel,
-                                       const ui::Event& event);
-
 }  // namespace launcher
 }  // namespace ash
 
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index a7ff127..32e20ec 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -376,7 +376,8 @@
       leading_inset_(kDefaultLeadingInset),
       cancelling_drag_model_changed_(false),
       last_hidden_index_(0),
-      closing_event_time_(base::TimeDelta()) {
+      closing_event_time_(base::TimeDelta()),
+      got_deleted_(NULL) {
   DCHECK(model_);
   bounds_animator_.reset(new views::BoundsAnimator(this));
   bounds_animator_->AddObserver(this);
@@ -389,6 +390,10 @@
 LauncherView::~LauncherView() {
   bounds_animator_->RemoveObserver(this);
   model_->RemoveObserver(this);
+  // If we are inside the MenuRunner, we need to know if we were getting
+  // deleted while it was running.
+  if (got_deleted_)
+    *got_deleted_ = true;
 }
 
 void LauncherView::Init() {
@@ -434,8 +439,8 @@
     if (i >= first_visible_index_ && i <= last_visible_index_)
       view_model_->view_at(i)->Layout();
   }
-  tooltip_->UpdateArrowLocation();
-  if (overflow_bubble_.get())
+  tooltip_->UpdateArrow();
+  if (overflow_bubble_)
     overflow_bubble_->Hide();
 }
 
@@ -670,7 +675,7 @@
     if (overflow_bubble_.get() && overflow_bubble_->IsShowing())
       UpdateOverflowRange(overflow_bubble_->launcher_view());
   } else {
-    if (overflow_bubble_.get())
+    if (overflow_bubble_)
       overflow_bubble_->Hide();
   }
 }
@@ -930,7 +935,7 @@
     return;
   }
 
-  if (!overflow_bubble_.get())
+  if (!overflow_bubble_)
     overflow_bubble_.reset(new OverflowBubble());
 
   LauncherView* overflow_view = new LauncherView(
@@ -1279,11 +1284,11 @@
     tooltip_->StopTimer();
 }
 
-string16 LauncherView::GetAccessibleName(const views::View* view) {
+base::string16 LauncherView::GetAccessibleName(const views::View* view) {
   int view_index = view_model_->GetIndexOfView(view);
   // May be -1 while in the process of animating closed.
   if (view_index == -1)
-    return string16();
+    return base::string16();
 
   switch (model_->items()[view_index].type) {
     case TYPE_TABBED:
@@ -1301,7 +1306,7 @@
     case TYPE_BROWSER_SHORTCUT:
       return Shell::GetInstance()->delegate()->GetProductName();
   }
-  return string16();
+  return base::string16();
 }
 
 void LauncherView::ButtonPressed(views::Button* sender,
@@ -1310,6 +1315,8 @@
   if (dragging())
     return;
 
+  tooltip_->Close();
+
   if (sender == overflow_button_) {
     ToggleOverflowBubble();
     return;
@@ -1325,8 +1332,6 @@
   if (!IsUsableEvent(event))
     return;
 
-  tooltip_->Close();
-
   {
     // Slow down activation animations if shift key is pressed.
     scoped_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations;
@@ -1345,7 +1350,7 @@
       // Fallthrough
     case TYPE_TABBED:
     case TYPE_APP_PANEL:
-      delegate_->ItemClicked(model_->items()[view_index], event);
+      delegate_->ItemSelected(model_->items()[view_index], event);
       break;
 
     case TYPE_APP_LIST:
@@ -1401,7 +1406,7 @@
   scoped_ptr<ui::MenuModel> menu_model(delegate_->CreateContextMenu(
       model_->items()[view_index],
       source->GetWidget()->GetNativeView()->GetRootWindow()));
-  if (!menu_model.get())
+  if (!menu_model)
     return;
   base::AutoReset<LauncherID> reseter(
       &context_menu_id_,
@@ -1428,10 +1433,11 @@
       views::MenuItemView::TOPLEFT;
   gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size());
 
+  ShelfWidget* shelf = RootWindowController::ForLauncher(
+      GetWidget()->GetNativeView())->shelf();
   if (!context_menu) {
     // Application lists use a bubble.
-    ash::ShelfAlignment align = RootWindowController::ForLauncher(
-        GetWidget()->GetNativeView())->shelf()->GetAlignment();
+    ash::ShelfAlignment align = shelf->GetAlignment();
     anchor_point = source->GetBoundsInScreen();
 
     // Launcher items can have an asymmetrical border for spacing reasons.
@@ -1454,6 +1460,12 @@
         break;
     }
   }
+  // If this gets deleted while we are in the menu, the launcher will be gone
+  // as well.
+  bool got_deleted = false;
+  got_deleted_ = &got_deleted;
+
+  shelf->ForceUndimming(true);
   // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building
   // code.
   if (launcher_menu_runner_->RunMenuAt(
@@ -1461,12 +1473,19 @@
           NULL,
           anchor_point,
           menu_alignment,
-          views::MenuRunner::CONTEXT_MENU) == views::MenuRunner::MENU_DELETED)
+          views::MenuRunner::CONTEXT_MENU) == views::MenuRunner::MENU_DELETED) {
+    if (!got_deleted) {
+      got_deleted_ = NULL;
+      shelf->ForceUndimming(false);
+    }
     return;
+  }
+  got_deleted_ = NULL;
+  shelf->ForceUndimming(false);
 
   // Unpinning an item will reset the |launcher_menu_runner_| before coming
   // here.
-  if (launcher_menu_runner_.get())
+  if (launcher_menu_runner_)
     closing_event_time_ = launcher_menu_runner_->closing_event_time();
   Shell::GetInstance()->UpdateShelfVisibility();
 }
diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h
index a3f209e..3b1f0f3 100644
--- a/ash/launcher/launcher_view.h
+++ b/ash/launcher/launcher_view.h
@@ -205,7 +205,7 @@
   virtual void MouseMovedOverButton(views::View* view) OVERRIDE;
   virtual void MouseEnteredButton(views::View* view) OVERRIDE;
   virtual void MouseExitedButton(views::View* view) OVERRIDE;
-  virtual string16 GetAccessibleName(const views::View* view) OVERRIDE;
+  virtual base::string16 GetAccessibleName(const views::View* view) OVERRIDE;
 
   // Overridden from views::ButtonListener:
   virtual void ButtonPressed(views::Button* sender,
@@ -316,6 +316,10 @@
   // The timestamp of the event which closed the last menu - or 0.
   base::TimeDelta closing_event_time_;
 
+  // When this object gets deleted while a menu is shown, this pointed
+  // element will be set to false.
+  bool* got_deleted_;
+
   DISALLOW_COPY_AND_ASSIGN(LauncherView);
 };
 
diff --git a/ash/launcher/overflow_bubble.cc b/ash/launcher/overflow_bubble.cc
index 1fa7255..09613ca 100644
--- a/ash/launcher/overflow_bubble.cc
+++ b/ash/launcher/overflow_bubble.cc
@@ -54,7 +54,7 @@
   }
 
   // Gets arrow location based on shelf alignment.
-  views::BubbleBorder::ArrowLocation GetBubbleArrowLocation() const {
+  views::BubbleBorder::Arrow GetBubbleArrow() const {
     return GetShelfLayoutManagerForLauncher()->SelectValueForShelfAlignment(
         views::BubbleBorder::BOTTOM_LEFT,
         views::BubbleBorder::LEFT_TOP,
@@ -100,7 +100,7 @@
   // set_anchor_view needs to be called before GetShelfLayoutManagerForLauncher
   // can be called.
   set_anchor_view(anchor);
-  set_arrow_location(GetBubbleArrowLocation());
+  set_arrow(GetBubbleArrow());
   set_background(NULL);
   set_color(SkColorSetARGB(kLauncherBackgroundAlpha, 0, 0, 0));
   set_margins(gfx::Insets(kPadding, kPadding, kPadding, kPadding));
@@ -172,10 +172,14 @@
 }
 
 bool OverflowBubbleView::OnMouseWheel(const ui::MouseWheelEvent& event) {
+  // The MouseWheelEvent was changed to support both X and Y offsets
+  // recently, but the behavior of this function was retained to continue
+  // using Y offsets only. Might be good to simply scroll in both
+  // directions as in OverflowBubbleView::OnScrollEvent.
   if (IsHorizontalAlignment())
-    ScrollByXOffset(-event.offset());
+    ScrollByXOffset(-event.y_offset());
   else
-    ScrollByYOffset(-event.offset());
+    ScrollByYOffset(-event.y_offset());
   Layout();
 
   return true;
@@ -193,7 +197,7 @@
   gfx::Insets bubble_insets = border->GetInsets();
 
   const int border_size =
-      views::BubbleBorder::is_arrow_on_horizontal(arrow_location()) ?
+      views::BubbleBorder::is_arrow_on_horizontal(arrow()) ?
       bubble_insets.left() : bubble_insets.top();
   const int arrow_offset = border_size + kPadding + kLauncherViewLeadingInset +
       kLauncherPreferredSize / 2;
@@ -211,7 +215,7 @@
       anchor_rect.CenterPoint()).work_area();
 
   int offset = 0;
-  if (views::BubbleBorder::is_arrow_on_horizontal(arrow_location())) {
+  if (views::BubbleBorder::is_arrow_on_horizontal(arrow())) {
     if (bubble_rect.x() < monitor_rect.x())
       offset = monitor_rect.x() - bubble_rect.x();
     else if (bubble_rect.right() > monitor_rect.right())