OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_page_actions_module.h" | 5 #include "chrome/browser/extensions/extension_page_actions_module.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (enable) { | 49 if (enable) { |
50 // Both of those are optional. | 50 // Both of those are optional. |
51 if (action->HasKey(keys::kTitleKey)) | 51 if (action->HasKey(keys::kTitleKey)) |
52 EXTENSION_FUNCTION_VALIDATE(action->GetString(keys::kTitleKey, &title)); | 52 EXTENSION_FUNCTION_VALIDATE(action->GetString(keys::kTitleKey, &title)); |
53 if (action->HasKey(keys::kIconIdKey)) { | 53 if (action->HasKey(keys::kIconIdKey)) { |
54 EXTENSION_FUNCTION_VALIDATE(action->GetInteger(keys::kIconIdKey, | 54 EXTENSION_FUNCTION_VALIDATE(action->GetInteger(keys::kIconIdKey, |
55 &icon_id)); | 55 &icon_id)); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 ExtensionAction2* page_action = dispatcher()->GetExtension()->page_action(); | 59 ExtensionAction* page_action = dispatcher()->GetExtension()->page_action(); |
60 if (!page_action) { | 60 if (!page_action) { |
61 error_ = kNoPageActionError; | 61 error_ = kNoPageActionError; |
62 return false; | 62 return false; |
63 } | 63 } |
64 | 64 |
65 if (icon_id < 0 || | 65 if (icon_id < 0 || |
66 static_cast<size_t>(icon_id) >= page_action->icon_paths()->size()) { | 66 static_cast<size_t>(icon_id) >= page_action->icon_paths()->size()) { |
67 error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds; | 67 error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds; |
68 return false; | 68 return false; |
69 } | 69 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 if (!InitCommon(tab_id)) | 255 if (!InitCommon(tab_id)) |
256 return false; | 256 return false; |
257 | 257 |
258 std::string text; | 258 std::string text; |
259 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); | 259 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); |
260 | 260 |
261 page_action_->SetBadgeText(tab_id, text); | 261 page_action_->SetBadgeText(tab_id, text); |
262 contents_->PageActionStateChanged(); | 262 contents_->PageActionStateChanged(); |
263 return true; | 263 return true; |
264 } | 264 } |
OLD | NEW |