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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc

Issue 1310183009: Add ability for Widgets to override the DefaultThemeProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only Set ThemeProvider on Top Level Widget 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 "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/search/search.h" 10 #include "chrome/browser/search/search.h"
10 #include "chrome/browser/themes/theme_properties.h" 11 #include "chrome/browser/themes/theme_properties.h"
12 #include "chrome/browser/themes/theme_service.h"
13 #include "chrome/browser/themes/theme_service_factory.h"
11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
12 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" 15 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
13 #include "components/omnibox/browser/omnibox_view.h" 16 #include "components/omnibox/browser/omnibox_view.h"
14 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
15 #include "ui/base/resource/material_design/material_design_controller.h" 18 #include "ui/base/resource/material_design/material_design_controller.h"
16 #include "ui/base/theme_provider.h" 19 #include "ui/base/theme_provider.h"
17 #include "ui/compositor/clip_transform_recorder.h" 20 #include "ui/compositor/clip_transform_recorder.h"
18 #include "ui/compositor/paint_recorder.h" 21 #include "ui/compositor/paint_recorder.h"
19 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
21 #include "ui/gfx/path.h" 24 #include "ui/gfx/path.h"
22 #include "ui/resources/grit/ui_resources.h" 25 #include "ui/resources/grit/ui_resources.h"
23 #include "ui/views/controls/image_view.h" 26 #include "ui/views/controls/image_view.h"
24 #include "ui/views/resources/grit/views_resources.h" 27 #include "ui/views/resources/grit/views_resources.h"
25 #include "ui/views/view_targeter.h" 28 #include "ui/views/view_targeter.h"
26 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
27 #include "ui/views/window/non_client_view.h" 30 #include "ui/views/window/non_client_view.h"
28 31
32 #if defined(OS_CHROMEOS)
33 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
34 #endif // OS_CHROMEOS
35
29 class OmniboxPopupContentsView::AutocompletePopupWidget 36 class OmniboxPopupContentsView::AutocompletePopupWidget
30 : public views::Widget, 37 : public views::Widget,
31 public base::SupportsWeakPtr<AutocompletePopupWidget> { 38 public base::SupportsWeakPtr<AutocompletePopupWidget> {
32 public: 39 public:
33 AutocompletePopupWidget() {} 40 AutocompletePopupWidget() {}
34 ~AutocompletePopupWidget() override {} 41 ~AutocompletePopupWidget() override {}
35 42
36 private: 43 private:
37 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); 44 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget);
38 }; 45 };
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // buffer creation. We can revert this change once http://crbug.com/125248 247 // buffer creation. We can revert this change once http://crbug.com/125248
241 // is fixed. 248 // is fixed.
242 #if defined(OS_WIN) 249 #if defined(OS_WIN)
243 views::Widget::InitParams params(views::Widget::InitParams::TYPE_MENU); 250 views::Widget::InitParams params(views::Widget::InitParams::TYPE_MENU);
244 // The menu style assumes a top most window. We don't want that in this 251 // The menu style assumes a top most window. We don't want that in this
245 // case. 252 // case.
246 params.keep_on_top = false; 253 params.keep_on_top = false;
247 #else 254 #else
248 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 255 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
249 #endif 256 #endif
257
258 // On login screen and logged in as an anonymous user you might not get a
oshima 2015/09/10 00:20:38 Is it impossible to have omnibox in login screen,
259 // profile. Which indicates that multi-user is not active and an anonymous
260 // profile is in use. Take the active profile to find the theme.
261 Profile* profile = nullptr;
262 #if defined(OS_CHROMEOS)
263 profile =
264 multi_user_util::GetProfileFromWindow(popup_parent->GetNativeWindow());
265 if (!profile)
266 profile = ProfileManager::GetActiveUserProfile();
267 #else
268 profile = ProfileManager::GetActiveUserProfile();
269 #endif // OS_CHROMEOS
270
250 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 271 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
251 params.parent = popup_parent->GetNativeView(); 272 params.parent = popup_parent->GetNativeView();
252 params.bounds = GetPopupBounds(); 273 params.bounds = GetPopupBounds();
253 params.context = popup_parent->GetNativeWindow(); 274 params.context = popup_parent->GetNativeWindow();
275 params.theme_provider = ThemeServiceFactory::GetForProfile(profile);
254 popup_->Init(params); 276 popup_->Init(params);
255 // Third-party software such as DigitalPersona identity verification can 277 // Third-party software such as DigitalPersona identity verification can
256 // hook the underlying window creation methods and use SendMessage to 278 // hook the underlying window creation methods and use SendMessage to
257 // synchronously change focus/activation, resulting in the popup being 279 // synchronously change focus/activation, resulting in the popup being
258 // destroyed by the time control returns here. Bail out in this case to 280 // destroyed by the time control returns here. Bail out in this case to
259 // avoid a NULL dereference. 281 // avoid a NULL dereference.
260 if (!popup_.get()) 282 if (!popup_.get())
261 return; 283 return;
262 popup_->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); 284 popup_->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE);
263 popup_->SetContentsView(this); 285 popup_->SetContentsView(this);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 size_t index = GetIndexForPoint(event.location()); 559 size_t index = GetIndexForPoint(event.location());
538 if (!HasMatchAt(index)) 560 if (!HasMatchAt(index))
539 return; 561 return;
540 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, 562 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition,
541 GURL(), base::string16(), index); 563 GURL(), base::string16(), index);
542 } 564 }
543 565
544 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { 566 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) {
545 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); 567 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i)));
546 } 568 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698