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/ui/webui/options/chromeos/about_page_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/about_page_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // license. | 47 // license. |
48 const char kBeginLink[] = "BEGIN_LINK"; | 48 const char kBeginLink[] = "BEGIN_LINK"; |
49 const char kEndLink[] = "END_LINK"; | 49 const char kEndLink[] = "END_LINK"; |
50 const char kBeginLinkChr[] = "BEGIN_LINK_CHR"; | 50 const char kBeginLinkChr[] = "BEGIN_LINK_CHR"; |
51 const char kBeginLinkOss[] = "BEGIN_LINK_OSS"; | 51 const char kBeginLinkOss[] = "BEGIN_LINK_OSS"; |
52 const char kEndLinkChr[] = "END_LINK_CHR"; | 52 const char kEndLinkChr[] = "END_LINK_CHR"; |
53 const char kEndLinkOss[] = "END_LINK_OSS"; | 53 const char kEndLinkOss[] = "END_LINK_OSS"; |
54 const char kBeginLinkCrosOss[] = "BEGIN_LINK_CROS_OSS"; | 54 const char kBeginLinkCrosOss[] = "BEGIN_LINK_CROS_OSS"; |
55 const char kEndLinkCrosOss[] = "END_LINK_CROS_OSS"; | 55 const char kEndLinkCrosOss[] = "END_LINK_CROS_OSS"; |
56 | 56 |
57 const char kDomainChangable[] = "domain"; | |
58 | |
59 // Returns a substring [start, end) from |text|. | 57 // Returns a substring [start, end) from |text|. |
60 std::string StringSubRange(const std::string& text, size_t start, | 58 std::string StringSubRange(const std::string& text, size_t start, |
61 size_t end) { | 59 size_t end) { |
62 DCHECK(end > start); | 60 DCHECK(end > start); |
63 return text.substr(start, end - start); | 61 return text.substr(start, end - start); |
64 } | 62 } |
65 | 63 |
66 bool CanChangeReleaseChannel() { | 64 bool CanChangeReleaseChannel() { |
67 // On non managed machines we have local owner who is the only one to change | 65 // On non managed machines we have local owner who is the only one to change |
68 // anything. | 66 // anything. |
69 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) | 67 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) |
70 return true; | 68 return true; |
71 // On a managed machine we delegate this setting to the users of the same | 69 // On a managed machine we delegate this setting to the users of the same |
72 // domain only if the policy value is "domain". | 70 // domain only if the policy value is "domain". |
73 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { | 71 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { |
74 std::string value; | 72 bool value = false; |
75 chromeos::CrosSettings::Get()->GetString(chromeos::kReleaseChannel, &value); | 73 if (!chromeos::CrosSettings::Get()->GetBoolean( |
76 if (value != kDomainChangable) | 74 chromeos::kReleaseChannelDelegated, &value) || !value) |
77 return false; | 75 return false; |
78 // Get the currently logged in user and strip the domain part only. | 76 // Get the currently logged in user and strip the domain part only. |
79 std::string domain = ""; | 77 std::string domain = ""; |
80 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); | 78 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); |
81 size_t at_pos = user.find('@'); | 79 size_t at_pos = user.find('@'); |
82 if (at_pos != std::string::npos && at_pos + 1 < user.length()) | 80 if (at_pos != std::string::npos && at_pos + 1 < user.length()) |
83 domain = user.substr(user.find('@') + 1); | 81 domain = user.substr(user.find('@') + 1); |
84 return domain == g_browser_process->browser_policy_connector()-> | 82 return domain == g_browser_process->browser_policy_connector()-> |
85 GetEnterpriseDomain(); | 83 GetEnterpriseDomain(); |
86 } | 84 } |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 // If UpdateEngineClient still has the observer, then the page handler | 446 // If UpdateEngineClient still has the observer, then the page handler |
449 // is valid. | 447 // is valid. |
450 AboutPageHandler* handler = observer->page_handler(); | 448 AboutPageHandler* handler = observer->page_handler(); |
451 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); | 449 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); |
452 handler->web_ui()->CallJavascriptFunction( | 450 handler->web_ui()->CallJavascriptFunction( |
453 "AboutPage.updateSelectedOptionCallback", *channel_string); | 451 "AboutPage.updateSelectedOptionCallback", *channel_string); |
454 } | 452 } |
455 } | 453 } |
456 | 454 |
457 } // namespace chromeos | 455 } // namespace chromeos |
OLD | NEW |