OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_window_controller.h" | 5 #include "chrome/browser/extensions/extension_window_controller.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/extension_function.h" | |
8 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 9 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
9 #include "chrome/browser/extensions/extension_window_list.h" | 10 #include "chrome/browser/extensions/extension_window_list.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/base_window.h" | 12 #include "chrome/browser/ui/base_window.h" |
12 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
13 | 14 |
14 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
15 // ExtensionWindowController | 16 // ExtensionWindowController |
16 | 17 |
17 ExtensionWindowController::ExtensionWindowController(BaseWindow* window, | 18 ExtensionWindowController::ExtensionWindowController(BaseWindow* window, |
18 Profile* profile) : | 19 Profile* profile) : |
19 window_(window), | 20 window_(window), |
20 profile_(profile) { | 21 profile_(profile) { |
21 ExtensionWindowList::GetInstance()->AddExtensionWindow(this); | 22 ExtensionWindowList::GetInstance()->AddExtensionWindow(this); |
22 } | 23 } |
23 | 24 |
24 ExtensionWindowController::~ExtensionWindowController() { | 25 ExtensionWindowController::~ExtensionWindowController() { |
25 ExtensionWindowList::GetInstance()->RemoveExtensionWindow(this); | 26 ExtensionWindowList::GetInstance()->RemoveExtensionWindow(this); |
26 } | 27 } |
27 | 28 |
28 bool ExtensionWindowController::MatchesProfile( | 29 bool ExtensionWindowController::IsVisibleToFunction( |
29 Profile* match_profile, | 30 UIThreadExtensionFunction* function) const { |
stevenjb
2012/05/21 19:22:52
It seems like this might be better if this were in
Mihai Parparita -not on Chrome
2012/05/21 21:10:06
Done.
| |
30 ProfileMatchType match_type) const { | 31 const Extension* extension = function->GetExtension(); |
31 return ((profile_ == match_profile) || | 32 // |extension| is NULL for unit tests only. |
32 (match_type == MATCH_INCOGNITO && | 33 if (extension != NULL && !IsVisibleToExtension(function->GetExtension())) |
stevenjb
2012/05/21 19:22:52
This would become window->IsVisibleToExtension(Get
| |
33 (match_profile->HasOffTheRecordProfile() && | 34 return false; |
34 match_profile->GetOffTheRecordProfile() == profile_))); | 35 |
36 if (function->profile() == profile_) | |
stevenjb
2012/05/21 19:22:52
profile() == window->profile()
| |
37 return true; | |
38 | |
39 if (!function->include_incognito()) | |
40 return false; | |
41 | |
42 return function->profile()->HasOffTheRecordProfile() && | |
43 function->profile()->GetOffTheRecordProfile() == profile_; | |
stevenjb
2012/05/21 19:22:52
The above has more to do with function than with w
| |
35 } | 44 } |
36 | 45 |
37 Browser* ExtensionWindowController::GetBrowser() const { | 46 Browser* ExtensionWindowController::GetBrowser() const { |
38 return NULL; | 47 return NULL; |
39 } | 48 } |
40 | 49 |
41 namespace keys = extension_tabs_module_constants; | 50 namespace keys = extension_tabs_module_constants; |
42 | 51 |
43 base::DictionaryValue* ExtensionWindowController::CreateWindowValue() const { | 52 base::DictionaryValue* ExtensionWindowController::CreateWindowValue() const { |
44 DictionaryValue* result = new DictionaryValue(); | 53 DictionaryValue* result = new DictionaryValue(); |
(...skipping 21 matching lines...) Expand all Loading... | |
66 bounds = window()->GetRestoredBounds(); | 75 bounds = window()->GetRestoredBounds(); |
67 else | 76 else |
68 bounds = window()->GetBounds(); | 77 bounds = window()->GetBounds(); |
69 result->SetInteger(keys::kLeftKey, bounds.x()); | 78 result->SetInteger(keys::kLeftKey, bounds.x()); |
70 result->SetInteger(keys::kTopKey, bounds.y()); | 79 result->SetInteger(keys::kTopKey, bounds.y()); |
71 result->SetInteger(keys::kWidthKey, bounds.width()); | 80 result->SetInteger(keys::kWidthKey, bounds.width()); |
72 result->SetInteger(keys::kHeightKey, bounds.height()); | 81 result->SetInteger(keys::kHeightKey, bounds.height()); |
73 | 82 |
74 return result; | 83 return result; |
75 } | 84 } |
OLD | NEW |