| 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/api/extension_action/extension_page_actions_
api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" | 10 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_tab_helper.h" | 12 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 13 #include "chrome/browser/extensions/extension_tab_util.h" | 13 #include "chrome/browser/extensions/extension_tab_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/extensions/extension_action.h" | 18 #include "chrome/common/extensions/extension_action.h" |
| 19 #include "chrome/common/extensions/extension_error_utils.h" | 19 #include "chrome/common/extensions/extension_error_utils.h" |
| 20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 | 22 |
| 23 using content::NavigationEntry; | 23 using content::NavigationEntry; |
| 24 | 24 |
| 25 namespace keys = extension_page_actions_api_constants; | 25 namespace keys = extension_page_actions_api_constants; |
| 26 | 26 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 error_ = kNoPageActionError; | 68 error_ = kNoPageActionError; |
| 69 return false; | 69 return false; |
| 70 } | 70 } |
| 71 | 71 |
| 72 if (icon_id < 0 || | 72 if (icon_id < 0 || |
| 73 static_cast<size_t>(icon_id) >= page_action->icon_paths()->size()) { | 73 static_cast<size_t>(icon_id) >= page_action->icon_paths()->size()) { |
| 74 error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds; | 74 error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds; |
| 75 return false; | 75 return false; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Find the TabContentsWrapper that contains this tab id. | 78 // Find the TabContents that contains this tab id. |
| 79 TabContentsWrapper* contents = NULL; | 79 TabContents* contents = NULL; |
| 80 bool result = ExtensionTabUtil::GetTabById( | 80 bool result = ExtensionTabUtil::GetTabById( |
| 81 tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL); | 81 tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL); |
| 82 if (!result || !contents) { | 82 if (!result || !contents) { |
| 83 error_ = ExtensionErrorUtils::FormatErrorMessage( | 83 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 84 kNoTabError, base::IntToString(tab_id)); | 84 kNoTabError, base::IntToString(tab_id)); |
| 85 return false; | 85 return false; |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Make sure the URL hasn't changed. | 88 // Make sure the URL hasn't changed. |
| 89 NavigationEntry* entry = | 89 NavigationEntry* entry = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool EnablePageActionsFunction::RunImpl() { | 105 bool EnablePageActionsFunction::RunImpl() { |
| 106 return SetPageActionEnabled(true); | 106 return SetPageActionEnabled(true); |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool DisablePageActionsFunction::RunImpl() { | 109 bool DisablePageActionsFunction::RunImpl() { |
| 110 return SetPageActionEnabled(false); | 110 return SetPageActionEnabled(false); |
| 111 } | 111 } |
| OLD | NEW |