Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: chrome/browser/extensions/extension_idle_api.cc

Issue 7649006: more changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another typo Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This implementation supposes a single extension thread and synchronized 5 // This implementation supposes a single extension thread and synchronized
6 // method invokation. 6 // method invokation.
7 7
8 #include "chrome/browser/extensions/extension_idle_api.h" 8 #include "chrome/browser/extensions/extension_idle_api.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (IDLE_STATE_ACTIVE == state) 67 if (IDLE_STATE_ACTIVE == state)
68 return keys::kStateActive; 68 return keys::kStateActive;
69 if (IDLE_STATE_IDLE == state) 69 if (IDLE_STATE_IDLE == state)
70 return keys::kStateIdle; 70 return keys::kStateIdle;
71 return keys::kStateLocked; 71 return keys::kStateLocked;
72 }; 72 };
73 73
74 // Helper function for reporting the idle state. The lifetime of the object 74 // Helper function for reporting the idle state. The lifetime of the object
75 // returned is controlled by the caller. 75 // returned is controlled by the caller.
76 StringValue* CreateIdleValue(IdleState idle_state) { 76 StringValue* CreateIdleValue(IdleState idle_state) {
77 StringValue* result = new StringValue(IdleStateToDescription(idle_state)); 77 StringValue* result =
78 base::StringValue::New(IdleStateToDescription(idle_state));
78 return result; 79 return result;
79 } 80 }
80 81
81 int CheckThresholdBounds(int timeout) { 82 int CheckThresholdBounds(int timeout) {
82 if (timeout < kMinThreshold) return kMinThreshold; 83 if (timeout < kMinThreshold) return kMinThreshold;
83 if (timeout > kMaxThreshold) return kMaxThreshold; 84 if (timeout > kMaxThreshold) return kMaxThreshold;
84 return timeout; 85 return timeout;
85 } 86 }
86 87
87 IdleState CalculateIdleStateAndUpdateTimestamp(int threshold) { 88 IdleState CalculateIdleStateAndUpdateTimestamp(int threshold) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 IdleState state) { 148 IdleState state) {
148 // Prepare the single argument of the current state. 149 // Prepare the single argument of the current state.
149 ListValue args; 150 ListValue args;
150 args.Append(CreateIdleValue(state)); 151 args.Append(CreateIdleValue(state));
151 std::string json_args; 152 std::string json_args;
152 base::JSONWriter::Write(&args, false, &json_args); 153 base::JSONWriter::Write(&args, false, &json_args);
153 154
154 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 155 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
155 keys::kOnStateChanged, json_args, profile, GURL()); 156 keys::kOnStateChanged, json_args, profile, GURL());
156 } 157 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_i18n_api.cc ('k') | chrome/browser/extensions/extension_info_private_api_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698