Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: ui/views/bubble/bubble_delegate.cc

Issue 8604012: move chromeos bubble setup code to window.cc (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: move functionality of wm ipc out of browser so that views/bubble can use it. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/views/bubble/bubble_delegate.h" 5 #include "ui/views/bubble/bubble_delegate.h"
6 6
7 #include <vector>
8
7 #include "ui/base/animation/slide_animation.h" 9 #include "ui/base/animation/slide_animation.h"
8 #include "ui/views/bubble/bubble_frame_view.h" 10 #include "ui/views/bubble/bubble_frame_view.h"
9 #include "views/widget/widget.h" 11 #include "views/widget/widget.h"
10 12
13 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
14 #include "views/widget/wm_ipc.h"
15 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h"
16 #endif
17
11 // The duration of the fade animation in milliseconds. 18 // The duration of the fade animation in milliseconds.
12 static const int kHideFadeDurationMS = 200; 19 static const int kHideFadeDurationMS = 200;
13 20
14 namespace views { 21 namespace views {
15 22
16 namespace { 23 namespace {
17 24
18 // Create a widget to host the bubble. 25 // Create a widget to host the bubble.
19 Widget* CreateBubbleWidget(BubbleDelegateView* bubble, Widget* parent) { 26 Widget* CreateBubbleWidget(BubbleDelegateView* bubble, Widget* parent) {
20 Widget* bubble_widget = new Widget(); 27 Widget* bubble_widget = new Widget();
21 Widget::InitParams bubble_params(Widget::InitParams::TYPE_BUBBLE); 28 Widget::InitParams bubble_params(Widget::InitParams::TYPE_BUBBLE);
22 bubble_params.delegate = bubble; 29 bubble_params.delegate = bubble;
23 bubble_params.transparent = true; 30 bubble_params.transparent = true;
24 bubble_params.parent_widget = parent; 31 bubble_params.parent_widget = parent;
25 #if defined(OS_WIN) && !defined(USE_AURA) 32 #if defined(OS_WIN) && !defined(USE_AURA)
26 bubble_params.type = Widget::InitParams::TYPE_WINDOW_FRAMELESS; 33 bubble_params.type = Widget::InitParams::TYPE_WINDOW_FRAMELESS;
27 bubble_params.transparent = false; 34 bubble_params.transparent = false;
28 #endif 35 #endif
29 bubble_widget->Init(bubble_params); 36 bubble_widget->Init(bubble_params);
37 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
38 {
39 std::vector<int> params;
40 params.push_back(bubble->show_while_screen_is_locked());
41 views::chromeos::WmIpc::instance()->SetWindowType(
42 bubble_widget->GetNativeView(),
43 ::chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE,
44 &params);
45 }
46 #endif
30 return bubble_widget; 47 return bubble_widget;
31 } 48 }
32 49
50 bool SetLegacyChromeosWindowType();
51
33 #if defined(OS_WIN) && !defined(USE_AURA) 52 #if defined(OS_WIN) && !defined(USE_AURA)
34 // The border widget's delegate, needed for transparent Windows native controls. 53 // The border widget's delegate, needed for transparent Windows native controls.
35 // TODO(msw): Remove this when Windows native controls are no longer needed. 54 // TODO(msw): Remove this when Windows native controls are no longer needed.
36 class VIEWS_EXPORT BubbleBorderDelegateView : public WidgetDelegateView { 55 class VIEWS_EXPORT BubbleBorderDelegateView : public WidgetDelegateView {
37 public: 56 public:
38 explicit BubbleBorderDelegateView(BubbleDelegateView* bubble) 57 explicit BubbleBorderDelegateView(BubbleDelegateView* bubble)
39 : bubble_(bubble) {} 58 : bubble_(bubble) {}
40 virtual ~BubbleBorderDelegateView() {} 59 virtual ~BubbleBorderDelegateView() {}
41 60
42 // WidgetDelegateView overrides: 61 // WidgetDelegateView overrides:
(...skipping 29 matching lines...) Expand all
72 } // namespace 91 } // namespace
73 92
74 BubbleDelegateView::BubbleDelegateView() 93 BubbleDelegateView::BubbleDelegateView()
75 : close_on_esc_(true), 94 : close_on_esc_(true),
76 close_on_deactivate_(true), 95 close_on_deactivate_(true),
77 allow_bubble_offscreen_(false), 96 allow_bubble_offscreen_(false),
78 anchor_view_(NULL), 97 anchor_view_(NULL),
79 arrow_location_(BubbleBorder::TOP_LEFT), 98 arrow_location_(BubbleBorder::TOP_LEFT),
80 color_(SK_ColorWHITE), 99 color_(SK_ColorWHITE),
81 border_widget_(NULL), 100 border_widget_(NULL),
82 use_focusless_(false) { 101 use_focusless_(false),
102 show_while_screen_is_locked_(false) {
83 set_background(views::Background::CreateSolidBackground(color_)); 103 set_background(views::Background::CreateSolidBackground(color_));
84 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0)); 104 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0));
85 } 105 }
86 106
87 BubbleDelegateView::BubbleDelegateView( 107 BubbleDelegateView::BubbleDelegateView(
88 View* anchor_view, 108 View* anchor_view,
89 BubbleBorder::ArrowLocation arrow_location, 109 BubbleBorder::ArrowLocation arrow_location,
90 const SkColor& color) 110 const SkColor& color)
91 : close_on_esc_(true), 111 : close_on_esc_(true),
92 close_on_deactivate_(true), 112 close_on_deactivate_(true),
93 allow_bubble_offscreen_(false), 113 allow_bubble_offscreen_(false),
94 anchor_view_(anchor_view), 114 anchor_view_(anchor_view),
95 arrow_location_(arrow_location), 115 arrow_location_(arrow_location),
96 color_(color), 116 color_(color),
97 original_opacity_(255), 117 original_opacity_(255),
98 border_widget_(NULL), 118 border_widget_(NULL),
99 use_focusless_(false) { 119 use_focusless_(false),
120 show_while_screen_is_locked_(false) {
100 set_background(views::Background::CreateSolidBackground(color_)); 121 set_background(views::Background::CreateSolidBackground(color_));
101 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0)); 122 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0));
102 } 123 }
103 124
104 BubbleDelegateView::~BubbleDelegateView() { 125 BubbleDelegateView::~BubbleDelegateView() {
105 if (border_widget_) 126 if (border_widget_)
106 border_widget_->Close(); 127 border_widget_->Close();
107 } 128 }
108 129
109 // static 130 // static
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 299
279 #if defined(OS_WIN) && !defined(USE_AURA) 300 #if defined(OS_WIN) && !defined(USE_AURA)
280 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { 301 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const {
281 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); 302 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView());
282 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); 303 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin());
283 return client_bounds; 304 return client_bounds;
284 } 305 }
285 #endif 306 #endif
286 307
287 } // namespace views 308 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698