| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 Profile* profile, const std::string& extension_id, | 75 Profile* profile, const std::string& extension_id, |
| 76 const std::string& input, int suggest_id) { | 76 const std::string& input, int suggest_id) { |
| 77 if (!profile->GetExtensionEventRouter()->ExtensionHasEventListener( | 77 if (!profile->GetExtensionEventRouter()->ExtensionHasEventListener( |
| 78 extension_id, events::kOnInputChanged)) | 78 extension_id, events::kOnInputChanged)) |
| 79 return false; | 79 return false; |
| 80 | 80 |
| 81 ListValue args; | 81 ListValue args; |
| 82 args.Set(0, Value::CreateStringValue(input)); | 82 args.Set(0, Value::CreateStringValue(input)); |
| 83 args.Set(1, Value::CreateIntegerValue(suggest_id)); | 83 args.Set(1, Value::CreateIntegerValue(suggest_id)); |
| 84 std::string json_args; | 84 std::string json_args; |
| 85 base::JSONWriter::Write(&args, false, &json_args); | 85 base::JSONWriter::Write(&args, &json_args); |
| 86 | 86 |
| 87 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 87 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 88 extension_id, events::kOnInputChanged, json_args, profile, GURL()); | 88 extension_id, events::kOnInputChanged, json_args, profile, GURL()); |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // static | 92 // static |
| 93 void ExtensionOmniboxEventRouter::OnInputEntered( | 93 void ExtensionOmniboxEventRouter::OnInputEntered( |
| 94 Profile* profile, const std::string& extension_id, | 94 Profile* profile, const std::string& extension_id, |
| 95 const std::string& input) { | 95 const std::string& input) { |
| 96 ListValue args; | 96 ListValue args; |
| 97 args.Set(0, Value::CreateStringValue(input)); | 97 args.Set(0, Value::CreateStringValue(input)); |
| 98 std::string json_args; | 98 std::string json_args; |
| 99 base::JSONWriter::Write(&args, false, &json_args); | 99 base::JSONWriter::Write(&args, &json_args); |
| 100 | 100 |
| 101 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 101 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 102 extension_id, events::kOnInputEntered, json_args, profile, GURL()); | 102 extension_id, events::kOnInputEntered, json_args, profile, GURL()); |
| 103 | 103 |
| 104 content::NotificationService::current()->Notify( | 104 content::NotificationService::current()->Notify( |
| 105 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, | 105 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, |
| 106 content::Source<Profile>(profile), | 106 content::Source<Profile>(profile), |
| 107 content::NotificationService::NoDetails()); | 107 content::NotificationService::NoDetails()); |
| 108 } | 108 } |
| 109 | 109 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 // Look at the preferences to find the right launch container. If no | 289 // Look at the preferences to find the right launch container. If no |
| 290 // preference is set, launch as a regular tab. | 290 // preference is set, launch as a regular tab. |
| 291 extension_misc::LaunchContainer launch_container = | 291 extension_misc::LaunchContainer launch_container = |
| 292 service->extension_prefs()->GetLaunchContainer( | 292 service->extension_prefs()->GetLaunchContainer( |
| 293 extension, ExtensionPrefs::LAUNCH_REGULAR); | 293 extension, ExtensionPrefs::LAUNCH_REGULAR); |
| 294 | 294 |
| 295 Browser::OpenApplication(profile, extension, launch_container, GURL(), | 295 Browser::OpenApplication(profile, extension, launch_container, GURL(), |
| 296 disposition); | 296 disposition); |
| 297 } | 297 } |
| OLD | NEW |