| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/options/cookies_view.h" | 5 #include "chrome/browser/ui/views/options/cookies_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/views/appcache_info_view.h" | 12 #include "chrome/browser/ui/views/appcache_info_view.h" |
| 13 #include "chrome/browser/ui/views/cookie_info_view.h" | 13 #include "chrome/browser/ui/views/cookie_info_view.h" |
| 14 #include "chrome/browser/ui/views/database_info_view.h" | 14 #include "chrome/browser/ui/views/database_info_view.h" |
| 15 #include "chrome/browser/ui/views/indexed_db_info_view.h" | 15 #include "chrome/browser/ui/views/indexed_db_info_view.h" |
| 16 #include "chrome/browser/ui/views/local_storage_info_view.h" | 16 #include "chrome/browser/ui/views/local_storage_info_view.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "grit/locale_settings.h" | 18 #include "grit/locale_settings.h" |
| 19 #include "net/base/cookie_monster.h" | 19 #include "net/base/cookie_monster.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/color_utils.h" | 22 #include "ui/gfx/color_utils.h" |
| 23 #include "views/border.h" | 23 #include "views/border.h" |
| 24 #include "views/controls/button/native_button.h" |
| 24 #include "views/controls/label.h" | 25 #include "views/controls/label.h" |
| 25 #include "views/controls/button/native_button.h" | 26 #include "views/controls/textfield/textfield.h" |
| 27 #include "views/controls/textfield/textfield.h" |
| 26 #include "views/controls/tree/tree_view.h" | 28 #include "views/controls/tree/tree_view.h" |
| 27 #include "views/controls/textfield/textfield.h" | |
| 28 #include "views/layout/grid_layout.h" | 29 #include "views/layout/grid_layout.h" |
| 29 #include "views/layout/layout_constants.h" | 30 #include "views/layout/layout_constants.h" |
| 30 | 31 |
| 31 // static | 32 // static |
| 32 views::Window* CookiesView::instance_ = NULL; | 33 views::Window* CookiesView::instance_ = NULL; |
| 33 static const int kSearchFilterDelayMs = 500; | 34 static const int kSearchFilterDelayMs = 500; |
| 34 | 35 |
| 35 /////////////////////////////////////////////////////////////////////////////// | 36 /////////////////////////////////////////////////////////////////////////////// |
| 36 // CookiesTreeView | 37 // CookiesTreeView |
| 37 // Overridden to handle Delete key presses | 38 // Overridden to handle Delete key presses |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 UpdateForEmptyState(); | 126 UpdateForEmptyState(); |
| 126 } else if (sender == remove_all_button_) { | 127 } else if (sender == remove_all_button_) { |
| 127 cookies_tree_model_->DeleteAllStoredObjects(); | 128 cookies_tree_model_->DeleteAllStoredObjects(); |
| 128 UpdateForEmptyState(); | 129 UpdateForEmptyState(); |
| 129 } else if (sender == clear_search_button_) { | 130 } else if (sender == clear_search_button_) { |
| 130 ResetSearchQuery(); | 131 ResetSearchQuery(); |
| 131 } | 132 } |
| 132 } | 133 } |
| 133 | 134 |
| 134 /////////////////////////////////////////////////////////////////////////////// | 135 /////////////////////////////////////////////////////////////////////////////// |
| 135 // CookiesView, views::Textfield::Controller implementation: | 136 // CookiesView, views::TextfieldController implementation: |
| 136 | 137 |
| 137 void CookiesView::ContentsChanged(views::Textfield* sender, | 138 void CookiesView::ContentsChanged(views::Textfield* sender, |
| 138 const std::wstring& new_contents) { | 139 const std::wstring& new_contents) { |
| 139 clear_search_button_->SetEnabled(!search_field_->text().empty()); | 140 clear_search_button_->SetEnabled(!search_field_->text().empty()); |
| 140 search_update_factory_.RevokeAll(); | 141 search_update_factory_.RevokeAll(); |
| 141 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 142 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 142 search_update_factory_.NewRunnableMethod( | 143 search_update_factory_.NewRunnableMethod( |
| 143 &CookiesView::UpdateSearchResults), kSearchFilterDelayMs); | 144 &CookiesView::UpdateSearchResults), kSearchFilterDelayMs); |
| 144 } | 145 } |
| 145 | 146 |
| 146 bool CookiesView::HandleKeyEvent(views::Textfield* sender, | 147 bool CookiesView::HandleKeyEvent(views::Textfield* sender, |
| 147 const views::KeyEvent& key_event) { | 148 const views::KeyEvent& key_event) { |
| 148 if (key_event.key_code() == ui::VKEY_ESCAPE) { | 149 if (key_event.key_code() == ui::VKEY_ESCAPE) { |
| 149 ResetSearchQuery(); | 150 ResetSearchQuery(); |
| 150 } else if (key_event.key_code() == ui::VKEY_RETURN) { | 151 } else if (key_event.key_code() == ui::VKEY_RETURN) { |
| 151 search_update_factory_.RevokeAll(); | 152 search_update_factory_.RevokeAll(); |
| 152 UpdateSearchResults(); | 153 UpdateSearchResults(); |
| 153 } | 154 } |
| 154 return false; | 155 return false; |
| 155 } | 156 } |
| 156 | 157 |
| 157 /////////////////////////////////////////////////////////////////////////////// | 158 /////////////////////////////////////////////////////////////////////////////// |
| 158 // CookiesView, views::DialogDelegate implementation: | 159 // CookiesView, views::DialogDelegate implementation: |
| 159 | 160 |
| 161 int CookiesView::GetDialogButtons() const { |
| 162 return MessageBoxFlags::DIALOGBUTTON_CANCEL; |
| 163 } |
| 164 |
| 165 views::View* CookiesView::GetInitiallyFocusedView() { |
| 166 return search_field_; |
| 167 } |
| 168 |
| 169 bool CookiesView::CanResize() const { |
| 170 return true; |
| 171 } |
| 172 |
| 160 std::wstring CookiesView::GetWindowTitle() const { | 173 std::wstring CookiesView::GetWindowTitle() const { |
| 161 return UTF16ToWide( | 174 return UTF16ToWide( |
| 162 l10n_util::GetStringUTF16(IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE)); | 175 l10n_util::GetStringUTF16(IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE)); |
| 163 } | 176 } |
| 164 | 177 |
| 165 void CookiesView::WindowClosing() { | 178 void CookiesView::WindowClosing() { |
| 166 instance_ = NULL; | 179 instance_ = NULL; |
| 167 } | 180 } |
| 168 | 181 |
| 169 views::View* CookiesView::GetContentsView() { | 182 views::View* CookiesView::GetContentsView() { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 GetTotalNodeCount() > 1); | 404 GetTotalNodeCount() > 1); |
| 392 } | 405 } |
| 393 | 406 |
| 394 void CookiesView::UpdateVisibleDetailedInfo(views::View* view) { | 407 void CookiesView::UpdateVisibleDetailedInfo(views::View* view) { |
| 395 cookie_info_view_->SetVisible(view == cookie_info_view_); | 408 cookie_info_view_->SetVisible(view == cookie_info_view_); |
| 396 database_info_view_->SetVisible(view == database_info_view_); | 409 database_info_view_->SetVisible(view == database_info_view_); |
| 397 local_storage_info_view_->SetVisible(view == local_storage_info_view_); | 410 local_storage_info_view_->SetVisible(view == local_storage_info_view_); |
| 398 appcache_info_view_->SetVisible(view == appcache_info_view_); | 411 appcache_info_view_->SetVisible(view == appcache_info_view_); |
| 399 indexed_db_info_view_->SetVisible(view == indexed_db_info_view_); | 412 indexed_db_info_view_->SetVisible(view == indexed_db_info_view_); |
| 400 } | 413 } |
| OLD | NEW |