| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/status/power_menu_button.h" | 5 #include "chrome/browser/chromeos/status/power_menu_button.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 // TODO(rhashimoto): Remove this workaround when WebUI provides a | 131 // TODO(rhashimoto): Remove this workaround when WebUI provides a |
| 132 // top-level widget on the ChromeOS login screen that is a window. | 132 // top-level widget on the ChromeOS login screen that is a window. |
| 133 // The current BackgroundView class for the ChromeOS login screen | 133 // The current BackgroundView class for the ChromeOS login screen |
| 134 // creates a owning Widget that has a native GtkWindow but is not a | 134 // creates a owning Widget that has a native GtkWindow but is not a |
| 135 // Window. This makes it impossible to get the NativeWindow via | 135 // Window. This makes it impossible to get the NativeWindow via |
| 136 // the views API. This workaround casts the top-level NativeWidget | 136 // the views API. This workaround casts the top-level NativeWidget |
| 137 // to a NativeWindow that we can pass to MenuItemView::RunMenuAt(). | 137 // to a NativeWindow that we can pass to MenuItemView::RunMenuAt(). |
| 138 gfx::NativeWindow window = GTK_WINDOW(source->GetWidget()->GetNativeView()); | 138 gfx::NativeWindow window = GTK_WINDOW(source->GetWidget()->GetNativeView()); |
| 139 | 139 |
| 140 gfx::Point screen_loc; | 140 gfx::Point screen_location; |
| 141 views::View::ConvertPointToScreen(source, &screen_loc); | 141 views::View::ConvertPointToScreen(source, &screen_location); |
| 142 gfx::Rect bounds(screen_loc, source->size()); | 142 gfx::Rect bounds(screen_location, source->size()); |
| 143 menu_->RunMenuAt( | 143 menu_->RunMenuAt( |
| 144 window, | 144 window, |
| 145 this, | 145 this, |
| 146 bounds, | 146 bounds, |
| 147 views::MenuItemView::TOPRIGHT, | 147 views::MenuItemView::TOPRIGHT, |
| 148 true); | 148 true); |
| 149 } | 149 } |
| 150 | 150 |
| 151 //////////////////////////////////////////////////////////////////////////////// | 151 //////////////////////////////////////////////////////////////////////////////// |
| 152 // PowerMenuButton, PowerLibrary::Observer implementation: | 152 // PowerMenuButton, PowerLibrary::Observer implementation: |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 menu_->AppendDelegateMenuItem(POWER_BATTERY_IS_CHARGED_ITEM); | 260 menu_->AppendDelegateMenuItem(POWER_BATTERY_IS_CHARGED_ITEM); |
| 261 } else { | 261 } else { |
| 262 menu_->AppendMenuItemWithLabel( | 262 menu_->AppendMenuItemWithLabel( |
| 263 POWER_NO_BATTERY, | 263 POWER_NO_BATTERY, |
| 264 UTF16ToWide(l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_BATTERY))); | 264 UTF16ToWide(l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_BATTERY))); |
| 265 } | 265 } |
| 266 menu_->ChildrenChanged(); | 266 menu_->ChildrenChanged(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace chromeos | 269 } // namespace chromeos |
| OLD | NEW |