| 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/setting_level_bubble.h" | 5 #include "chrome/browser/chromeos/setting_level_bubble.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 | 8 |
| 9 #include "base/timer.h" | 9 #include "base/timer.h" |
| 10 #include "chrome/browser/chromeos/login/background_view.h" | 10 #include "chrome/browser/chromeos/login/background_view.h" |
| 11 #include "chrome/browser/chromeos/login/login_utils.h" | 11 #include "chrome/browser/chromeos/login/login_utils.h" |
| 12 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 12 #include "chrome/browser/chromeos/setting_level_bubble_view.h" | 13 #include "chrome/browser/chromeos/setting_level_bubble_view.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/views/bubble/bubble.h" | 18 #include "chrome/browser/ui/views/bubble/bubble.h" |
| 18 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
| 19 #include "views/widget/root_view.h" | 20 #include "views/widget/root_view.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 true); // match_incognito | 59 true); // match_incognito |
| 59 if (browser) { | 60 if (browser) { |
| 60 window = GTK_WINDOW(browser->window()->GetNativeHandle()); | 61 window = GTK_WINDOW(browser->window()->GetNativeHandle()); |
| 61 } else { | 62 } else { |
| 62 // Otherwise, see if there's a background window that we can use. | 63 // Otherwise, see if there's a background window that we can use. |
| 63 BackgroundView* background = LoginUtils::Get()->GetBackgroundView(); | 64 BackgroundView* background = LoginUtils::Get()->GetBackgroundView(); |
| 64 if (background) | 65 if (background) |
| 65 window = GTK_WINDOW(background->GetNativeWindow()); | 66 window = GTK_WINDOW(background->GetNativeWindow()); |
| 66 } | 67 } |
| 67 | 68 |
| 68 if (!window) | 69 if (window) |
| 69 return NULL; | 70 return views::Widget::GetWidgetForNativeWindow(window); |
| 70 | 71 else |
| 71 return views::Widget::GetWidgetForNativeWindow(window); | 72 return WebUILoginDisplay::GetLoginWindow(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 SettingLevelBubble::SettingLevelBubble(SkBitmap* increase_icon, | 75 SettingLevelBubble::SettingLevelBubble(SkBitmap* increase_icon, |
| 75 SkBitmap* decrease_icon, | 76 SkBitmap* decrease_icon, |
| 76 SkBitmap* zero_icon) | 77 SkBitmap* zero_icon) |
| 77 : previous_percent_(-1), | 78 : previous_percent_(-1), |
| 78 current_percent_(-1), | 79 current_percent_(-1), |
| 79 increase_icon_(increase_icon), | 80 increase_icon_(increase_icon), |
| 80 decrease_icon_(decrease_icon), | 81 decrease_icon_(decrease_icon), |
| 81 zero_icon_(zero_icon), | 82 zero_icon_(zero_icon), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 95 current_percent_ = percent; | 96 current_percent_ = percent; |
| 96 | 97 |
| 97 SkBitmap* icon = increase_icon_; | 98 SkBitmap* icon = increase_icon_; |
| 98 if (current_percent_ == 0) | 99 if (current_percent_ == 0) |
| 99 icon = zero_icon_; | 100 icon = zero_icon_; |
| 100 else if (current_percent_ < previous_percent_) | 101 else if (current_percent_ < previous_percent_) |
| 101 icon = decrease_icon_; | 102 icon = decrease_icon_; |
| 102 | 103 |
| 103 if (!bubble_) { | 104 if (!bubble_) { |
| 104 views::Widget* parent_widget = GetToplevelWidget(); | 105 views::Widget* parent_widget = GetToplevelWidget(); |
| 105 if (parent_widget == NULL) | 106 if (parent_widget == NULL) { |
| 107 LOG(WARNING) << "Unable to locate parent widget to display a bubble"; |
| 106 return; | 108 return; |
| 109 } |
| 107 DCHECK(view_ == NULL); | 110 DCHECK(view_ == NULL); |
| 108 view_ = new SettingLevelBubbleView; | 111 view_ = new SettingLevelBubbleView; |
| 109 view_->Init(icon, previous_percent_); | 112 view_->Init(icon, previous_percent_); |
| 110 | 113 |
| 111 // Calculate the position in screen coordinates that the bubble should | 114 // Calculate the position in screen coordinates that the bubble should |
| 112 // "point" at (since we use BubbleBorder::FLOAT, this position actually | 115 // "point" at (since we use BubbleBorder::FLOAT, this position actually |
| 113 // specifies the center of the bubble). | 116 // specifies the center of the bubble). |
| 114 const gfx::Rect monitor_area = | 117 const gfx::Rect monitor_area = |
| 115 gfx::Screen::GetMonitorAreaNearestWindow( | 118 gfx::Screen::GetMonitorAreaNearestWindow( |
| 116 GTK_WIDGET(parent_widget->GetNativeWindow())); | 119 GTK_WIDGET(parent_widget->GetNativeWindow())); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 void SettingLevelBubble::AnimationProgressed(const ui::Animation* animation) { | 192 void SettingLevelBubble::AnimationProgressed(const ui::Animation* animation) { |
| 190 if (view_) { | 193 if (view_) { |
| 191 view_->Update( | 194 view_->Update( |
| 192 ui::Tween::ValueBetween(animation->GetCurrentValue(), | 195 ui::Tween::ValueBetween(animation->GetCurrentValue(), |
| 193 previous_percent_, | 196 previous_percent_, |
| 194 current_percent_)); | 197 current_percent_)); |
| 195 } | 198 } |
| 196 } | 199 } |
| 197 | 200 |
| 198 } // namespace chromeos | 201 } // namespace chromeos |
| OLD | NEW |