| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_omnibox_api.h" | 5 #include "chrome/browser/extensions/extension_omnibox_api.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 // static | 71 // static |
| 72 bool ExtensionOmniboxEventRouter::OnInputChanged( | 72 bool ExtensionOmniboxEventRouter::OnInputChanged( |
| 73 Profile* profile, const std::string& extension_id, | 73 Profile* profile, const std::string& extension_id, |
| 74 const std::string& input, int suggest_id) { | 74 const std::string& input, int suggest_id) { |
| 75 if (!profile->GetExtensionEventRouter()->ExtensionHasEventListener( | 75 if (!profile->GetExtensionEventRouter()->ExtensionHasEventListener( |
| 76 extension_id, events::kOnInputChanged)) | 76 extension_id, events::kOnInputChanged)) |
| 77 return false; | 77 return false; |
| 78 | 78 |
| 79 ListValue args; | 79 ListValue args; |
| 80 args.Set(0, Value::CreateStringValue(input)); | 80 args.Set(0, base::StringValue::New(input)); |
| 81 args.Set(1, Value::CreateIntegerValue(suggest_id)); | 81 args.Set(1, base::NumberValue::New(suggest_id)); |
| 82 std::string json_args; | 82 std::string json_args; |
| 83 base::JSONWriter::Write(&args, false, &json_args); | 83 base::JSONWriter::Write(&args, false, &json_args); |
| 84 | 84 |
| 85 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 85 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 86 extension_id, events::kOnInputChanged, json_args, profile, GURL()); | 86 extension_id, events::kOnInputChanged, json_args, profile, GURL()); |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // static | 90 // static |
| 91 void ExtensionOmniboxEventRouter::OnInputEntered( | 91 void ExtensionOmniboxEventRouter::OnInputEntered( |
| 92 Profile* profile, const std::string& extension_id, | 92 Profile* profile, const std::string& extension_id, |
| 93 const std::string& input) { | 93 const std::string& input) { |
| 94 ListValue args; | 94 ListValue args; |
| 95 args.Set(0, Value::CreateStringValue(input)); | 95 args.Set(0, base::StringValue::New(input)); |
| 96 std::string json_args; | 96 std::string json_args; |
| 97 base::JSONWriter::Write(&args, false, &json_args); | 97 base::JSONWriter::Write(&args, false, &json_args); |
| 98 | 98 |
| 99 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 99 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 100 extension_id, events::kOnInputEntered, json_args, profile, GURL()); | 100 extension_id, events::kOnInputEntered, json_args, profile, GURL()); |
| 101 | 101 |
| 102 NotificationService::current()->Notify( | 102 NotificationService::current()->Notify( |
| 103 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, | 103 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, |
| 104 Source<Profile>(profile), NotificationService::NoDetails()); | 104 Source<Profile>(profile), NotificationService::NoDetails()); |
| 105 } | 105 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | 285 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); |
| 286 | 286 |
| 287 // Look at the preferences to find the right launch container. If no | 287 // Look at the preferences to find the right launch container. If no |
| 288 // preference is set, launch as a regular tab. | 288 // preference is set, launch as a regular tab. |
| 289 extension_misc::LaunchContainer launch_container = | 289 extension_misc::LaunchContainer launch_container = |
| 290 service->extension_prefs()->GetLaunchContainer( | 290 service->extension_prefs()->GetLaunchContainer( |
| 291 extension, ExtensionPrefs::LAUNCH_REGULAR); | 291 extension, ExtensionPrefs::LAUNCH_REGULAR); |
| 292 | 292 |
| 293 Browser::OpenApplication(profile, extension, launch_container, disposition); | 293 Browser::OpenApplication(profile, extension, launch_container, disposition); |
| 294 } | 294 } |
| OLD | NEW |