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/options/exceptions_view.h" | 5 #include "chrome/browser/views/options/exceptions_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "base/gfx/rect.h" | 11 #include "base/gfx/rect.h" |
12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
13 #include "grit/locale_settings.h" | 13 #include "grit/locale_settings.h" |
14 #include "views/controls/button/native_button.h" | 14 #include "views/controls/button/native_button.h" |
15 #include "views/controls/table/table_view.h" | 15 #include "views/controls/table/table_view.h" |
16 #include "views/grid_layout.h" | 16 #include "views/grid_layout.h" |
17 #include "views/standard_layout.h" | 17 #include "views/standard_layout.h" |
18 #include "views/window/window.h" | 18 #include "views/window/window.h" |
19 | 19 |
20 static const int kExceptionsViewInsetSize = 5; | 20 static const int kExceptionsViewInsetSize = 5; |
21 static ExceptionsView* instances[CONTENT_SETTINGS_NUM_TYPES] = { NULL }; | |
21 | 22 |
22 // static | 23 // static |
23 void ExceptionsView::ShowExceptionsWindow(gfx::NativeWindow parent, | 24 void ExceptionsView::ShowExceptionsWindow(gfx::NativeWindow parent, |
24 HostContentSettingsMap* map, | 25 HostContentSettingsMap* map, |
25 ContentSettingsType type) { | 26 ContentSettingsType content_type) { |
26 views::Window::CreateChromeWindow( | 27 if (!instances[content_type]) { |
27 parent, gfx::Rect(), new ExceptionsView(map, type))->Show(); | 28 instances[content_type] = new ExceptionsView(map, content_type); |
29 views::Window::CreateChromeWindow(parent, gfx::Rect(), | |
30 instances[content_type]); | |
31 // The window is alive by itself now... | |
sky
2010/02/09 21:32:24
I don't get what this comment means.
| |
32 } | |
33 | |
34 // This will show invisible windows and bring visible windows to the front. | |
35 instances[content_type]->window()->Show(); | |
28 } | 36 } |
29 | 37 |
30 ExceptionsView::~ExceptionsView() { | 38 ExceptionsView::~ExceptionsView() { |
39 instances[model_.content_type()] = NULL; | |
31 table_->SetModel(NULL); | 40 table_->SetModel(NULL); |
32 } | 41 } |
33 | 42 |
34 void ExceptionsView::OnSelectionChanged() { | 43 void ExceptionsView::OnSelectionChanged() { |
35 UpdateButtonState(); | 44 UpdateButtonState(); |
36 } | 45 } |
37 | 46 |
38 void ExceptionsView::OnDoubleClick() { | 47 void ExceptionsView::OnDoubleClick() { |
39 if (table_->SelectedRowCount() == 1) | 48 if (table_->SelectedRowCount() == 1) |
40 Edit(); | 49 Edit(); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 } | 245 } |
237 | 246 |
238 UpdateButtonState(); | 247 UpdateButtonState(); |
239 } | 248 } |
240 | 249 |
241 void ExceptionsView::RemoveAll() { | 250 void ExceptionsView::RemoveAll() { |
242 model_.RemoveAll(); | 251 model_.RemoveAll(); |
243 | 252 |
244 UpdateButtonState(); | 253 UpdateButtonState(); |
245 } | 254 } |
OLD | NEW |