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_action.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/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/extensions/location_bar_controller.h" | 14 #include "chrome/browser/extensions/location_bar_controller.h" |
| 15 #include "chrome/browser/extensions/tab_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/extensions/extension_action.h" | |
20 #include "chrome/common/extensions/extension_error_utils.h" | 20 #include "chrome/common/extensions/extension_error_utils.h" |
21 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 | 23 |
24 using content::NavigationEntry; | 24 using content::NavigationEntry; |
25 | 25 |
26 namespace keys = extension_page_actions_api_constants; | 26 namespace keys = extension_page_actions_api_constants; |
27 | 27 |
28 namespace { | 28 namespace { |
29 // Errors. | 29 // Errors. |
(...skipping 27 matching lines...) Expand all Loading... |
57 if (enable) { | 57 if (enable) { |
58 // Both of those are optional. | 58 // Both of those are optional. |
59 if (action->HasKey(keys::kTitleKey)) | 59 if (action->HasKey(keys::kTitleKey)) |
60 EXTENSION_FUNCTION_VALIDATE(action->GetString(keys::kTitleKey, &title)); | 60 EXTENSION_FUNCTION_VALIDATE(action->GetString(keys::kTitleKey, &title)); |
61 if (action->HasKey(keys::kIconIdKey)) { | 61 if (action->HasKey(keys::kIconIdKey)) { |
62 EXTENSION_FUNCTION_VALIDATE(action->GetInteger(keys::kIconIdKey, | 62 EXTENSION_FUNCTION_VALIDATE(action->GetInteger(keys::kIconIdKey, |
63 &icon_id)); | 63 &icon_id)); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 ExtensionAction* page_action = GetExtension()->page_action(); | 67 ExtensionAction* page_action = GetPageAction(profile(), *GetExtension()); |
68 if (!page_action) { | 68 if (!page_action) { |
69 error_ = kNoPageActionError; | 69 error_ = kNoPageActionError; |
70 return false; | 70 return false; |
71 } | 71 } |
72 | 72 |
73 if (icon_id < 0 || | 73 if (icon_id < 0 || |
74 static_cast<size_t>(icon_id) >= page_action->icon_paths()->size()) { | 74 static_cast<size_t>(icon_id) >= page_action->icon_paths()->size()) { |
75 error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds; | 75 error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds; |
76 return false; | 76 return false; |
77 } | 77 } |
(...skipping 26 matching lines...) Expand all Loading... |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 bool EnablePageActionsFunction::RunImpl() { | 107 bool EnablePageActionsFunction::RunImpl() { |
108 return SetPageActionEnabled(true); | 108 return SetPageActionEnabled(true); |
109 } | 109 } |
110 | 110 |
111 bool DisablePageActionsFunction::RunImpl() { | 111 bool DisablePageActionsFunction::RunImpl() { |
112 return SetPageActionEnabled(false); | 112 return SetPageActionEnabled(false); |
113 } | 113 } |
OLD | NEW |