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

Side by Side Diff: chrome/browser/extensions/api/extension_action/extension_action_api.cc

Issue 495193004: Remove extra from deprecated pageActions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « chrome/browser/extensions/api/extension_action/extension_action_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extension_action/extension_action_api.h" 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 // static 312 // static
313 void ExtensionActionAPI::BrowserActionExecuted( 313 void ExtensionActionAPI::BrowserActionExecuted(
314 content::BrowserContext* context, 314 content::BrowserContext* context,
315 const ExtensionAction& browser_action, 315 const ExtensionAction& browser_action,
316 WebContents* web_contents) { 316 WebContents* web_contents) {
317 ExtensionActionExecuted(context, browser_action, web_contents); 317 ExtensionActionExecuted(context, browser_action, web_contents);
318 } 318 }
319 319
320 // static 320 // static
321 void ExtensionActionAPI::PageActionExecuted(content::BrowserContext* context, 321 void ExtensionActionAPI::PageActionExecuted(content::BrowserContext* context,
Devlin 2014/08/21 21:44:38 I'll clean up the rest of this in an (unrelated) C
322 const ExtensionAction& page_action, 322 const ExtensionAction& page_action,
323 int tab_id, 323 int tab_id,
324 const std::string& url, 324 const std::string& url,
325 int button) { 325 int button) {
326 DispatchOldPageActionEvent(context,
327 page_action.extension_id(),
328 page_action.id(),
329 tab_id,
330 url,
331 button);
332 WebContents* web_contents = NULL; 326 WebContents* web_contents = NULL;
333 if (!ExtensionTabUtil::GetTabById( 327 if (!ExtensionTabUtil::GetTabById(
334 tab_id, 328 tab_id,
335 Profile::FromBrowserContext(context), 329 Profile::FromBrowserContext(context),
336 context->IsOffTheRecord(), 330 context->IsOffTheRecord(),
337 NULL, 331 NULL,
338 NULL, 332 NULL,
339 &web_contents, 333 &web_contents,
340 NULL)) { 334 NULL)) {
341 return; 335 return;
(...skipping 11 matching lines...) Expand all
353 return; 347 return;
354 348
355 scoped_ptr<Event> event(new Event(event_name, event_args.Pass())); 349 scoped_ptr<Event> event(new Event(event_name, event_args.Pass()));
356 event->restrict_to_browser_context = context; 350 event->restrict_to_browser_context = context;
357 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; 351 event->user_gesture = EventRouter::USER_GESTURE_ENABLED;
358 EventRouter::Get(context) 352 EventRouter::Get(context)
359 ->DispatchEventToExtension(extension_id, event.Pass()); 353 ->DispatchEventToExtension(extension_id, event.Pass());
360 } 354 }
361 355
362 // static 356 // static
363 void ExtensionActionAPI::DispatchOldPageActionEvent(
364 content::BrowserContext* context,
365 const std::string& extension_id,
366 const std::string& page_action_id,
367 int tab_id,
368 const std::string& url,
369 int button) {
370 scoped_ptr<base::ListValue> args(new base::ListValue());
371 args->Append(new base::StringValue(page_action_id));
372
373 base::DictionaryValue* data = new base::DictionaryValue();
374 data->Set(page_actions_keys::kTabIdKey, new base::FundamentalValue(tab_id));
375 data->Set(page_actions_keys::kTabUrlKey, new base::StringValue(url));
376 data->Set(page_actions_keys::kButtonKey,
377 new base::FundamentalValue(button));
378 args->Append(data);
379
380 DispatchEventToExtension(context, extension_id, "pageActions", args.Pass());
381 }
382
383 // static
384 void ExtensionActionAPI::ExtensionActionExecuted( 357 void ExtensionActionAPI::ExtensionActionExecuted(
385 content::BrowserContext* context, 358 content::BrowserContext* context,
386 const ExtensionAction& extension_action, 359 const ExtensionAction& extension_action,
387 WebContents* web_contents) { 360 WebContents* web_contents) {
388 const char* event_name = NULL; 361 const char* event_name = NULL;
389 switch (extension_action.action_type()) { 362 switch (extension_action.action_type()) {
390 case ActionInfo::TYPE_BROWSER: 363 case ActionInfo::TYPE_BROWSER:
391 event_name = "browserAction.onClicked"; 364 event_name = "browserAction.onClicked";
392 break; 365 break;
393 case ActionInfo::TYPE_PAGE: 366 case ActionInfo::TYPE_PAGE:
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || 800 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP ||
828 host->extension()->id() != extension_->id()) 801 host->extension()->id() != extension_->id())
829 return; 802 return;
830 803
831 SendResponse(true); 804 SendResponse(true);
832 response_sent_ = true; 805 response_sent_ = true;
833 registrar_.RemoveAll(); 806 registrar_.RemoveAll();
834 } 807 }
835 808
836 } // namespace extensions 809 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/extension_action/extension_action_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698