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

Side by Side Diff: chrome/browser/extensions/api/omnibox/omnibox_api.cc

Issue 11418043: Remove TabContents from OmniboxEditController and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros Created 8 years, 1 month 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) 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/api/omnibox/omnibox_api.h" 5 #include "chrome/browser/extensions/api/omnibox/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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/extensions/event_router.h" 13 #include "chrome/browser/extensions/event_router.h"
14 #include "chrome/browser/extensions/extension_prefs.h" 14 #include "chrome/browser/extensions/extension_prefs.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_system.h" 16 #include "chrome/browser/extensions/extension_system.h"
17 #include "chrome/browser/extensions/tab_helper.h" 17 #include "chrome/browser/extensions/tab_helper.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/search_engines/template_url.h" 19 #include "chrome/browser/search_engines/template_url.h"
20 #include "chrome/browser/ui/tab_contents/tab_contents.h"
21 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/extensions/extension_constants.h" 21 #include "chrome/common/extensions/extension_constants.h"
23 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
24 23
25 namespace events { 24 namespace events {
26 const char kOnInputStarted[] = "omnibox.onInputStarted"; 25 const char kOnInputStarted[] = "omnibox.onInputStarted";
27 const char kOnInputChanged[] = "omnibox.onInputChanged"; 26 const char kOnInputChanged[] = "omnibox.onInputChanged";
28 const char kOnInputEntered[] = "omnibox.onInputEntered"; 27 const char kOnInputEntered[] = "omnibox.onInputEntered";
29 const char kOnInputCancelled[] = "omnibox.onInputCancelled"; 28 const char kOnInputCancelled[] = "omnibox.onInputCancelled";
30 } // namespace events 29 } // namespace events
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 args->Set(1, Value::CreateIntegerValue(suggest_id)); 69 args->Set(1, Value::CreateIntegerValue(suggest_id));
71 70
72 extensions::ExtensionSystem::Get(profile)->event_router()-> 71 extensions::ExtensionSystem::Get(profile)->event_router()->
73 DispatchEventToExtension(extension_id, events::kOnInputChanged, 72 DispatchEventToExtension(extension_id, events::kOnInputChanged,
74 args.Pass(), profile, GURL()); 73 args.Pass(), profile, GURL());
75 return true; 74 return true;
76 } 75 }
77 76
78 // static 77 // static
79 void ExtensionOmniboxEventRouter::OnInputEntered( 78 void ExtensionOmniboxEventRouter::OnInputEntered(
80 TabContents* tab_contents, 79 content::WebContents* web_contents,
81 const std::string& extension_id, 80 const std::string& extension_id,
82 const std::string& input) { 81 const std::string& input) {
83 Profile* profile = tab_contents->profile(); 82 Profile* profile =
83 Profile::FromBrowserContext(web_contents->GetBrowserContext());
84 84
85 const Extension* extension = 85 const Extension* extension =
86 ExtensionSystem::Get(profile)->extension_service()->extensions()-> 86 ExtensionSystem::Get(profile)->extension_service()->extensions()->
87 GetByID(extension_id); 87 GetByID(extension_id);
88 CHECK(extension); 88 CHECK(extension);
89 extensions::TabHelper::FromWebContents(tab_contents->web_contents())-> 89 extensions::TabHelper::FromWebContents(web_contents)->
90 active_tab_permission_granter()->GrantIfRequested(extension); 90 active_tab_permission_granter()->GrantIfRequested(extension);
91 91
92 scoped_ptr<ListValue> args(new ListValue()); 92 scoped_ptr<ListValue> args(new ListValue());
93 args->Set(0, Value::CreateStringValue(input)); 93 args->Set(0, Value::CreateStringValue(input));
94 94
95 extensions::ExtensionSystem::Get(profile)->event_router()-> 95 extensions::ExtensionSystem::Get(profile)->event_router()->
96 DispatchEventToExtension(extension_id, events::kOnInputEntered, 96 DispatchEventToExtension(extension_id, events::kOnInputEntered,
97 args.Pass(), profile, GURL()); 97 args.Pass(), profile, GURL());
98 98
99 content::NotificationService::current()->Notify( 99 content::NotificationService::current()->Notify(
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 for (size_t i = 0; i < description_styles.size(); ++i) { 305 for (size_t i = 0; i < description_styles.size(); ++i) {
306 if (description_styles[i].offset > placeholder) 306 if (description_styles[i].offset > placeholder)
307 description_styles[i].offset += replacement.length() - 2; 307 description_styles[i].offset += replacement.length() - 2;
308 } 308 }
309 } 309 }
310 310
311 match->contents.assign(description); 311 match->contents.assign(description);
312 } 312 }
313 313
314 } // namespace extensions 314 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698