| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/cookie_prompt_view.h" | 5 #include "chrome/browser/views/cookie_prompt_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 : remember_radio_(NULL), | 46 : remember_radio_(NULL), |
| 47 ask_radio_(NULL), | 47 ask_radio_(NULL), |
| 48 allow_button_(NULL), | 48 allow_button_(NULL), |
| 49 block_button_(NULL), | 49 block_button_(NULL), |
| 50 show_cookie_link_(NULL), | 50 show_cookie_link_(NULL), |
| 51 info_view_(NULL), | 51 info_view_(NULL), |
| 52 session_expire_(false), | 52 session_expire_(false), |
| 53 expanded_view_(false), | 53 expanded_view_(false), |
| 54 signaled_(false), | 54 signaled_(false), |
| 55 parent_(parent), | 55 parent_(parent), |
| 56 root_window_(root_window) { | 56 root_window_(root_window), |
| 57 profile_(profile) { |
| 57 InitializeViewResources(); | 58 InitializeViewResources(); |
| 58 expanded_view_ = g_browser_process->local_state()-> | 59 expanded_view_ = profile_->GetPrefs()-> |
| 59 GetBoolean(prefs::kCookiePromptExpanded); | 60 GetBoolean(prefs::kCookiePromptExpanded); |
| 60 } | 61 } |
| 61 | 62 |
| 62 CookiePromptView::~CookiePromptView() { | 63 CookiePromptView::~CookiePromptView() { |
| 63 } | 64 } |
| 64 | 65 |
| 65 /////////////////////////////////////////////////////////////////////////////// | 66 /////////////////////////////////////////////////////////////////////////////// |
| 66 // CookiePromptView, views::View overrides: | 67 // CookiePromptView, views::View overrides: |
| 67 | 68 |
| 68 gfx::Size CookiePromptView::GetPreferredSize() { | 69 gfx::Size CookiePromptView::GetPreferredSize() { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 int CookiePromptView::GetExtendedViewHeight() { | 268 int CookiePromptView::GetExtendedViewHeight() { |
| 268 DCHECK(info_view_); | 269 DCHECK(info_view_); |
| 269 return expanded_view_ ? | 270 return expanded_view_ ? |
| 270 0 : -info_view_->GetPreferredSize().height(); | 271 0 : -info_view_->GetPreferredSize().height(); |
| 271 } | 272 } |
| 272 | 273 |
| 273 void CookiePromptView::ToggleDetailsViewExpand() { | 274 void CookiePromptView::ToggleDetailsViewExpand() { |
| 274 int old_extended_height = GetExtendedViewHeight(); | 275 int old_extended_height = GetExtendedViewHeight(); |
| 275 | 276 |
| 276 expanded_view_ = !expanded_view_; | 277 expanded_view_ = !expanded_view_; |
| 277 g_browser_process->local_state()->SetBoolean(prefs::kCookiePromptExpanded, | 278 profile_->GetPrefs()->SetBoolean(prefs::kCookiePromptExpanded, |
| 278 expanded_view_); | 279 expanded_view_); |
| 279 | 280 |
| 280 // We have to set the visbility before asking for the extended view height | 281 // We have to set the visbility before asking for the extended view height |
| 281 // again as there is a bug in combobox that results in preferred height | 282 // again as there is a bug in combobox that results in preferred height |
| 282 // changing when visible and not visible. | 283 // changing when visible and not visible. |
| 283 info_view_->SetVisible(expanded_view_); | 284 info_view_->SetVisible(expanded_view_); |
| 284 int extended_height_delta = GetExtendedViewHeight() - old_extended_height; | 285 int extended_height_delta = GetExtendedViewHeight() - old_extended_height; |
| 285 views::Window* window = GetWindow(); | 286 views::Window* window = GetWindow(); |
| 286 gfx::Rect bounds = window->GetBounds(); | 287 gfx::Rect bounds = window->GetBounds(); |
| 287 bounds.set_height(bounds.height() + extended_height_delta); | 288 bounds.set_height(bounds.height() + extended_height_delta); |
| 288 window->SetBounds(bounds, NULL); | 289 window->SetBounds(bounds, NULL); |
| 289 } | 290 } |
| 290 | 291 |
| 291 void CookiePromptView::InitializeViewResources() { | 292 void CookiePromptView::InitializeViewResources() { |
| 292 CookiePromptModalDialog::DialogType type = parent_->dialog_type(); | 293 CookiePromptModalDialog::DialogType type = parent_->dialog_type(); |
| 293 title_ = l10n_util::GetStringF( | 294 title_ = l10n_util::GetStringF( |
| 294 type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE ? | 295 type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE ? |
| 295 IDS_COOKIE_ALERT_TITLE : IDS_DATA_ALERT_TITLE, | 296 IDS_COOKIE_ALERT_TITLE : IDS_DATA_ALERT_TITLE, |
| 296 UTF8ToWide(parent_->origin().host())); | 297 UTF8ToWide(parent_->origin().host())); |
| 297 } | 298 } |
| OLD | NEW |