OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
12 #include "grit/ui_strings.h" | 12 #include "grit/ui_strings.h" |
13 #include "ui/base/animation/slide_animation.h" | 13 #include "ui/base/animation/slide_animation.h" |
14 #include "ui/base/keycodes/keyboard_codes.h" | 14 #include "ui/base/keycodes/keyboard_codes.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
19 #include "ui/views/bubble/bubble_border.h" | 19 #include "ui/views/bubble/bubble_border.h" |
20 #include "ui/views/controls/button/text_button.h" | 20 #include "ui/views/controls/button/label_button.h" |
21 #include "ui/views/controls/link.h" | 21 #include "ui/views/controls/link.h" |
22 #include "ui/views/controls/link_listener.h" | 22 #include "ui/views/controls/link_listener.h" |
23 #include "ui/views/layout/box_layout.h" | 23 #include "ui/views/layout/box_layout.h" |
24 #include "ui/views/layout/grid_layout.h" | 24 #include "ui/views/layout/grid_layout.h" |
25 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
26 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
27 | 27 |
28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 #include "ui/base/l10n/l10n_util_win.h" | 29 #include "ui/base/l10n/l10n_util_win.h" |
30 #endif | 30 #endif |
31 | 31 |
32 // FullscreenExitView ---------------------------------------------------------- | 32 // FullscreenExitView ---------------------------------------------------------- |
33 | 33 |
34 namespace { | 34 namespace { |
35 | |
35 // Space between the site info label and the buttons / link. | 36 // Space between the site info label and the buttons / link. |
36 const int kMiddlePaddingPx = 30; | 37 const int kMiddlePaddingPx = 30; |
37 | 38 |
38 class ButtonView : public views::View { | 39 class ButtonView : public views::View { |
39 public: | 40 public: |
40 ButtonView(views::ButtonListener* listener, int between_button_spacing); | 41 ButtonView(views::ButtonListener* listener, int between_button_spacing); |
41 virtual ~ButtonView(); | 42 virtual ~ButtonView(); |
42 | 43 |
43 // Returns an empty size when the view is not visible. | 44 // Returns an empty size when the view is not visible. |
44 virtual gfx::Size GetPreferredSize() OVERRIDE; | 45 virtual gfx::Size GetPreferredSize() OVERRIDE; |
45 | 46 |
46 views::NativeTextButton* accept_button() const { return accept_button_; } | 47 views::LabelButton* accept_button() { return accept_button_; } |
47 views::NativeTextButton* deny_button() const { return deny_button_; } | 48 views::LabelButton* deny_button() { return deny_button_; } |
48 | 49 |
49 private: | 50 private: |
50 views::NativeTextButton* accept_button_; | 51 views::LabelButton* accept_button_; |
51 views::NativeTextButton* deny_button_; | 52 views::LabelButton* deny_button_; |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(ButtonView); | |
52 }; | 55 }; |
53 | 56 |
54 ButtonView::ButtonView(views::ButtonListener* listener, | 57 ButtonView::ButtonView(views::ButtonListener* listener, |
55 int between_button_spacing) : accept_button_(NULL), | 58 int between_button_spacing) |
56 deny_button_(NULL) { | 59 : accept_button_(NULL), |
57 accept_button_ = new views::NativeTextButton(listener); | 60 deny_button_(NULL) { |
61 accept_button_ = new views::LabelButton(listener, string16()); | |
62 accept_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
58 accept_button_->set_focusable(false); | 63 accept_button_->set_focusable(false); |
59 AddChildView(accept_button_); | 64 AddChildView(accept_button_); |
60 | 65 |
61 deny_button_ = new views::NativeTextButton(listener); | 66 deny_button_ = new views::LabelButton(listener, string16()); |
67 deny_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
62 deny_button_->set_focusable(false); | 68 deny_button_->set_focusable(false); |
63 AddChildView(deny_button_); | 69 AddChildView(deny_button_); |
64 | 70 |
65 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 71 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
66 between_button_spacing)); | 72 between_button_spacing)); |
67 } | 73 } |
68 | 74 |
69 ButtonView::~ButtonView() { | 75 ButtonView::~ButtonView() { |
70 } | 76 } |
71 | 77 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 const GURL& url, | 211 const GURL& url, |
206 FullscreenExitBubbleType bubble_type) { | 212 FullscreenExitBubbleType bubble_type) { |
207 DCHECK_NE(FEB_TYPE_NONE, bubble_type); | 213 DCHECK_NE(FEB_TYPE_NONE, bubble_type); |
208 | 214 |
209 message_label_->SetText(bubble_->GetCurrentMessageText()); | 215 message_label_->SetText(bubble_->GetCurrentMessageText()); |
210 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) { | 216 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) { |
211 link_->SetVisible(false); | 217 link_->SetVisible(false); |
212 mouse_lock_exit_instruction_->SetVisible(false); | 218 mouse_lock_exit_instruction_->SetVisible(false); |
213 button_view_->SetVisible(true); | 219 button_view_->SetVisible(true); |
214 button_view_->deny_button()->SetText(bubble_->GetCurrentDenyButtonText()); | 220 button_view_->deny_button()->SetText(bubble_->GetCurrentDenyButtonText()); |
215 button_view_->deny_button()->ClearMaxTextSize(); | 221 button_view_->deny_button()->set_max_size(gfx::Size()); |
msw
2013/04/04 02:31:03
It's a little confusing, but the TextButton::Clear
tfarina
2013/04/04 22:36:52
Removed.
msw
2013/04/04 22:41:16
Incorrect; it should be changed to set_min_size(gf
tfarina
2013/04/05 00:10:38
Done.
| |
216 } else { | 222 } else { |
217 bool link_visible = true; | 223 bool link_visible = true; |
218 string16 accelerator; | 224 string16 accelerator; |
219 if (bubble_type == FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION || | 225 if (bubble_type == FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION || |
220 bubble_type == FEB_TYPE_BROWSER_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) { | 226 bubble_type == FEB_TYPE_BROWSER_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) { |
221 accelerator = browser_fullscreen_exit_accelerator_; | 227 accelerator = browser_fullscreen_exit_accelerator_; |
222 } else if (bubble_type == FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION) { | 228 } else if (bubble_type == FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION) { |
223 accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY); | 229 accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY); |
224 } else { | 230 } else { |
225 link_visible = false; | 231 link_visible = false; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 } | 389 } |
384 | 390 |
385 bool FullscreenExitBubbleViews::IsAnimating() { | 391 bool FullscreenExitBubbleViews::IsAnimating() { |
386 return size_animation_->GetCurrentValue() != 0; | 392 return size_animation_->GetCurrentValue() != 0; |
387 } | 393 } |
388 | 394 |
389 void FullscreenExitBubbleViews::StartWatchingMouseIfNecessary() { | 395 void FullscreenExitBubbleViews::StartWatchingMouseIfNecessary() { |
390 if (!fullscreen_bubble::ShowButtonsForType(bubble_type_)) | 396 if (!fullscreen_bubble::ShowButtonsForType(bubble_type_)) |
391 StartWatchingMouse(); | 397 StartWatchingMouse(); |
392 } | 398 } |
OLD | NEW |