| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/subtle_notification_view.h" | 5 #include "chrome/browser/ui/views/subtle_notification_view.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 SubtleNotificationView::~SubtleNotificationView() {} | 176 SubtleNotificationView::~SubtleNotificationView() {} |
| 177 | 177 |
| 178 void SubtleNotificationView::UpdateContent( | 178 void SubtleNotificationView::UpdateContent( |
| 179 const base::string16& instruction_text, | 179 const base::string16& instruction_text, |
| 180 const base::string16& link_text) { | 180 const base::string16& link_text) { |
| 181 instruction_view_->SetText(instruction_text); | 181 instruction_view_->SetText(instruction_text); |
| 182 instruction_view_->SetVisible(!instruction_text.empty()); | 182 instruction_view_->SetVisible(!instruction_text.empty()); |
| 183 link_->SetText(link_text); | 183 link_->SetText(link_text); |
| 184 link_->SetVisible(!link_text.empty()); | 184 link_->SetVisible(!link_text.empty()); |
| 185 Layout(); |
| 185 } | 186 } |
| 186 | 187 |
| 187 // static | 188 // static |
| 188 views::Widget* SubtleNotificationView::CreatePopupWidget( | 189 views::Widget* SubtleNotificationView::CreatePopupWidget( |
| 189 gfx::NativeView parent_view, | 190 gfx::NativeView parent_view, |
| 190 SubtleNotificationView* view, | 191 SubtleNotificationView* view, |
| 191 bool accept_events) { | 192 bool accept_events) { |
| 192 // Initialize the popup. | 193 // Initialize the popup. |
| 193 views::Widget* popup = new views::Widget; | 194 views::Widget* popup = new views::Widget; |
| 194 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 195 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 195 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 196 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 196 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 197 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 197 params.parent = parent_view; | 198 params.parent = parent_view; |
| 198 params.accept_events = accept_events; | 199 params.accept_events = accept_events; |
| 199 popup->Init(params); | 200 popup->Init(params); |
| 200 popup->SetContentsView(view); | 201 popup->SetContentsView(view); |
| 201 // We set layout manager to nullptr to prevent the widget from sizing its | 202 // We set layout manager to nullptr to prevent the widget from sizing its |
| 202 // contents to the same size as itself. This prevents the widget contents from | 203 // contents to the same size as itself. This prevents the widget contents from |
| 203 // shrinking while we animate the height of the popup to give the impression | 204 // shrinking while we animate the height of the popup to give the impression |
| 204 // that it is sliding off the top of the screen. | 205 // that it is sliding off the top of the screen. |
| 205 // TODO(mgiuca): This probably isn't necessary now that there is no slide | 206 // TODO(mgiuca): This probably isn't necessary now that there is no slide |
| 206 // animation. Remove it. | 207 // animation. Remove it. |
| 207 popup->GetRootView()->SetLayoutManager(nullptr); | 208 popup->GetRootView()->SetLayoutManager(nullptr); |
| 208 | 209 |
| 209 return popup; | 210 return popup; |
| 210 } | 211 } |
| OLD | NEW |