Switch TestFrameNavigationObserver to DidCommitProvisionalLoadForFrame.
[chromium-blink-merge.git] / third_party / google_input_tools / src / chrome / os / inputview / featuretracker.js
blob22a4a9e47e44aac635cdb8f38d1575dae2966f59
1 // Copyright 2015 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
14 goog.provide('i18n.input.chrome.inputview.FeatureTracker');
16 goog.require('goog.object');
17 goog.require('i18n.input.chrome.inputview.FeatureName');
19 goog.scope(function() {
20 var Adapter = i18n.input.chrome.inputview.Adapter;
21 var FeatureName = i18n.input.chrome.inputview.FeatureName;
24 /**
25 * Controller for experimental features.
27 * @constructor
29 i18n.input.chrome.inputview.FeatureTracker = function() {
31 /**
32 * Whether experimental flags is enabled.
34 * @private {Object.<string, boolean>}
36 this.features_ = {};
38 /**
39 * Features that are enabled by default. Any feature not on this list is
40 * disabled unless the runtime --enable-inputview-{feature} flag is present.
42 * @const
43 * @private {!Array<FeatureName>}
45 this.ENABLED_BY_DEFAULT_ = [];
48 var FeatureTracker = i18n.input.chrome.inputview.FeatureTracker;
51 /**
52 * Whether the feature is enabled.
54 * @param {!FeatureName} feature .
55 * @return {boolean}
57 FeatureTracker.prototype.isEnabled = function(feature) {
58 if (feature in this.features_) {
59 return this.features_[feature];
61 return (this.ENABLED_BY_DEFAULT_.indexOf(feature) >= 0) ||
62 !!this.features_[FeatureName.EXPERIMENTAL];
66 /**
67 * Inits the feature tracker.
69 * @param {!Object} config The keyboard config.
71 FeatureTracker.prototype.initialize = function(config) {
72 if (config.features) {
73 var features = config.features;
74 // Parse the run time flags.
75 for (var i = 0; i < features.length; i++) {
76 var pieces = features[i].split('-');
77 var state = pieces.pop();
78 if (state == 'enabled') {
79 this.features_[pieces.join('-')] = true;
80 } else if (state == 'disabled') {
81 this.features_[pieces.join('-')] = false;
82 } else {
83 console.error('Unrecognized flag: ' + features[i]);
86 } else {
87 console.error('API Error. Features not present in config.');
88 return;
92 }); // goog.scope