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

Side by Side Diff: chrome/browser/extensions/extension_page_actions_module.cc

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_number_conversions.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"
11 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" 11 #include "chrome/browser/extensions/extension_page_actions_module_constants.h"
12 #include "chrome/browser/extensions/extension_tabs_module.h" 12 #include "chrome/browser/extensions/extension_tabs_module.h"
13 #include "chrome/browser/extensions/extensions_service.h" 13 #include "chrome/browser/extensions/extensions_service.h"
14 #include "chrome/browser/tab_contents/navigation_entry.h" 14 #include "chrome/browser/tab_contents/navigation_entry.h"
15 #include "chrome/browser/tab_contents/tab_contents.h" 15 #include "chrome/browser/tab_contents/tab_contents.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/extension_action.h" 17 #include "chrome/common/extensions/extension_action.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 static_cast<size_t>(icon_id) >= page_action->icon_paths()->size()) { 64 static_cast<size_t>(icon_id) >= page_action->icon_paths()->size()) {
65 error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds; 65 error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds;
66 return false; 66 return false;
67 } 67 }
68 68
69 // Find the TabContents that contains this tab id. 69 // Find the TabContents that contains this tab id.
70 TabContents* contents = NULL; 70 TabContents* contents = NULL;
71 bool result = ExtensionTabUtil::GetTabById( 71 bool result = ExtensionTabUtil::GetTabById(
72 tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL); 72 tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL);
73 if (!result || !contents) { 73 if (!result || !contents) {
74 error_ = ExtensionErrorUtils::FormatErrorMessage(kNoTabError, 74 error_ = ExtensionErrorUtils::FormatErrorMessage(
75 IntToString(tab_id)); 75 kNoTabError, base::IntToString(tab_id));
76 return false; 76 return false;
77 } 77 }
78 78
79 // Make sure the URL hasn't changed. 79 // Make sure the URL hasn't changed.
80 NavigationEntry* entry = contents->controller().GetActiveEntry(); 80 NavigationEntry* entry = contents->controller().GetActiveEntry();
81 if (!entry || url != entry->url().spec()) { 81 if (!entry || url != entry->url().spec()) {
82 error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url); 82 error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url);
83 return false; 83 return false;
84 } 84 }
85 85
(...skipping 11 matching lines...) Expand all
97 if (!page_action_) { 97 if (!page_action_) {
98 error_ = kNoPageActionError; 98 error_ = kNoPageActionError;
99 return false; 99 return false;
100 } 100 }
101 101
102 // Find the TabContents that contains this tab id. 102 // Find the TabContents that contains this tab id.
103 contents_ = NULL; 103 contents_ = NULL;
104 bool result = ExtensionTabUtil::GetTabById( 104 bool result = ExtensionTabUtil::GetTabById(
105 tab_id, profile(), include_incognito(), NULL, NULL, &contents_, NULL); 105 tab_id, profile(), include_incognito(), NULL, NULL, &contents_, NULL);
106 if (!result || !contents_) { 106 if (!result || !contents_) {
107 error_ = ExtensionErrorUtils::FormatErrorMessage(kNoTabError, 107 error_ = ExtensionErrorUtils::FormatErrorMessage(
108 IntToString(tab_id)); 108 kNoTabError, base::IntToString(tab_id));
109 return false; 109 return false;
110 } 110 }
111 111
112 return true; 112 return true;
113 } 113 }
114 114
115 bool PageActionFunction::SetVisible(bool visible) { 115 bool PageActionFunction::SetVisible(bool visible) {
116 int tab_id; 116 int tab_id;
117 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); 117 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
118 if (!InitCommon(tab_id)) 118 if (!InitCommon(tab_id))
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if (!InitCommon(tab_id)) 278 if (!InitCommon(tab_id))
279 return false; 279 return false;
280 280
281 std::string text; 281 std::string text;
282 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); 282 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text));
283 283
284 page_action_->SetBadgeText(tab_id, text); 284 page_action_->SetBadgeText(tab_id, text);
285 contents_->PageActionStateChanged(); 285 contents_->PageActionStateChanged();
286 return true; 286 return true;
287 } 287 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_infobar_module.cc ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698