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

Side by Side Diff: ui/views/widget/widget.cc

Issue 1310183009: Add ability for Widgets to override the DefaultThemeProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months 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
OLDNEW
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 "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 mirror_origin_in_rtl(false), 115 mirror_origin_in_rtl(false),
116 shadow_type(SHADOW_TYPE_DEFAULT), 116 shadow_type(SHADOW_TYPE_DEFAULT),
117 remove_standard_frame(false), 117 remove_standard_frame(false),
118 use_system_default_icon(false), 118 use_system_default_icon(false),
119 show_state(ui::SHOW_STATE_DEFAULT), 119 show_state(ui::SHOW_STATE_DEFAULT),
120 parent(NULL), 120 parent(NULL),
121 native_widget(NULL), 121 native_widget(NULL),
122 desktop_window_tree_host(NULL), 122 desktop_window_tree_host(NULL),
123 layer_type(ui::LAYER_TEXTURED), 123 layer_type(ui::LAYER_TEXTURED),
124 context(NULL), 124 context(NULL),
125 force_show_in_taskbar(false) { 125 force_show_in_taskbar(false),
126 theme_provider(nullptr) {
126 } 127 }
127 128
128 Widget::InitParams::InitParams(Type type) 129 Widget::InitParams::InitParams(Type type)
129 : type(type), 130 : type(type),
130 delegate(NULL), 131 delegate(NULL),
131 child(false), 132 child(false),
132 opacity(INFER_OPACITY), 133 opacity(INFER_OPACITY),
133 accept_events(true), 134 accept_events(true),
134 activatable(ACTIVATABLE_DEFAULT), 135 activatable(ACTIVATABLE_DEFAULT),
135 keep_on_top(type == TYPE_MENU || type == TYPE_DRAG), 136 keep_on_top(type == TYPE_MENU || type == TYPE_DRAG),
136 visible_on_all_workspaces(false), 137 visible_on_all_workspaces(false),
137 ownership(NATIVE_WIDGET_OWNS_WIDGET), 138 ownership(NATIVE_WIDGET_OWNS_WIDGET),
138 mirror_origin_in_rtl(false), 139 mirror_origin_in_rtl(false),
139 shadow_type(SHADOW_TYPE_DEFAULT), 140 shadow_type(SHADOW_TYPE_DEFAULT),
140 remove_standard_frame(false), 141 remove_standard_frame(false),
141 use_system_default_icon(false), 142 use_system_default_icon(false),
142 show_state(ui::SHOW_STATE_DEFAULT), 143 show_state(ui::SHOW_STATE_DEFAULT),
143 parent(NULL), 144 parent(NULL),
144 native_widget(NULL), 145 native_widget(NULL),
145 desktop_window_tree_host(NULL), 146 desktop_window_tree_host(NULL),
146 layer_type(ui::LAYER_TEXTURED), 147 layer_type(ui::LAYER_TEXTURED),
147 context(NULL), 148 context(NULL),
148 force_show_in_taskbar(false) { 149 force_show_in_taskbar(false),
150 theme_provider(nullptr) {
149 } 151 }
150 152
151 Widget::InitParams::~InitParams() { 153 Widget::InitParams::~InitParams() {
152 } 154 }
153 155
154 //////////////////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////////////////
155 // Widget, public: 157 // Widget, public:
156 158
157 Widget::Widget() 159 Widget::Widget()
158 : native_widget_(NULL), 160 : native_widget_(NULL),
159 widget_delegate_(NULL), 161 widget_delegate_(NULL),
160 non_client_view_(NULL), 162 non_client_view_(NULL),
163 theme_provider_(nullptr),
161 dragged_view_(NULL), 164 dragged_view_(NULL),
162 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), 165 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET),
163 is_secondary_widget_(true), 166 is_secondary_widget_(true),
164 frame_type_(FRAME_TYPE_DEFAULT), 167 frame_type_(FRAME_TYPE_DEFAULT),
165 disable_inactive_rendering_(false), 168 disable_inactive_rendering_(false),
166 widget_closed_(false), 169 widget_closed_(false),
167 saved_show_state_(ui::SHOW_STATE_DEFAULT), 170 saved_show_state_(ui::SHOW_STATE_DEFAULT),
168 focus_on_creation_(true), 171 focus_on_creation_(true),
169 is_top_level_(false), 172 is_top_level_(false),
170 native_widget_initialized_(false), 173 native_widget_initialized_(false),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 347 }
345 348
346 widget_delegate_ = params.delegate ? 349 widget_delegate_ = params.delegate ?
347 params.delegate : new DefaultWidgetDelegate(this); 350 params.delegate : new DefaultWidgetDelegate(this);
348 widget_delegate_->set_can_activate(can_activate); 351 widget_delegate_->set_can_activate(can_activate);
349 352
350 ownership_ = params.ownership; 353 ownership_ = params.ownership;
351 native_widget_ = CreateNativeWidget(params.native_widget, this)-> 354 native_widget_ = CreateNativeWidget(params.native_widget, this)->
352 AsNativeWidgetPrivate(); 355 AsNativeWidgetPrivate();
353 root_view_.reset(CreateRootView()); 356 root_view_.reset(CreateRootView());
354 default_theme_provider_.reset(new ui::DefaultThemeProvider); 357 if (in_params.theme_provider)
358 theme_provider_ = in_params.theme_provider;
359 else
360 default_theme_provider_.reset(new ui::DefaultThemeProvider);
355 if (params.type == InitParams::TYPE_MENU) { 361 if (params.type == InitParams::TYPE_MENU) {
356 is_mouse_button_pressed_ = 362 is_mouse_button_pressed_ =
357 internal::NativeWidgetPrivate::IsMouseButtonDown(); 363 internal::NativeWidgetPrivate::IsMouseButtonDown();
358 } 364 }
359 native_widget_->InitNativeWidget(params); 365 native_widget_->InitNativeWidget(params);
360 if (RequiresNonClientView(params.type)) { 366 if (RequiresNonClientView(params.type)) {
361 non_client_view_ = new NonClientView; 367 non_client_view_ = new NonClientView;
362 non_client_view_->SetFrameView(CreateNonClientFrameView()); 368 non_client_view_->SetFrameView(CreateNonClientFrameView());
363 // Create the ClientView, add it to the NonClientView and add the 369 // Create the ClientView, add it to the NonClientView and add the
364 // NonClientView to the RootView. This will cause everything to be parented. 370 // NonClientView to the RootView. This will cause everything to be parented.
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 741
736 const View* Widget::GetRootView() const { 742 const View* Widget::GetRootView() const {
737 return root_view_.get(); 743 return root_view_.get();
738 } 744 }
739 745
740 bool Widget::IsVisible() const { 746 bool Widget::IsVisible() const {
741 return native_widget_->IsVisible(); 747 return native_widget_->IsVisible();
742 } 748 }
743 749
744 ui::ThemeProvider* Widget::GetThemeProvider() const { 750 ui::ThemeProvider* Widget::GetThemeProvider() const {
751 if (theme_provider_)
752 return theme_provider_;
745 const Widget* root_widget = GetTopLevelWidget(); 753 const Widget* root_widget = GetTopLevelWidget();
746 if (root_widget && root_widget != this) { 754 if (root_widget && root_widget != this) {
747 // Attempt to get the theme provider, and fall back to the default theme 755 // Attempt to get the theme provider, and fall back to the default theme
748 // provider if not found. 756 // provider if not found.
749 ui::ThemeProvider* provider = root_widget->GetThemeProvider(); 757 ui::ThemeProvider* provider = root_widget->GetThemeProvider();
750 if (provider) 758 if (provider)
751 return provider; 759 return provider;
752 760
753 provider = root_widget->default_theme_provider_.get(); 761 provider = root_widget->default_theme_provider_.get();
754 if (provider) 762 if (provider)
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 1491
1484 //////////////////////////////////////////////////////////////////////////////// 1492 ////////////////////////////////////////////////////////////////////////////////
1485 // internal::NativeWidgetPrivate, NativeWidget implementation: 1493 // internal::NativeWidgetPrivate, NativeWidget implementation:
1486 1494
1487 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1495 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1488 return this; 1496 return this;
1489 } 1497 }
1490 1498
1491 } // namespace internal 1499 } // namespace internal
1492 } // namespace views 1500 } // namespace views
OLDNEW
« chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc ('K') | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698