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

Side by Side Diff: mandoline/ui/omnibox/omnibox_impl.cc

Issue 1134003004: mandoline/omnibox: Add some opacity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mandoline/ui/omnibox/omnibox_impl.h" 5 #include "mandoline/ui/omnibox/omnibox_impl.h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "components/view_manager/public/cpp/view_manager_client_factory.h" 8 #include "components/view_manager/public/cpp/view_manager_client_factory.h"
9 #include "components/window_manager/public/interfaces/window_manager.mojom.h" 9 #include "components/window_manager/public/interfaces/window_manager.mojom.h"
10 #include "mandoline/ui/aura/aura_init.h" 10 #include "mandoline/ui/aura/aura_init.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 void OmniboxImpl::OnEmbed(mojo::View* root, 54 void OmniboxImpl::OnEmbed(mojo::View* root,
55 mojo::InterfaceRequest<mojo::ServiceProvider> services, 55 mojo::InterfaceRequest<mojo::ServiceProvider> services,
56 mojo::ServiceProviderPtr exposed_services) { 56 mojo::ServiceProviderPtr exposed_services) {
57 if (!aura_init_.get()) { 57 if (!aura_init_.get()) {
58 aura_init_.reset(new AuraInit); 58 aura_init_.reset(new AuraInit);
59 edit_ = new views::Textfield; 59 edit_ = new views::Textfield;
60 edit_->set_controller(this); 60 edit_->set_controller(this);
61 } 61 }
62 62
63 const int kOpacity = 0xC0;
63 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; 64 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView;
64 widget_delegate->GetContentsView()->set_background( 65 widget_delegate->GetContentsView()->set_background(
65 views::Background::CreateSolidBackground(0xFFDDDDDD)); 66 views::Background::CreateSolidBackground(
67 SkColorSetA(0xDDDDDD, kOpacity)));
66 widget_delegate->GetContentsView()->AddChildView(edit_); 68 widget_delegate->GetContentsView()->AddChildView(edit_);
67 widget_delegate->GetContentsView()->SetLayoutManager(this); 69 widget_delegate->GetContentsView()->SetLayoutManager(this);
68 70
69 // TODO(beng): we may be leaking these on subsequent calls to OnEmbed()... 71 // TODO(beng): we may be leaking these on subsequent calls to OnEmbed()...
70 // probably should only allow once instance per view. 72 // probably should only allow once instance per view.
71 views::Widget* widget = new views::Widget; 73 views::Widget* widget = new views::Widget;
72 views::Widget::InitParams params( 74 views::Widget::InitParams params(
73 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 75 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
74 params.native_widget = 76 params.native_widget =
75 new NativeWidgetViewManager(widget, app_impl_->shell(), root); 77 new NativeWidgetViewManager(widget, app_impl_->shell(), root);
76 params.delegate = widget_delegate; 78 params.delegate = widget_delegate;
77 params.bounds = root->bounds().To<gfx::Rect>(); 79 params.bounds = root->bounds().To<gfx::Rect>();
80 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
78 widget->Init(params); 81 widget->Init(params);
79 widget->Show(); 82 widget->Show();
83 widget->GetCompositor()->SetBackgroundColor(
84 SkColorSetA(SK_ColorBLACK, kOpacity));
80 root->SetFocus(); 85 root->SetFocus();
81 edit_->SetText(url_.To<base::string16>()); 86 edit_->SetText(url_.To<base::string16>());
82 edit_->SelectAll(false); 87 edit_->SelectAll(false);
83 edit_->RequestFocus(); 88 edit_->RequestFocus();
84 } 89 }
85 90
86 void OmniboxImpl::OnViewManagerDisconnected(mojo::ViewManager* view_manager) {} 91 void OmniboxImpl::OnViewManagerDisconnected(mojo::ViewManager* view_manager) {}
87 92
88 //////////////////////////////////////////////////////////////////////////////// 93 ////////////////////////////////////////////////////////////////////////////////
89 // OmniboxImpl, views::LayoutManager implementation: 94 // OmniboxImpl, views::LayoutManager implementation:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 134 }
130 135
131 void OmniboxImpl::ShowForURL(const mojo::String& url) { 136 void OmniboxImpl::ShowForURL(const mojo::String& url) {
132 url_ = url; 137 url_ = url;
133 mojo::WindowManagerPtr window_manager; 138 mojo::WindowManagerPtr window_manager;
134 app_impl_->ConnectToService("mojo:window_manager", &window_manager); 139 app_impl_->ConnectToService("mojo:window_manager", &window_manager);
135 window_manager->Embed("mojo:omnibox", nullptr, nullptr); 140 window_manager->Embed("mojo:omnibox", nullptr, nullptr);
136 } 141 }
137 142
138 } // namespace mandoline 143 } // namespace mandoline
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698