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/ui/views/fullscreen_exit_bubble_views.h" | 5 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/ui/views/bubble/bubble.h" | |
11 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
12 #include "ui/base/animation/slide_animation.h" | 11 #include "ui/base/animation/slide_animation.h" |
13 #include "ui/base/keycodes/keyboard_codes.h" | 12 #include "ui/base/keycodes/keyboard_codes.h" |
14 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
15 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/gfx/canvas_skia.h" | 15 #include "ui/gfx/canvas_skia.h" |
17 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
18 #include "views/bubble/bubble_border.h" | 17 #include "views/bubble/bubble_border.h" |
19 #include "views/controls/button/text_button.h" | 18 #include "views/controls/button/text_button.h" |
20 #include "views/controls/link.h" | 19 #include "views/controls/link.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 #if !defined(OS_CHROMEOS) | 73 #if !defined(OS_CHROMEOS) |
75 browser_fullscreen_exit_text_ = | 74 browser_fullscreen_exit_text_ = |
76 l10n_util::GetStringFUTF16(IDS_EXIT_FULLSCREEN_MODE, accelerator); | 75 l10n_util::GetStringFUTF16(IDS_EXIT_FULLSCREEN_MODE, accelerator); |
77 #else | 76 #else |
78 browser_fullscreen_exit_text_ = | 77 browser_fullscreen_exit_text_ = |
79 l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE); | 78 l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE); |
80 #endif | 79 #endif |
81 | 80 |
82 views::BubbleBorder* bubble_border = | 81 views::BubbleBorder* bubble_border = |
83 new views::BubbleBorder(views::BubbleBorder::NONE); | 82 new views::BubbleBorder(views::BubbleBorder::NONE); |
84 bubble_border->set_background_color(Bubble::kBackgroundColor); | |
85 set_background(new views::BubbleBackground(bubble_border)); | 83 set_background(new views::BubbleBackground(bubble_border)); |
86 set_border(bubble_border); | 84 set_border(bubble_border); |
87 set_focusable(false); | 85 set_focusable(false); |
88 | 86 |
89 message_label_.set_parent_owned(false); | 87 message_label_.set_parent_owned(false); |
90 message_label_.SetFont(ResourceBundle::GetSharedInstance().GetFont( | 88 message_label_.SetFont(ResourceBundle::GetSharedInstance().GetFont( |
91 ResourceBundle::MediumFont)); | 89 ResourceBundle::MediumFont)); |
92 | 90 |
93 link_.set_parent_owned(false); | 91 link_.set_parent_owned(false); |
94 link_.set_collapse_when_hidden(false); | 92 link_.set_collapse_when_hidden(false); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 size_animation_->Reset(1); | 214 size_animation_->Reset(1); |
217 | 215 |
218 // Create the contents view. | 216 // Create the contents view. |
219 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); | 217 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); |
220 bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); | 218 bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); |
221 DCHECK(got_accelerator); | 219 DCHECK(got_accelerator); |
222 view_ = new FullscreenExitView( | 220 view_ = new FullscreenExitView( |
223 this, accelerator.GetShortcutText(), url, bubble_type_); | 221 this, accelerator.GetShortcutText(), url, bubble_type_); |
224 | 222 |
225 // Initialize the popup. | 223 // Initialize the popup. |
226 popup_ = new views::Widget; | 224 popup_ = new views::Widget; |
msw
2011/11/16 22:05:40
This wouldn't be necessary if we used the views bu
yzshen1
2011/11/17 00:55:45
Done.
| |
227 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 225 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
228 params.transparent = true; | 226 params.transparent = true; |
229 params.can_activate = false; | 227 params.can_activate = false; |
230 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 228 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
231 params.parent = frame->GetNativeView(); | 229 params.parent = frame->GetNativeView(); |
232 params.bounds = GetPopupRect(false); | 230 params.bounds = GetPopupRect(false); |
233 popup_->Init(params); | 231 popup_->Init(params); |
234 gfx::Size size = GetPopupRect(true).size(); | 232 gfx::Size size = GetPopupRect(true).size(); |
235 popup_->SetContentsView(view_); | 233 popup_->SetContentsView(view_); |
236 // We set layout manager to NULL to prevent the widget from sizing its | 234 // We set layout manager to NULL to prevent the widget from sizing its |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 size.set_height(size.height() - popup_bottom + y_offset); | 345 size.set_height(size.height() - popup_bottom + y_offset); |
348 origin.set_y(origin.y() - y_offset); | 346 origin.set_y(origin.y() - y_offset); |
349 } | 347 } |
350 return gfx::Rect(origin, size); | 348 return gfx::Rect(origin, size); |
351 } | 349 } |
352 | 350 |
353 void FullscreenExitBubbleViews::StartWatchingMouseIfNecessary() { | 351 void FullscreenExitBubbleViews::StartWatchingMouseIfNecessary() { |
354 if (!fullscreen_bubble::ShowButtonsForType(bubble_type_)) | 352 if (!fullscreen_bubble::ShowButtonsForType(bubble_type_)) |
355 StartWatchingMouse(); | 353 StartWatchingMouse(); |
356 } | 354 } |
OLD | NEW |