// Copyright (c) 2012 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.

function set(message) {
  var errorObject = { "message": message };
  if (chrome.extension)
    chrome.extension.lastError = errorObject;
  chrome.runtime.lastError = errorObject;
};

function clear() {
  if (chrome.extension)
    delete chrome.extension.lastError;
  delete chrome.runtime.lastError;
};

exports.clear = clear;
exports.set = set;

// Copyright (c) 2012 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.

requireNative('runtime');

function set(message) {
  var errorObject = { 'message': message };
  if (chrome.extension)
    chrome.extension.lastError = errorObject;
  chrome.runtime.lastError = errorObject;
};

function clear() {
  if (chrome.extension)
    delete chrome.extension.lastError;
  delete chrome.runtime.lastError;
};

exports.clear = clear;
exports.set = set;

Fix to problem of chrome.runtime sometimes not being defined.
Fix to problem of chrome.runtime sometimes not being defined.

There appears to be some non-determinism in the order that the chrome.runtime
namespace gets set up relative to when the last_error.js file is loaded. This adds a require statement that should hopefully resolve this.

BUG=136352
TEST=Chrome webstore should function normally

Review URL: https://chromiumcodereview.appspot.com/10748011

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@145964 0039d316-1c4b-4281-b951-d872f2087c98
