forked from crosswalk-project/chromium-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 233394 "Add extension permissions for new settings overrid..."
> Add extension permissions for new settings override API. > > Needed to create new class, mimicking SimpleAPIPermission, as opposed to inheriting from SetDisjunctionPermission, since we just needed to construct strings dynamically with extension properties. > > BUG=306128 > > Review URL: https://codereview.chromium.org/55533003 [email protected] Review URL: https://codereview.chromium.org/67363002 git-svn-id: svn://svn.chromium.org/chrome/branches/1700/src@233986 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
1 parent
26490eb
commit fb3d8ce
Showing
10 changed files
with
360 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
chrome/common/extensions/permissions/settings_override_permission.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/common/extensions/permissions/settings_override_permission.h" | ||
|
||
#include "base/strings/utf_string_conversions.h" | ||
#include "grit/generated_resources.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
|
||
|
||
namespace extensions { | ||
|
||
SettingsOverrideAPIPermission::SettingsOverrideAPIPermission( | ||
const APIPermissionInfo* permission, const std::string& setting_value) | ||
: APIPermission(permission), | ||
setting_value_(setting_value) { | ||
} | ||
|
||
SettingsOverrideAPIPermission::~SettingsOverrideAPIPermission() { | ||
} | ||
|
||
bool SettingsOverrideAPIPermission::HasMessages() const { | ||
return info()->message_id() > PermissionMessage::kNone; | ||
} | ||
|
||
PermissionMessages SettingsOverrideAPIPermission::GetMessages() const { | ||
DCHECK(HasMessages()); | ||
int string_id = -1; | ||
switch (id()) { | ||
case kHomepage: { | ||
string_id = IDS_EXTENSION_PROMPT_WARNING_HOME_PAGE_SETTING_OVERRIDE; | ||
break; | ||
} | ||
case kStartupPages: { | ||
string_id = IDS_EXTENSION_PROMPT_WARNING_START_PAGE_SETTING_OVERRIDE; | ||
break; | ||
} | ||
case kSearchProvider: { | ||
string_id = IDS_EXTENSION_PROMPT_WARNING_SEARCH_SETTINGS_OVERRIDE; | ||
break; | ||
} | ||
default: | ||
NOTREACHED(); | ||
} | ||
PermissionMessages result; | ||
result.push_back(PermissionMessage( | ||
info()->message_id(), | ||
l10n_util::GetStringFUTF16(string_id, UTF8ToUTF16(setting_value_)))); | ||
return result; | ||
} | ||
|
||
bool SettingsOverrideAPIPermission::Check( | ||
const APIPermission::CheckParam* param) const { | ||
return !param; | ||
} | ||
|
||
bool SettingsOverrideAPIPermission::Contains(const APIPermission* rhs) const { | ||
CHECK(info() == rhs->info()); | ||
return true; | ||
} | ||
|
||
bool SettingsOverrideAPIPermission::Equal(const APIPermission* rhs) const { | ||
if (this == rhs) | ||
return true; | ||
CHECK(info() == rhs->info()); | ||
return true; | ||
} | ||
|
||
bool SettingsOverrideAPIPermission::FromValue(const base::Value* value) { | ||
if (value) | ||
return false; | ||
return true; | ||
} | ||
|
||
scoped_ptr<base::Value> SettingsOverrideAPIPermission::ToValue() const { | ||
return scoped_ptr<base::Value>(); | ||
} | ||
|
||
APIPermission* SettingsOverrideAPIPermission::Clone() const { | ||
return new SettingsOverrideAPIPermission(info(), setting_value_); | ||
} | ||
|
||
APIPermission* SettingsOverrideAPIPermission::Diff( | ||
const APIPermission* rhs) const { | ||
CHECK(info() == rhs->info()); | ||
return NULL; | ||
} | ||
|
||
APIPermission* SettingsOverrideAPIPermission::Union( | ||
const APIPermission* rhs) const { | ||
CHECK(info() == rhs->info()); | ||
return new SettingsOverrideAPIPermission(info(), setting_value_); | ||
} | ||
|
||
APIPermission* SettingsOverrideAPIPermission::Intersect( | ||
const APIPermission* rhs) const { | ||
CHECK(info() == rhs->info()); | ||
return new SettingsOverrideAPIPermission(info(), setting_value_); | ||
} | ||
|
||
void SettingsOverrideAPIPermission::Write(IPC::Message* m) const { | ||
} | ||
|
||
bool SettingsOverrideAPIPermission::Read( | ||
const IPC::Message* m, PickleIterator* iter) { | ||
return true; | ||
} | ||
|
||
void SettingsOverrideAPIPermission::Log(std::string* log) const { | ||
} | ||
|
||
} // namespace extensions |
44 changes: 44 additions & 0 deletions
44
chrome/common/extensions/permissions/settings_override_permission.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_SETTINGS_OVERRIDE_PERMISSION_H_ | ||
#define CHROME_COMMON_EXTENSIONS_PERMISSIONS_SETTINGS_OVERRIDE_PERMISSION_H_ | ||
|
||
#include <string> | ||
|
||
#include "extensions/common/permissions/api_permission.h" | ||
|
||
namespace extensions { | ||
|
||
// Takes care of creating custom permission messages for extensions that | ||
// override settings. | ||
class SettingsOverrideAPIPermission : public APIPermission { | ||
public: | ||
SettingsOverrideAPIPermission( | ||
const APIPermissionInfo* permission, const std::string& setting_value); | ||
virtual ~SettingsOverrideAPIPermission(); | ||
|
||
// APIPermission overrides. | ||
virtual bool HasMessages() const OVERRIDE; | ||
virtual PermissionMessages GetMessages() const OVERRIDE; | ||
virtual bool Check(const APIPermission::CheckParam* param) const OVERRIDE; | ||
virtual bool Contains(const APIPermission* rhs) const OVERRIDE; | ||
virtual bool Equal(const APIPermission* rhs) const OVERRIDE; | ||
virtual bool FromValue(const base::Value* value) OVERRIDE; | ||
virtual scoped_ptr<base::Value> ToValue() const OVERRIDE; | ||
virtual APIPermission* Clone() const OVERRIDE; | ||
virtual APIPermission* Diff(const APIPermission* rhs) const OVERRIDE; | ||
virtual APIPermission* Union(const APIPermission* rhs) const OVERRIDE; | ||
virtual APIPermission* Intersect(const APIPermission* rhs) const OVERRIDE; | ||
virtual void Write(IPC::Message* m) const OVERRIDE; | ||
virtual bool Read(const IPC::Message* m, PickleIterator* iter) OVERRIDE; | ||
virtual void Log(std::string* log) const OVERRIDE; | ||
|
||
private: | ||
std::string setting_value_; | ||
}; | ||
|
||
} // namespace extensions | ||
|
||
#endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SETTINGS_OVERRIDE_PERMISSION_H_ |
Oops, something went wrong.