| 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/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
| 10 #include "app/gfx/color_utils.h" | 10 #include "app/gfx/color_utils.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 static const int kCookiePromptViewInsetSize = 5; | 35 static const int kCookiePromptViewInsetSize = 5; |
| 36 | 36 |
| 37 /////////////////////////////////////////////////////////////////////////////// | 37 /////////////////////////////////////////////////////////////////////////////// |
| 38 // CookiePromptView, public: | 38 // CookiePromptView, public: |
| 39 | 39 |
| 40 CookiePromptView::CookiePromptView( | 40 CookiePromptView::CookiePromptView( |
| 41 CookiePromptModalDialog* parent, | 41 CookiePromptModalDialog* parent, |
| 42 gfx::NativeWindow root_window, | 42 gfx::NativeWindow root_window, |
| 43 Profile* profile, | 43 Profile* profile, |
| 44 const BrowsingDataLocalStorageHelper::LocalStorageInfo& storage_info, | 44 const BrowsingDataLocalStorageHelper::LocalStorageInfo& storage_info, |
| 45 const std::string& host, | 45 const GURL& url, |
| 46 const std::string& cookie_line, | 46 const std::string& cookie_line, |
| 47 CookiePromptModalDialogDelegate* delegate, | 47 CookiePromptModalDialogDelegate* delegate, |
| 48 bool cookie_ui) | 48 bool cookie_ui) |
| 49 : remember_radio_(NULL), | 49 : remember_radio_(NULL), |
| 50 ask_radio_(NULL), | 50 ask_radio_(NULL), |
| 51 allow_button_(NULL), | 51 allow_button_(NULL), |
| 52 block_button_(NULL), | 52 block_button_(NULL), |
| 53 show_cookie_link_(NULL), | 53 show_cookie_link_(NULL), |
| 54 info_view_(NULL), | 54 info_view_(NULL), |
| 55 session_expire_(false), | 55 session_expire_(false), |
| 56 expanded_view_(false), | 56 expanded_view_(false), |
| 57 signaled_(false), | 57 signaled_(false), |
| 58 cookie_ui_(cookie_ui), | 58 cookie_ui_(cookie_ui), |
| 59 parent_(parent), | 59 parent_(parent), |
| 60 root_window_(root_window), | 60 root_window_(root_window), |
| 61 host_(host), | 61 url_(url), |
| 62 cookie_line_(cookie_line), | 62 cookie_line_(cookie_line), |
| 63 local_storage_info_(storage_info), | 63 local_storage_info_(storage_info), |
| 64 delegate_(delegate) { | 64 delegate_(delegate) { |
| 65 InitializeViewResources(host); | 65 InitializeViewResources(); |
| 66 expanded_view_ = g_browser_process->local_state()-> | 66 expanded_view_ = g_browser_process->local_state()-> |
| 67 GetBoolean(prefs::kCookiePromptExpanded); | 67 GetBoolean(prefs::kCookiePromptExpanded); |
| 68 } | 68 } |
| 69 | 69 |
| 70 CookiePromptView::~CookiePromptView() { | 70 CookiePromptView::~CookiePromptView() { |
| 71 } | 71 } |
| 72 | 72 |
| 73 /////////////////////////////////////////////////////////////////////////////// | 73 /////////////////////////////////////////////////////////////////////////////// |
| 74 // CookiePromptView, views::View overrides: | 74 // CookiePromptView, views::View overrides: |
| 75 | 75 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 235 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 236 | 236 |
| 237 layout->StartRow(0, one_column_layout_id); | 237 layout->StartRow(0, one_column_layout_id); |
| 238 | 238 |
| 239 if (cookie_ui_) { | 239 if (cookie_ui_) { |
| 240 CookieInfoView* cookie_info_view = new CookieInfoView(true); | 240 CookieInfoView* cookie_info_view = new CookieInfoView(true); |
| 241 cookie_info_view->set_delegate(this); | 241 cookie_info_view->set_delegate(this); |
| 242 layout->AddView(cookie_info_view, 1, 1, GridLayout::FILL, | 242 layout->AddView(cookie_info_view, 1, 1, GridLayout::FILL, |
| 243 GridLayout::CENTER); | 243 GridLayout::CENTER); |
| 244 | 244 |
| 245 cookie_info_view->SetCookieString(host_, cookie_line_); | 245 cookie_info_view->SetCookieString(url_, cookie_line_); |
| 246 info_view_ = cookie_info_view; | 246 info_view_ = cookie_info_view; |
| 247 } else { | 247 } else { |
| 248 LocalStorageInfoView* local_storage_info_view = new LocalStorageInfoView(); | 248 LocalStorageInfoView* local_storage_info_view = new LocalStorageInfoView(); |
| 249 layout->AddView(local_storage_info_view, 1, 1, GridLayout::FILL, | 249 layout->AddView(local_storage_info_view, 1, 1, GridLayout::FILL, |
| 250 GridLayout::CENTER); | 250 GridLayout::CENTER); |
| 251 local_storage_info_view->SetLocalStorageInfo(local_storage_info_); | 251 local_storage_info_view->SetLocalStorageInfo(local_storage_info_); |
| 252 info_view_ = local_storage_info_view; | 252 info_view_ = local_storage_info_view; |
| 253 } | 253 } |
| 254 | 254 |
| 255 info_view_->SetVisible(expanded_view_); | 255 info_view_->SetVisible(expanded_view_); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 275 // again as there is a bug in combobox that results in preferred height | 275 // again as there is a bug in combobox that results in preferred height |
| 276 // changing when visible and not visible. | 276 // changing when visible and not visible. |
| 277 info_view_->SetVisible(expanded_view_); | 277 info_view_->SetVisible(expanded_view_); |
| 278 int extended_height_delta = GetExtendedViewHeight() - old_extended_height; | 278 int extended_height_delta = GetExtendedViewHeight() - old_extended_height; |
| 279 views::Window* window = GetWindow(); | 279 views::Window* window = GetWindow(); |
| 280 gfx::Rect bounds = window->GetBounds(); | 280 gfx::Rect bounds = window->GetBounds(); |
| 281 bounds.set_height(bounds.height() + extended_height_delta); | 281 bounds.set_height(bounds.height() + extended_height_delta); |
| 282 window->SetBounds(bounds, NULL); | 282 window->SetBounds(bounds, NULL); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void CookiePromptView::InitializeViewResources(const std::string& host) { | 285 void CookiePromptView::InitializeViewResources() { |
| 286 DCHECK(host.empty() || host[0] != '.'); | 286 host_ = cookie_ui_ ? url_.host() : local_storage_info_.host; |
| 287 host_ = host; | |
| 288 title_ = l10n_util::GetStringF( | 287 title_ = l10n_util::GetStringF( |
| 289 cookie_ui_ ? IDS_COOKIE_ALERT_TITLE : IDS_DATA_ALERT_TITLE, | 288 cookie_ui_ ? IDS_COOKIE_ALERT_TITLE : IDS_DATA_ALERT_TITLE, |
| 290 UTF8ToWide(host_)); | 289 UTF8ToWide(host_)); |
| 291 } | 290 } |
| 292 | 291 |
| OLD | NEW |