diff options
author | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-21 17:28:22 +0000 |
---|---|---|
committer | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-21 17:28:22 +0000 |
commit | 620e11385a009f495dfb26cf88434dfe35c756c5 (patch) | |
tree | 2b8f64ccf778da681c057fbc84d6fe09b8fdc34c | |
parent | 84e8f71e8ec86ef64124b415c782dbdb1fd003ea (diff) | |
download | chromium_src-620e11385a009f495dfb26cf88434dfe35c756c5.zip chromium_src-620e11385a009f495dfb26cf88434dfe35c756c5.tar.gz chromium_src-620e11385a009f495dfb26cf88434dfe35c756c5.tar.bz2 |
Recreate the date and time menu each time it is opened.
The menu was previously only created once. If it was created on the login or lock screen the option to edit date and time options would never be available even after logging in.
BUG=109678
TEST=Open proxy menu from login or lock screen, no option to open date and time options. Open when logged in and can edit date and time options.
Review URL: https://chromiumcodereview.appspot.com/9226021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118622 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/status/clock_menu_button.cc | 26 | ||||
-rw-r--r-- | chrome/browser/chromeos/status/clock_menu_button.h | 10 |
2 files changed, 16 insertions, 20 deletions
diff --git a/chrome/browser/chromeos/status/clock_menu_button.cc b/chrome/browser/chromeos/status/clock_menu_button.cc index b4e3279..ed5e6ae 100644 --- a/chrome/browser/chromeos/status/clock_menu_button.cc +++ b/chrome/browser/chromeos/status/clock_menu_button.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,6 +7,7 @@ #include "chrome/browser/chromeos/status/clock_menu_button.h" +#include "base/basictypes.h" #include "base/i18n/time_formatting.h" #include "base/string_util.h" #include "base/time.h" @@ -166,16 +167,17 @@ void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { // View passed in must be a views::MenuButton, i.e. the ClockMenuButton. DCHECK_EQ(source, this); - EnsureMenu(); + scoped_ptr<views::MenuRunner> menu_runner(CreateMenu()); gfx::Point screen_location; views::View::ConvertPointToScreen(source, &screen_location); gfx::Rect bounds(screen_location, source->size()); - if (menu_runner_->RunMenuAt( - source->GetWidget()->GetTopLevelWidget(), this, bounds, - views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) == - views::MenuRunner::MENU_DELETED) - return; + ignore_result(menu_runner->RunMenuAt( + source->GetWidget()->GetTopLevelWidget(), + this, + bounds, + views::MenuItemView::TOPRIGHT, + views::MenuRunner::HAS_MNEMONICS)); } // ClockMenuButton, views::View implementation: @@ -184,13 +186,10 @@ void ClockMenuButton::OnLocaleChanged() { UpdateText(); } -void ClockMenuButton::EnsureMenu() { - if (menu_runner_.get()) - return; - +views::MenuRunner* ClockMenuButton::CreateMenu() { views::MenuItemView* menu = new views::MenuItemView(this); - // menu_runner_ takes ownership of menu. - menu_runner_.reset(new views::MenuRunner(menu)); + // menu_runner takes ownership of menu. + views::MenuRunner* menu_runner = new views::MenuRunner(menu); // Text for this item will be set by GetLabel(). menu->AppendDelegateMenuItem(CLOCK_DISPLAY_ITEM); @@ -205,4 +204,5 @@ void ClockMenuButton::EnsureMenu() { menu->AppendMenuItemWithLabel(CLOCK_OPEN_OPTIONS_ITEM, clock_open_options_label); } + return menu_runner; } diff --git a/chrome/browser/chromeos/status/clock_menu_button.h b/chrome/browser/chromeos/status/clock_menu_button.h index 92a6949..9051f0a 100644 --- a/chrome/browser/chromeos/status/clock_menu_button.h +++ b/chrome/browser/chromeos/status/clock_menu_button.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -64,17 +64,13 @@ class ClockMenuButton : public StatusAreaButton, // Sets default use 24hour clock mode. void SetUse24HourClock(bool use_24hour_clock); - // Create and initialize menu if not already present. - void EnsureMenu(); + // Create menu and return menu runner. + views::MenuRunner* CreateMenu(); // Updates text and schedules the timer to fire at the next minute interval. void UpdateTextAndSetNextTimer(); base::OneShotTimer<ClockMenuButton> timer_; - - // The clock menu. - scoped_ptr<views::MenuRunner> menu_runner_; - PrefService* pref_service_; scoped_ptr<PrefChangeRegistrar> registrar_; |