| 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/chromeos/extensions/file_handler_util.h" | 5 #include "chrome/browser/chromeos/extensions/file_handler_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
| 12 #include "chrome/browser/extensions/extension_event_router.h" | 13 #include "chrome/browser/extensions/extension_event_router.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_tab_util.h" | 15 #include "chrome/browser/extensions/extension_tab_util.h" |
| 15 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/common/extensions/file_browser_handler.h" | 19 #include "chrome/common/extensions/file_browser_handler.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/child_process_security_policy.h" | 22 #include "content/public/browser/child_process_security_policy.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 207 } |
| 207 } | 208 } |
| 208 } | 209 } |
| 209 | 210 |
| 210 const DictionaryValue* prefs_tasks = | 211 const DictionaryValue* prefs_tasks = |
| 211 profile->GetPrefs()->GetDictionary(prefs::kLastUsedFileBrowserHandlers); | 212 profile->GetPrefs()->GetDictionary(prefs::kLastUsedFileBrowserHandlers); |
| 212 for (ActionSet::const_iterator iter = common_tasks.begin(); | 213 for (ActionSet::const_iterator iter = common_tasks.begin(); |
| 213 iter != common_tasks.end(); ++iter) { | 214 iter != common_tasks.end(); ++iter) { |
| 214 // Get timestamp of when this task was used last time. | 215 // Get timestamp of when this task was used last time. |
| 215 int last_used_timestamp = 0; | 216 int last_used_timestamp = 0; |
| 217 |
| 218 if ((*iter)->extension_id() == kFileBrowserDomain) { |
| 219 // Give a little bump to the action from File Browser extenion |
| 220 // to make sure it is the default on a fresh profile. |
| 221 last_used_timestamp = 1; |
| 222 } |
| 216 prefs_tasks->GetInteger(MakeTaskID((*iter)->extension_id(), (*iter)->id()), | 223 prefs_tasks->GetInteger(MakeTaskID((*iter)->extension_id(), (*iter)->id()), |
| 217 &last_used_timestamp); | 224 &last_used_timestamp); |
| 218 URLPatternSet matching_patterns = GetAllMatchingPatterns(*iter, files_list); | 225 URLPatternSet matching_patterns = GetAllMatchingPatterns(*iter, files_list); |
| 219 named_action_list->push_back(LastUsedHandler(last_used_timestamp, *iter, | 226 named_action_list->push_back(LastUsedHandler(last_used_timestamp, *iter, |
| 220 matching_patterns)); | 227 matching_patterns)); |
| 221 } | 228 } |
| 222 | 229 |
| 223 SortLastUsedHandlerList(named_action_list); | 230 SortLastUsedHandlerList(named_action_list); |
| 224 return true; | 231 return true; |
| 225 } | 232 } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 base::JSONWriter::Write(event_args.get(), false, &json_args); | 545 base::JSONWriter::Write(event_args.get(), false, &json_args); |
| 539 event_router->DispatchEventToExtension( | 546 event_router->DispatchEventToExtension( |
| 540 extension_id_, std::string("fileBrowserHandler.onExecute"), | 547 extension_id_, std::string("fileBrowserHandler.onExecute"), |
| 541 json_args, profile_, | 548 json_args, profile_, |
| 542 GURL()); | 549 GURL()); |
| 543 Done(true); | 550 Done(true); |
| 544 } | 551 } |
| 545 | 552 |
| 546 } // namespace file_handler_util | 553 } // namespace file_handler_util |
| 547 | 554 |
| OLD | NEW |