OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_action_runner.h" | 5 #include "chrome/browser/extensions/extension_action_runner.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 10 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/ptr_util.h" |
11 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
12 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
13 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 15 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
14 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 16 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
15 #include "chrome/browser/extensions/extension_action.h" | 17 #include "chrome/browser/extensions/extension_action.h" |
16 #include "chrome/browser/extensions/extension_action_manager.h" | 18 #include "chrome/browser/extensions/extension_action_manager.h" |
17 #include "chrome/browser/extensions/permissions_updater.h" | 19 #include "chrome/browser/extensions/permissions_updater.h" |
18 #include "chrome/browser/extensions/tab_helper.h" | 20 #include "chrome/browser/extensions/tab_helper.h" |
19 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/sessions/session_tab_helper.h" | 22 #include "chrome/browser/sessions/session_tab_helper.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 browser ? browser->window()->GetToolbarActionsBar() : nullptr; | 347 browser ? browser->window()->GetToolbarActionsBar() : nullptr; |
346 if (toolbar_actions_bar) { | 348 if (toolbar_actions_bar) { |
347 auto callback = | 349 auto callback = |
348 base::Bind(&ExtensionActionRunner::OnBlockedActionBubbleClosed, | 350 base::Bind(&ExtensionActionRunner::OnBlockedActionBubbleClosed, |
349 weak_factory_.GetWeakPtr(), extension->id()); | 351 weak_factory_.GetWeakPtr(), extension->id()); |
350 if (default_bubble_close_action_for_testing_) { | 352 if (default_bubble_close_action_for_testing_) { |
351 base::MessageLoop::current()->PostTask( | 353 base::MessageLoop::current()->PostTask( |
352 FROM_HERE, | 354 FROM_HERE, |
353 base::Bind(callback, *default_bubble_close_action_for_testing_)); | 355 base::Bind(callback, *default_bubble_close_action_for_testing_)); |
354 } else { | 356 } else { |
355 toolbar_actions_bar->ShowToolbarActionBubble(make_scoped_ptr( | 357 toolbar_actions_bar->ShowToolbarActionBubble(base::WrapUnique( |
356 new BlockedActionBubbleDelegate(callback, extension->id()))); | 358 new BlockedActionBubbleDelegate(callback, extension->id()))); |
357 } | 359 } |
358 } | 360 } |
359 } | 361 } |
360 | 362 |
361 void ExtensionActionRunner::OnBlockedActionBubbleClosed( | 363 void ExtensionActionRunner::OnBlockedActionBubbleClosed( |
362 const std::string& extension_id, | 364 const std::string& extension_id, |
363 ToolbarActionsBarBubbleDelegate::CloseAction action) { | 365 ToolbarActionsBarBubbleDelegate::CloseAction action) { |
364 // If the user agreed to refresh the page, do so. | 366 // If the user agreed to refresh the page, do so. |
365 if (action == ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE) { | 367 if (action == ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 UnloadedExtensionInfo::Reason reason) { | 416 UnloadedExtensionInfo::Reason reason) { |
415 PendingScriptMap::iterator iter = pending_scripts_.find(extension->id()); | 417 PendingScriptMap::iterator iter = pending_scripts_.find(extension->id()); |
416 if (iter != pending_scripts_.end()) { | 418 if (iter != pending_scripts_.end()) { |
417 pending_scripts_.erase(iter); | 419 pending_scripts_.erase(iter); |
418 ExtensionActionAPI::Get(browser_context_) | 420 ExtensionActionAPI::Get(browser_context_) |
419 ->NotifyPageActionsChanged(web_contents()); | 421 ->NotifyPageActionsChanged(web_contents()); |
420 } | 422 } |
421 } | 423 } |
422 | 424 |
423 } // namespace extensions | 425 } // namespace extensions |
OLD | NEW |